channeldb: add ChainHash to ChannelEdgeInfo to match BOLT-0007

This commit is contained in:
Olaoluwa Osuntokun 2017-08-21 22:57:16 -07:00
parent 59aae249dc
commit 35d9dc8092
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

@ -1078,6 +1078,13 @@ type ChannelEdgeInfo struct {
// and the last 2 bytes are the output index for the channel. // and the last 2 bytes are the output index for the channel.
ChannelID uint64 ChannelID uint64
// ChainHash is the hash that uniquely identifies the chain that this
// channel was opened within.
//
// TODO(roasbeef): need to modify db keying for multi-chain
// * must add chain hash to prefix as well
ChainHash chainhash.Hash
// NodeKey1 is the identity public key of the "first" node that was // NodeKey1 is the identity public key of the "first" node that was
// involved in the creation of this channel. A node is considered // involved in the creation of this channel. A node is considered
// "first" if the lexicographical ordering the its serialized public // "first" if the lexicographical ordering the its serialized public
@ -1674,6 +1681,9 @@ func putChanEdgeInfo(edgeIndex *bolt.Bucket, edgeInfo *ChannelEdgeInfo, chanID [
if _, err := b.Write(chanID[:]); err != nil { if _, err := b.Write(chanID[:]); err != nil {
return err return err
} }
if _, err := b.Write(edgeInfo.ChainHash[:]); err != nil {
return err
}
return edgeIndex.Put(chanID[:], b.Bytes()) return edgeIndex.Put(chanID[:], b.Bytes())
} }
@ -1774,6 +1784,10 @@ func deserializeChanEdgeInfo(r io.Reader) (*ChannelEdgeInfo, error) {
return nil, err return nil, err
} }
if _, err := io.ReadFull(r, edgeInfo.ChainHash[:]); err != nil {
return nil, err
}
return edgeInfo, nil return edgeInfo, nil
} }