From 2952db57564cb4ba384f920049bc8dadc10e0746 Mon Sep 17 00:00:00 2001 From: hannahhoward Date: Wed, 28 Jul 2021 13:53:06 -0700 Subject: [PATCH] feat(graphsync): improve logging associate graphsync requests to dt requests, record channel sends as they happen --- channels/channels.go | 3 ++- transport/graphsync/graphsync.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/channels/channels.go b/channels/channels.go index ab4dc866..71952aca 100644 --- a/channels/channels.go +++ b/channels/channels.go @@ -123,7 +123,7 @@ func (c *Channels) dispatch(eventName fsm.EventName, channel fsm.StateType) { Message: realChannel.Message, Timestamp: time.Now(), } - + log.Debugw("process data transfer listeners", "name", datatransfer.Events[evtCode], "transfer ID", realChannel.TransferID) c.notifier(evt, c.fromInternalChannelState(realChannel)) // When the channel has been cleaned up, remove the caches of seen cids @@ -406,6 +406,7 @@ func (c *Channels) send(chid datatransfer.ChannelID, code datatransfer.EventCode if err != nil { return err } + log.Debugw("send data transfer event", "name", datatransfer.Events[code], "transfer ID", chid.ID, "args", args) return c.stateMachines.Send(chid, code, args...) } diff --git a/transport/graphsync/graphsync.go b/transport/graphsync/graphsync.go index 34cd8d1f..7fbf44a7 100644 --- a/transport/graphsync/graphsync.go +++ b/transport/graphsync/graphsync.go @@ -949,7 +949,7 @@ func (c *dtChannel) gsReqOpened(gsKey graphsyncKey, hookActions graphsync.Outgoi if c.hasStore() { hookActions.UsePersistenceOption("data-transfer-" + c.channelID.String()) } - + log.Infow("outgoing graphsync request", "peer", gsKey.p, "graphsync request id", gsKey.requestID, "data transfer channel id", c.channelID) // Save a mapping from the graphsync key to the channel ID so that // subsequent graphsync callbacks are associated with this channel c.gsKeyToChannelID.set(gsKey, c.channelID) @@ -982,6 +982,7 @@ func (c *dtChannel) gsDataRequestRcvd(gsKey graphsyncKey, hookActions graphsync. // Save a mapping from the graphsync key to the channel ID so that // subsequent graphsync callbacks are associated with this channel c.gsKey = gsKey + log.Infow("incoming graphsync request", "peer", gsKey.p, "graphsync request id", gsKey.requestID, "data transfer channel id", c.channelID) c.gsKeyToChannelID.set(gsKey, c.channelID) c.isOpen = true