-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Background
go-fil-markets assumes that Disconnect is only fired when several retries have been attempted, so on the client side it fails the deal when the Disconnect event is fired (on the provider side it waits for the client to reconnect).
In most places in the go-data-transfer code, the Disconnect event is only fired when SendMessage fails, and SendMessage only fails after attempting to retry the message send several times.
Lines 305 to 309 in d4e6175
| if err := m.dataTransferNetwork.SendMessage(ctx, chst.OtherPeer(), updateRequest); err != nil { | |
| err = fmt.Errorf("Unable to send request: %w", err) | |
| _ = m.OnRequestDisconnected(ctx, channelID) | |
| return err | |
| } |
However when there is an error sending data with graphsync (eg because the connection went down), go-data-transfer fires the Disconnect event:
go-data-transfer/transport/graphsync/graphsync.go
Lines 698 to 709 in d4e6175
| func (t *Transport) gsNetworkErrorListener(p peer.ID, request graphsync.RequestData, err error) { | |
| t.dataLock.Lock() | |
| defer t.dataLock.Unlock() | |
| chid, ok := t.graphsyncRequestMap[graphsyncKey{request.ID(), p}] | |
| if ok { | |
| err := t.events.OnRequestDisconnected(context.TODO(), chid) | |
| if err != nil { | |
| log.Error(err) | |
| } | |
| } | |
| } |
When go-fil-markets sees the Disconnect event it immediately fails the deal.
Currently for push channels (the local node initiated a channel to send data to the remote peer), the push channel monitor will automatically attempt to send a "restart" message when it sees a data-transfer error:
go-data-transfer/pushchannelmonitor/pushchannelmonitor.go
Lines 225 to 228 in d4e6175
| case datatransfer.Error: | |
| // If there's an error, attempt to restart the channel | |
| log.Debugf("%s: data transfer error, restarting", mc.chid) | |
| go mc.restartChannel() |
However when go-fil-markets receives an Error event from go-data-transfer it immediately aborts the transfer.
Proposed Solution
When there is an error sending data with graphsync, fire a new SendError event.
In the push channel monitor, listen for the SendError event and respond by restarting the push channel.
More detail on the proposed solution: #160