Skip to content

Commit 545c7e3

Browse files
authored
fix(protocol): guard debug log message again nil (#1212)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent becb83c commit 545c7e3

File tree

1 file changed

+27
-23
lines changed

1 file changed

+27
-23
lines changed

protocol/chainsync/server.go

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,15 @@ func (s *Server) messageHandler(msg protocol.Message) error {
177177
}
178178

179179
func (s *Server) handleRequestNext() error {
180-
// TODO: figure out why this one log message causes a panic (and only this one)
181-
// during tests (#857)
182-
// s.Protocol.Logger().
183-
// Debug("request next",
184-
// "component", "network",
185-
// "protocol", ProtocolName,
186-
// "role", "server",
187-
// "connection_id", s.callbackContext.ConnectionId.String(),
188-
// )
180+
if s.Protocol != nil {
181+
s.Protocol.Logger().
182+
Debug("request next",
183+
"component", "network",
184+
"protocol", ProtocolName,
185+
"role", "server",
186+
"connection_id", s.callbackContext.ConnectionId.String(),
187+
)
188+
}
189189
if s.config == nil || s.config.RequestNextFunc == nil {
190190
return errors.New(
191191
"received chain-sync RequestNext message but no callback function is defined",
@@ -195,13 +195,15 @@ func (s *Server) handleRequestNext() error {
195195
}
196196

197197
func (s *Server) handleFindIntersect(msg protocol.Message) error {
198-
s.Protocol.Logger().
199-
Debug("find intersect",
200-
"component", "network",
201-
"protocol", ProtocolName,
202-
"role", "server",
203-
"connection_id", s.callbackContext.ConnectionId.String(),
204-
)
198+
if s.Protocol != nil {
199+
s.Protocol.Logger().
200+
Debug("find intersect",
201+
"component", "network",
202+
"protocol", ProtocolName,
203+
"role", "server",
204+
"connection_id", s.callbackContext.ConnectionId.String(),
205+
)
206+
}
205207
if s.config == nil || s.config.FindIntersectFunc == nil {
206208
return errors.New(
207209
"received chain-sync FindIntersect message but no callback function is defined",
@@ -230,13 +232,15 @@ func (s *Server) handleFindIntersect(msg protocol.Message) error {
230232
}
231233

232234
func (s *Server) handleDone() error {
233-
s.Protocol.Logger().
234-
Debug("done",
235-
"component", "network",
236-
"protocol", ProtocolName,
237-
"role", "server",
238-
"connection_id", s.callbackContext.ConnectionId.String(),
239-
)
235+
if s.Protocol != nil {
236+
s.Protocol.Logger().
237+
Debug("done",
238+
"component", "network",
239+
"protocol", ProtocolName,
240+
"role", "server",
241+
"connection_id", s.callbackContext.ConnectionId.String(),
242+
)
243+
}
240244
// Restart protocol
241245
s.Stop()
242246
s.initProtocol()

0 commit comments

Comments
 (0)