Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using no disk based files with torrent creation. #648

Open
BernhardGlueck opened this issue Dec 11, 2023 · 3 comments
Open

Using no disk based files with torrent creation. #648

BernhardGlueck opened this issue Dec 11, 2023 · 3 comments

Comments

@BernhardGlueck
Copy link

Hi !

I have the following issue, or rather just a request for someone to point me into the right direction.
I have a content repository that is read only from my side, and which is represented by the following interfaces.
Each content file is represented by a sequential collection of blocks all identified by their SHA256 hash.
The blocks are each 1 MB in size ( except the last one of a given content item )

interface IBlock 
{
  long Size { get; }
  byte[] Sha256 { get; }
  
  Stream OpenRead();
}

interface IContent : IReadOnlyList<IBlock>
{
    string Filename { get; }
     long Size { get; }
}

Now i would like to distribute those content files via bittorrent, using monotorrent of course.
Backward compatiblity is no concern, as all clients are under my control. So the V2 protocol can be used,

In my mind the structure i have maps perfectly to torrents and their piece structure, and since i already have the SHA256 hashes
this would also work quite well with the V2 protocol .

However currently i am struggling on how to plug my system into montorrent e.g creating a torrent file from a collection of such content items...

All the samples and interfaces like ITorrentFileSource etc assume that the files reside on disk, and that piece are not already defined.

Is there a way to plug my system into the torrent creation pipeline ? Where should i start to look in terms of interfaces ?

@BernhardGlueck
Copy link
Author

After some more investigation it seems that i would have to reimplement TorrentCreator
However a lot of the types needed to do this are internal to monotorrent... i would rather like to avoid doing a full source fork ...
Any ideas ?

@lostmsu
Copy link

lostmsu commented Mar 21, 2024

@BernhardGlueck what did you end up doing?

@BernhardGlueck
Copy link
Author

BernhardGlueck commented Mar 22, 2024

I wrote everything from scratch so its now not related to monotorrent anymore ( our own Beencode writer and of course the Torrent V2 creation ) .. works like a charm... however it was very difficult as the TorrentV2 spec is very ambiguous and left us with a lot of trial and error to do. Especially if you don't have the original file but only its piece hashes ( tree padding logic and the 16 kb page hashes )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants