lnwire: converge discovery part of messages with specification

Change the name of fields of messages which are belong to the discovery
subsystem in a such way so they were the same with the names that are
defined in the specification.
This commit is contained in:
Andrey Samokhvalov
2017-03-27 18:22:37 +03:00
committed by Olaoluwa Osuntokun
parent 54b3541707
commit c3b2854428
19 changed files with 163 additions and 165 deletions

View File

@@ -1,8 +1,8 @@
package lnwire
// ChannelID represent the set of data which is needed to retrieve all
// ShortChannelID represent the set of data which is needed to retrieve all
// necessary data to validate the channel existence.
type ChannelID struct {
type ShortChannelID struct {
// BlockHeight is the height of the block where funding transaction
// located.
//
@@ -18,21 +18,21 @@ type ChannelID struct {
TxPosition uint16
}
// NewChanIDFromInt returns a new ChannelID which is the decoded version of the
// compact channel ID encoded within the uint64. The format of the compact
// channel ID is as follows: 3 bytes for the block height, 3 bytes for the
// transaction index, and 2 bytes for the output index.
func NewChanIDFromInt(chanID uint64) ChannelID {
return ChannelID{
// NewShortChanIDFromInt returns a new ShortChannelID which is the decoded
// version of the compact channel ID encoded within the uint64. The format of
// the compact channel ID is as follows: 3 bytes for the block height, 3 bytes
// for the transaction index, and 2 bytes for the output index.
func NewShortChanIDFromInt(chanID uint64) ShortChannelID {
return ShortChannelID{
BlockHeight: uint32(chanID >> 40),
TxIndex: uint32(chanID>>16) & 0xFFFFFF,
TxPosition: uint16(chanID),
}
}
// ToUint64 converts the ChannelID into a compact format encoded within a
// ToUint64 converts the ShortChannelID into a compact format encoded within a
// uint64 (8 bytes).
func (c *ChannelID) ToUint64() uint64 {
func (c *ShortChannelID) ToUint64() uint64 {
// TODO(roasbeef): explicit error on overflow?
return ((uint64(c.BlockHeight) << 40) | (uint64(c.TxIndex) << 16) |
(uint64(c.TxPosition)))