Skip to content

Commit

Permalink
Retrieval Market Extraction (#13)
Browse files Browse the repository at this point in the history
* feat(retrievalmarket): extract from lotus

Extract retrievalmarket from lotus, migrate to shared types, use cbor-gen-for, etc

* Testing refactors (#21)

* extract mocknet setup from datatransfer testing, fold whitebox testing into graphsync_impl_test

Co-authored-by: Shannon Wells <[email protected]>
  • Loading branch information
2 people authored and ingar committed Dec 19, 2019
1 parent d9fb621 commit 920f643
Show file tree
Hide file tree
Showing 16 changed files with 2,895 additions and 377 deletions.
9 changes: 8 additions & 1 deletion datatransfer/impl/graphsync/graphsync_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,13 @@ func (impl *graphsyncImpl) TransferChannelStatus(x datatransfer.ChannelID) datat
return datatransfer.ChannelNotFoundError
}

// Subscribers returns a copy of the list of subscribers.
func (impl *graphsyncImpl) Subscribers() []datatransfer.Subscriber {
subscribersCopy := make([]datatransfer.Subscriber, len(impl.subscribers))
copy(subscribersCopy, impl.subscribers)
return subscribersCopy
}

// get notified when certain types of events happen
func (impl *graphsyncImpl) SubscribeToEvents(subscriber datatransfer.Subscriber) datatransfer.Unsubscribe {
impl.subscribers = append(impl.subscribers, subscriber)
Expand All @@ -277,7 +284,7 @@ func (impl *graphsyncImpl) unsubscribeAt(sub datatransfer.Subscriber) datatransf
}

func (impl *graphsyncImpl) notifySubscribers(evt datatransfer.Event, cs datatransfer.ChannelState) {
for _, cb := range impl.subscribers {
for _, cb := range impl.Subscribers() {
cb(evt, cs)
}
}
Expand Down
Loading

0 comments on commit 920f643

Please sign in to comment.