-
Notifications
You must be signed in to change notification settings - Fork 338
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
feat: propagate stream error to origin node for pushsync and retrieval protocols #4321
Conversation
pkg/p2p/p2p.go
Outdated
@@ -222,3 +223,30 @@ const ( | |||
func NewSwarmStreamName(protocol, version, stream string) string { | |||
return "/swarm/" + protocol + "/" + version + "/" + stream | |||
} | |||
|
|||
var errDelivery = errors.New("received delivery error msg") |
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.
This error is not necessary, I'd recommend doing the following:
// ChunkDeliveryError contains information about a failed chunk delivery to a peer.
type ChunkDeliveryError struct {
chunk swarm.Chunk
peer swarm.Address
msg string
}
// Error implements the error interface.
func (e *ChunkDeliveryError) Error() string {
return fmt.Sprintf("delivery of chunk %s to peer %s: %s", e.chunk.Address(), e.peer, e.msg)
}
// NewChunkDeliveryError is a convenience constructor for ChunkDeliveryError.
func NewChunkDeliveryError(chunk swarm.Chunk, peer swarm.Address, msg string) error {
return &ChunkDeliveryError{
chunk: chunk,
peer: peer,
msg: msg,
}
}
The Unwrap
method is not needed in this case.
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.
thanks for the suggestion, I made the change but without peer or chunk address because the existing logs take care of this
Checklist
Description
Introduces a simple mechanism to return error messages for pushsync and retrieval protocols so the origin node can log the error messages.
Bumps protocol versions.
To be included in the upcoming breaking release (ph4).
Open API Spec Version Changes (if applicable)
Motivation and Context (Optional)
Related Issue (Optional)
Screenshots (if appropriate):