Skip to content

Commit

Permalink
fix(graphsync): fix UseStore for restarts (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahhoward authored Dec 1, 2020
1 parent e9108e7 commit 39b37dc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions transport/graphsync/graphsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,17 @@ func (t *Transport) Shutdown(ctx context.Context) error {

// UseStore tells the graphsync transport to use the given loader and storer for this channelID
func (t *Transport) UseStore(channelID datatransfer.ChannelID, loader ipld.Loader, storer ipld.Storer) error {
t.dataLock.Lock()
defer t.dataLock.Unlock()
_, ok := t.stores[channelID]
if ok {
return nil
}
err := t.gs.RegisterPersistenceOption("data-transfer-"+channelID.String(), loader, storer)
if err != nil {
return err
}
t.dataLock.Lock()
t.stores[channelID] = struct{}{}
t.dataLock.Unlock()
return nil
}

Expand Down

0 comments on commit 39b37dc

Please sign in to comment.