lnwire+peer: introduce new error for unknown message type for forward compat
This commit adds a new error type to the `lnwire` package: `UnknownMessage`. With this error we can catch the particular case of a an error during reading that encounters a new or unknown message. When we encounter this message in the peer’s readHandler, we can now gracefully handle it by just skipping to the next message rather than closing out the section entirely. This puts us a bit closer to the spec, but not exactly as it has an additional constraint that we can only ignore a new message if it has an odd type. In a future release, we’ll modify this code to match the spec as written.
This commit is contained in:
2 files changed
+32
-3
No files matched your search
@@ -360,7 +360,21 @@ out:
|
||||
nextMsg, _, err := p.readNextMessage()
|
||||
if err != nil {
|
||||
peerLog.Infof("unable to read message: %v", err)
|
||||
break out
|
||||
|
||||
switch err.(type) {
|
||||
// If this is just a message we don't yet recognize,
|
||||
// we'll continue processing as normal as this allows
|
||||
// us to introduce new messages in a forwards
|
||||
// compatible manner.
|
||||
case *lnwire.UnknownMessage:
|
||||
continue
|
||||
|
||||
// If the error we encountered wasn't just a message we
|
||||
// didn't recognize, then we'll stop all processing s
|
||||
// this is a fatal error.
|
||||
default:
|
||||
break out
|
||||
}
|
||||
}
|
||||
|
||||
var isChanUpdate bool
|
||||
|
||||
Reference in new issue
Block a user