Opinion on how to implement a remote storage backend. #515
Zilog8-duplicate
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
Ok, GitHub just made me a duplicate account, weird. Anyway, this is my main account. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Problem: I want to download a 100gb torrent, but my server only has 10gb of disk space
Solution: Write a remote storage back end. (Did it in the past for a different torrent client jackpal/Taipei-Torrent@1b09582 )
Goals for Efficiency:
(1) is relatively trivial; I could just adapt the cached storage backend and SFTP client I made for Taipei-Torrent, but (2) requires refactoring where piece hashing is done (also a different transfer protocol altogether; although SFTP's spec includes an optional "check-file" extension, few servers implement it and it's not flexible enough to hash pieces that span more than one file).
I've been getting familiar with anacrolix/torrent code over the weekend, but want to get someone else's opinion on how I plan to implement the anacrolix/torrent side of this:
Step 1:
In anacrolix/torrent/storage/interface.go ; Create a new interface:
type SelfHashing interface { SelfHash() metainfo.Hash }
Step 2:
Refactor the contents of
func (t *Torrent) hashPiece(piece pieceIndex) (ret metainfo.Hash, err error)
(in anacrolix/torrent/torrent.go), out into new functionfunc (p Piece) SumHash (ret metainfo.Hash, err error)
(in anacrolix/torrent/storage/wrappers.go). hashPiece would basically just call and return the results from p.SumHashStep 3:
func (p Piece) SumHash
pseudocode:if p implements SelfHashing { return p.SelfHash() } Else { calculate the hash using the code moved during step 2 }
This should result in storage backends being able to override how hashing is done if they want to (by implementing the SelfHashing interface), but maintaining backwards compatibility for all storage backends who don't (without modification)
Opinions?
Beta Was this translation helpful? Give feedback.
All reactions