Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions impl/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ func (m *manager) OnTransferQueued(chid datatransfer.ChannelID) {
}

func (m *manager) OnResponseReceived(chid datatransfer.ChannelID, response datatransfer.Response) error {
if response.IsComplete() {
log.Infow("received complete response", "chid", chid, "isAccepted", response.Accepted())
}

if response.IsCancel() {
log.Infof("channel %s: received cancel response, cancelling channel", chid)
return m.channels.Cancel(chid)
Expand Down Expand Up @@ -202,9 +206,11 @@ func (m *manager) OnResponseReceived(chid datatransfer.ChannelID, response datat
}
if response.IsComplete() && response.Accepted() {
if !response.IsPaused() {
log.Infof("channel %s: received complete response, completing channel", chid)
log.Infow("received complete response,responder not paused, completing channel", "chid", chid)
return m.channels.ResponderCompletes(chid)
}

log.Infow("received complete response, responder is paused, not completing channel", "chid", chid)
err := m.channels.ResponderBeginsFinalization(chid)
if err != nil {
return nil
Expand Down Expand Up @@ -244,17 +250,20 @@ func (m *manager) OnChannelCompleted(chid datatransfer.ChannelID, completeErr er
if completeErr == nil {
// If the channel was initiated by the other peer
if chid.Initiator != m.peerID {
log.Infow("received OnChannelCompleted, will send completion message to initiator", "chid", chid)
msg, err := m.completeMessage(chid)
if err != nil {
return nil
return err
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this changed on purpose? I see everything else is log lines, apart from this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs an explanation, as it introduces a change in behaviour.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey,

The error returned from here is only logged and we take no action based on it. If there's an error while creating the complete message, we do want to know about it.

}
if msg != nil {
// Send the other peer a message that the transfer has completed
log.Infof("channel %s: sending completion message to initiator", chid)
log.Infow("sending completion message to initiator", "chid", chid)
if err := m.dataTransferNetwork.SendMessage(context.Background(), chid.Initiator, msg); err != nil {
err := xerrors.Errorf("channel %s: failed to send completion message to initiator: %w", chid, err)
log.Warn(err)
log.Warnw("failed to send completion message to initiator", "chid", chid, "err", err)
return m.OnRequestDisconnected(chid, err)
} else {
log.Infow("successfully sent completion message to initiator", "chid", chid)
}
}
if msg.Accepted() {
Expand Down