Skip to content

Commit 0a742cf

Browse files
authored
feat(graphsync): improve logging (#225)
associate graphsync requests to dt requests, record channel sends as they happen
1 parent 191dec0 commit 0a742cf

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

channels/channels.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func (c *Channels) dispatch(eventName fsm.EventName, channel fsm.StateType) {
123123
Message: realChannel.Message,
124124
Timestamp: time.Now(),
125125
}
126-
126+
log.Debugw("process data transfer listeners", "name", datatransfer.Events[evtCode], "transfer ID", realChannel.TransferID)
127127
c.notifier(evt, c.fromInternalChannelState(realChannel))
128128

129129
// 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
406406
if err != nil {
407407
return err
408408
}
409+
log.Debugw("send data transfer event", "name", datatransfer.Events[code], "transfer ID", chid.ID, "args", args)
409410
return c.stateMachines.Send(chid, code, args...)
410411
}
411412

transport/graphsync/graphsync.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ func (c *dtChannel) gsReqOpened(gsKey graphsyncKey, hookActions graphsync.Outgoi
949949
if c.hasStore() {
950950
hookActions.UsePersistenceOption("data-transfer-" + c.channelID.String())
951951
}
952-
952+
log.Infow("outgoing graphsync request", "peer", gsKey.p, "graphsync request id", gsKey.requestID, "data transfer channel id", c.channelID)
953953
// Save a mapping from the graphsync key to the channel ID so that
954954
// subsequent graphsync callbacks are associated with this channel
955955
c.gsKeyToChannelID.set(gsKey, c.channelID)
@@ -982,6 +982,7 @@ func (c *dtChannel) gsDataRequestRcvd(gsKey graphsyncKey, hookActions graphsync.
982982
// Save a mapping from the graphsync key to the channel ID so that
983983
// subsequent graphsync callbacks are associated with this channel
984984
c.gsKey = gsKey
985+
log.Infow("incoming graphsync request", "peer", gsKey.p, "graphsync request id", gsKey.requestID, "data transfer channel id", c.channelID)
985986
c.gsKeyToChannelID.set(gsKey, c.channelID)
986987

987988
c.isOpen = true

0 commit comments

Comments
 (0)