-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Feat/debug accept message error #210
base: master
Are you sure you want to change the base?
Changes from 5 commits
e62413b
d1e0642
a61b1d5
bc5a06d
6934ef0
fa3f7ae
8982d1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,29 +161,40 @@ func (m *manager) OnRequestReceived(chid datatransfer.ChannelID, request datatra | |
} | ||
|
||
func (m *manager) OnResponseReceived(chid datatransfer.ChannelID, response datatransfer.Response) error { | ||
log.Infof("channel %s: received response %+v from provider", chid, response) | ||
|
||
if response.IsCancel() { | ||
log.Infof("channel %s: received cancel response, cancelling channel", chid) | ||
return m.channels.Cancel(chid) | ||
} | ||
|
||
if response.IsVoucherResult() { | ||
log.Infof("channel %s: received response %+v from provider is a voucher result", chid, response) | ||
if !response.EmptyVoucherResult() { | ||
log.Debug("processing non-empty voucher result") | ||
vresult, err := m.decodeVoucherResult(response) | ||
if err != nil { | ||
log.Errorf("channel %s:, failed to decode voucher result, err=%s", chid, err) | ||
return err | ||
} | ||
log.Infof("channel %s: received voucher response %+v", chid, vresult) | ||
err = m.channels.NewVoucherResult(chid, vresult) | ||
if err != nil { | ||
log.Errorf("channel %s: failed NewVoucherResult, err=%s ", chid, err) | ||
return err | ||
} | ||
} | ||
|
||
if !response.Accepted() { | ||
log.Infof("channel %s: received rejected response, erroring out channel", chid) | ||
return m.channels.Error(chid, datatransfer.ErrRejected) | ||
} | ||
|
||
if response.IsNew() { | ||
log.Infof("channel %s: received new response, accepting channel", chid) | ||
err := m.channels.Accept(chid) | ||
if err != nil { | ||
log.Errorf("channel %s: failed to accept new response, err=%s", chid, err) | ||
return err | ||
} | ||
} | ||
|
@@ -196,16 +207,21 @@ 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) | ||
return m.channels.ResponderCompletes(chid) | ||
} | ||
|
||
log.Infof("channel %s: received complete response but responder is paused", chid) | ||
|
||
err := m.channels.ResponderBeginsFinalization(chid) | ||
if err != nil { | ||
return nil | ||
} | ||
} | ||
|
||
if response.IsPaused() { | ||
return m.pauseOther(chid) | ||
} | ||
|
@@ -432,6 +448,10 @@ func (m *manager) validateVoucher( | |
} | ||
|
||
result, err := validatorFunc(isRestart, sender, vouch, baseCid, stor) | ||
if isPull { | ||
log.Infof("\n ValidatePull, result=%s, err=%s", result, err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Not sure why we have \n inside a |
||
} | ||
|
||
return vouch, result, err | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -592,7 +592,9 @@ func (t *Transport) gsReqRecdHook(p peer.ID, request graphsync.RequestData, hook | |||||
// when a DT request comes in on graphsync, it's a pull | ||||||
chid = datatransfer.ChannelID{ID: msg.TransferID(), Initiator: p, Responder: t.peerID} | ||||||
request := msg.(datatransfer.Request) | ||||||
log.Debugf("will validate recieved gs request, chid=%s, request=%+v", chid, request) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
responseMessage, err = t.events.OnRequestReceived(chid, request) | ||||||
log.Debugf("will send response message %+v for request gs chid=%s, error/pause/resume value=%s", responseMessage, chid, err) | ||||||
} else { | ||||||
// when a DT response comes in on graphsync, it's a push | ||||||
chid = datatransfer.ChannelID{ID: msg.TransferID(), Initiator: t.peerID, Responder: p} | ||||||
|
@@ -604,15 +606,18 @@ func (t *Transport) gsReqRecdHook(p peer.ID, request graphsync.RequestData, hook | |||||
extensions, extensionErr := extension.ToExtensionData(responseMessage, t.supportedExtensions) | ||||||
if extensionErr != nil { | ||||||
hookActions.TerminateWithError(err) | ||||||
log.Errorf("terminated client gs request chid=%s with extension err=%s", chid, err) | ||||||
return | ||||||
} | ||||||
for _, extension := range extensions { | ||||||
log.Debugf("queued up extension %+v for response, gs chid=%s", extension, chid) | ||||||
hookActions.SendExtensionData(extension) | ||||||
} | ||||||
} | ||||||
|
||||||
if err != nil && err != datatransfer.ErrPause { | ||||||
hookActions.TerminateWithError(err) | ||||||
log.Errorf("terminated client gs request chid=%s with err=%s", chid, err) | ||||||
return | ||||||
} | ||||||
|
||||||
|
@@ -632,6 +637,7 @@ func (t *Transport) gsReqRecdHook(p peer.ID, request graphsync.RequestData, hook | |||||
hasXferStarted, isRestart := t.channelXferStarted[chid] | ||||||
if isRestart && !hasXferStarted && !paused { | ||||||
paused = true | ||||||
log.Debugf("pausing responder for request gs chid=%s, even though validator sent no-op as it's a restart req", chid) | ||||||
hookActions.PauseResponse() | ||||||
} | ||||||
t.channelXferStarted[chid] = !paused | ||||||
|
@@ -820,7 +826,11 @@ func (t *Transport) processExtension(chid datatransfer.ChannelID, gsMsg extensio | |||||
} | ||||||
|
||||||
dtResponse := msg.(datatransfer.Response) | ||||||
return nil, t.events.OnResponseReceived(chid, dtResponse) | ||||||
err = t.events.OnResponseReceived(chid, dtResponse) | ||||||
if err != nil { | ||||||
log.Errorf("\n error receieved from OnResponseReceived is %s", err) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment here - why |
||||||
} | ||||||
return nil, err | ||||||
} | ||||||
|
||||||
func (t *Transport) gsRequestorCancelledListener(p peer.ID, request graphsync.RequestData) { | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add the
chid
as part of this logline, so that we can correlate to which channel this refers?