channeldb: also ignore the EOF error when trying to read ExtraOpaqueBytes

In this commit, we account for the additional case wherein the
announcement hasn't yet been written with the extra zero byte to
indicate that there aren't any remaining bytes to be read. Before this
commit, we accounted for the case where the announcement was written
with the extra byte, but now we ensure that legacy nodes that upgrade
will be able to boot properly.
This commit is contained in:
Olaoluwa Osuntokun 2018-09-05 16:42:16 -07:00
parent 48072f8e82
commit 785efcfaa2
No known key found for this signature in database
GPG key ID: 964EA263DD637C21

View file

@ -2860,7 +2860,10 @@ func deserializeLightningNode(r io.Reader) (LightningNode, error) {
node.ExtraOpaqueData, err = wire.ReadVarBytes(
r, 0, MaxAllowedExtraOpaqueBytes, "blob",
)
if err != nil && err != io.ErrUnexpectedEOF {
switch {
case err == io.ErrUnexpectedEOF:
case err == io.EOF:
case err != nil:
return LightningNode{}, err
}
@ -3012,7 +3015,10 @@ func deserializeChanEdgeInfo(r io.Reader) (ChannelEdgeInfo, error) {
edgeInfo.ExtraOpaqueData, err = wire.ReadVarBytes(
r, 0, MaxAllowedExtraOpaqueBytes, "blob",
)
if err != nil && err != io.ErrUnexpectedEOF {
switch {
case err == io.ErrUnexpectedEOF:
case err == io.EOF:
case err != nil:
return ChannelEdgeInfo{}, err
}
@ -3260,7 +3266,10 @@ func deserializeChanEdgePolicy(r io.Reader,
edge.ExtraOpaqueData, err = wire.ReadVarBytes(
r, 0, MaxAllowedExtraOpaqueBytes, "blob",
)
if err != nil && err != io.ErrUnexpectedEOF {
switch {
case err == io.ErrUnexpectedEOF:
case err == io.EOF:
case err != nil:
return nil, err
}