application-research / autoretrieve

A server to make GraphSync data accessible on IPFS
22 stars 7 forks source link

feat: subscribe to filclient retrieval events #82

Closed kylehuntsman closed 2 years ago

kylehuntsman commented 2 years ago

Implement filclient retrieval subscriber into autoretrieve.

I was waffling on creating a new struct for the subscriber, but there currently isn't any additional state that needs to be retained, so I opted for making the retriever struct the subscriber.

kylehuntsman commented 2 years ago

Currently having trouble getting dependencies right around filclient and filecoin/ffi

rvagg commented 2 years ago

this works for me

patch ```diff diff --git a/filecoin/retriever.go b/filecoin/retriever.go index ef3e315..ea495ca 100644 --- a/filecoin/retriever.go +++ b/filecoin/retriever.go @@ -282,7 +282,7 @@ func (retriever *Retriever) retrieve(ctx context.Context, query candidateQuery) timedOut = true }) } - stats, err := retriever.filClient.RetrieveContextFromPeerWithProgressCallback(retrieveCtx, query.candidate.MinerPeer.ID, query.response.PaymentAddress, proposal, func(bytesReceived uint64) { + stats, err := retriever.filClient.RetrieveContentFromPeerWithProgressCallback(retrieveCtx, query.candidate.MinerPeer.ID, query.response.PaymentAddress, proposal, func(bytesReceived uint64) { if lastBytesReceivedTimer != nil { doneLk.Lock() if !done { diff --git a/go.mod b/go.mod index db3da76..8c6ef4c 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( contrib.go.opencensus.io/exporter/prometheus v0.4.0 - github.com/application-research/filclient v0.0.0-20220602175911-a6b8faf9f1cd + github.com/application-research/filclient v0.0.0-20220622165741-3ca6a3f3bc7a github.com/dustin/go-humanize v1.0.0 github.com/filecoin-project/go-address v0.0.6 github.com/filecoin-project/go-data-transfer v1.15.1 diff --git a/go.sum b/go.sum index 6d05bd5..f10ade8 100644 --- a/go.sum +++ b/go.sum @@ -100,8 +100,8 @@ github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYU github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= -github.com/application-research/filclient v0.0.0-20220602175911-a6b8faf9f1cd h1:IF5gUAti2Dnqe6GoQS7oxAcj6Gy+RXYKEyM5tPFtJ3c= -github.com/application-research/filclient v0.0.0-20220602175911-a6b8faf9f1cd/go.mod h1:QSOQ2dcnSvucj23jOg535mvTMezoNV0bdJbIySoDaOg= +github.com/application-research/filclient v0.0.0-20220622165741-3ca6a3f3bc7a h1:Xw4boQwfwLqBV9dx69j43XOdokgFVjfZ+Dnd6l+KJw8= +github.com/application-research/filclient v0.0.0-20220622165741-3ca6a3f3bc7a/go.mod h1:QSOQ2dcnSvucj23jOg535mvTMezoNV0bdJbIySoDaOg= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= ```