channeldb: store the funding transaction broadcast height for channels

This commit expands the field within the OpenChannel struct in order to
start tracking the height that the funding transaction was initially
broadcast. Other sub-systems within lnd can now use this data to give a
more accurate height hint to the ChainNotifier, or to use during the
funding workflow to decide if a channel should be forgotten after it
fails to confirm for N blocks.
This commit is contained in:
Olaoluwa Osuntokun committed 2017-06-05 19:15:44 -07:00
1 parent fb4121ba6c
commit 66ba2e862c
3 files changed
+60 -26

No files matched your search

+10 -3
View File
@@ -391,10 +391,17 @@ func (d *DB) MarkChannelAsOpen(outpoint *wire.OutPoint, openHeight uint32) error
// Finally, we'll also store the opening height for this
// channel as well.
byteOrder.PutUint32(scratch, openHeight)
copy(keyPrefix[:3], openHeightPrefix)
confInfoKey := make([]byte, len(confInfoPrefix)+len(b.Bytes()))
copy(confInfoKey[:len(confInfoPrefix)], confInfoPrefix)
copy(confInfoKey[len(confInfoPrefix):], b.Bytes())
return openChanBucket.Put(keyPrefix, scratch[:])
confInfoBytes := openChanBucket.Get(confInfoKey)
infoCopy := make([]byte, len(confInfoBytes))
copy(infoCopy[:], confInfoBytes)
byteOrder.PutUint32(infoCopy[4:], openHeight)
return openChanBucket.Put(confInfoKey, infoCopy)
})
}