diff --git a/protocol/chainsync/client.go b/protocol/chainsync/client.go index cb8f2b61..a3c9df70 100644 --- a/protocol/chainsync/client.go +++ b/protocol/chainsync/client.go @@ -722,7 +722,7 @@ func (c *Client) handleRollForward(msgGeneric protocol.Message) error { } } if callbackErr != nil { - if callbackErr == StopSyncProcessError { + if errors.Is(callbackErr, StopSyncProcessError) { // Signal that we're cancelling the sync c.readyForNextBlockChan <- false return nil @@ -751,7 +751,7 @@ func (c *Client) handleRollBackward(msg protocol.Message) error { } // Call the user callback function if callbackErr := c.config.RollBackwardFunc(c.callbackContext, msgRollBackward.Point, msgRollBackward.Tip); callbackErr != nil { - if callbackErr == StopSyncProcessError { + if errors.Is(callbackErr, StopSyncProcessError) { // Signal that we're cancelling the sync c.readyForNextBlockChan <- false return nil diff --git a/protocol/chainsync/client_test.go b/protocol/chainsync/client_test.go index d158f561..7f2bb54a 100644 --- a/protocol/chainsync/client_test.go +++ b/protocol/chainsync/client_test.go @@ -1,4 +1,4 @@ -// Copyright 2024 Blink Labs Software +// Copyright 2025 Blink Labs Software // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ package chainsync_test import ( + "errors" "fmt" "reflect" "testing" @@ -127,7 +128,7 @@ func TestIntersectNotFound(t *testing.T) { if err == nil { t.Fatalf("did not receive expected error") } - if err != chainsync.IntersectNotFoundError { + if !errors.Is(err, chainsync.IntersectNotFoundError) { t.Fatalf( "did not receive expected error\n got: %s\n wanted: %s", err, diff --git a/protocol/chainsync/server.go b/protocol/chainsync/server.go index 4a9dfe0d..a65a534e 100644 --- a/protocol/chainsync/server.go +++ b/protocol/chainsync/server.go @@ -203,7 +203,7 @@ func (s *Server) handleFindIntersect(msg protocol.Message) error { msgFindIntersect.Points, ) if err != nil { - if err == IntersectNotFoundError { + if errors.Is(err, IntersectNotFoundError) { msgResp := NewMsgIntersectNotFound(tip) if err := s.SendMessage(msgResp); err != nil { return err diff --git a/protocol/protocol.go b/protocol/protocol.go index 88c564df..56e1598a 100644 --- a/protocol/protocol.go +++ b/protocol/protocol.go @@ -363,7 +363,7 @@ func (p *Protocol) recvLoop() { tmpMsg := []cbor.RawMessage{} numBytesRead, err := cbor.Decode(recvBuffer.Bytes(), &tmpMsg) if err != nil { - if err == io.ErrUnexpectedEOF && recvBuffer.Len() > 0 { + if errors.Is(err, io.ErrUnexpectedEOF) && recvBuffer.Len() > 0 { // This is probably a multi-part message, so we wait until we get more of the message // before trying to process it p.recvReadyChan <- true