From af6c4e5174984936fa8518d6fcf8c07f0c254c79 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Fri, 27 Jul 2018 02:20:53 -0700 Subject: [PATCH] channeldb/channel: adds readLogKey for chanids Adds helper method to parse short chanids used as keys in the forwarding package. --- channeldb/channel.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/channeldb/channel.go b/channeldb/channel.go index d0a288218..e5dc42eab 100644 --- a/channeldb/channel.go +++ b/channeldb/channel.go @@ -2440,12 +2440,20 @@ func deleteOpenChannel(chanBucket *bolt.Bucket, chanPointBytes []byte) error { } +// makeLogKey converts a uint64 into an 8 byte array. func makeLogKey(updateNum uint64) [8]byte { var key [8]byte byteOrder.PutUint64(key[:], updateNum) return key } +// readLogKey parse the first 8- bytes of a byte slice into a uint64. +// +// NOTE: The slice must be at least 8 bytes long. +func readLogKey(b []byte) uint64 { + return byteOrder.Uint64(b) +} + func appendChannelLogEntry(log *bolt.Bucket, commit *ChannelCommitment) error {