lnwire: embed ChannelID within the announcement structs rather than pointer
This commit is contained in:
parent
597b4ee3d3
commit
5ee201e712
@ -44,7 +44,7 @@ type ChannelAnnouncement struct {
|
||||
SecondNodeSig *btcec.Signature
|
||||
|
||||
// ChannelID is the unique description of the funding transaction.
|
||||
ChannelID *ChannelID
|
||||
ChannelID ChannelID
|
||||
|
||||
// This signatures are used by nodes in order to create cross
|
||||
// references between node's channel and node. Requiring the bitcoin
|
||||
|
@ -4,8 +4,9 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/roasbeef/btcd/btcec"
|
||||
"io"
|
||||
|
||||
"github.com/roasbeef/btcd/btcec"
|
||||
)
|
||||
|
||||
// ChannelUpdateAnnouncement message is used after channel has been initially
|
||||
@ -18,7 +19,7 @@ type ChannelUpdateAnnouncement struct {
|
||||
Signature *btcec.Signature
|
||||
|
||||
// ChannelID is the unique description of the funding transaction.
|
||||
ChannelID *ChannelID
|
||||
ChannelID ChannelID
|
||||
|
||||
// Timestamp allows ordering in the case of multiple announcements.
|
||||
// We should ignore the message if timestamp is not greater than
|
||||
|
@ -326,7 +326,7 @@ func writeElement(w io.Writer, element interface{}) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
case *ChannelID:
|
||||
case ChannelID:
|
||||
// Check that field fit in 3 bytes and write the blockHeight
|
||||
if e.BlockHeight > ((1 << 24) - 1) {
|
||||
return errors.New("block height should fit in 3 bytes")
|
||||
@ -669,7 +669,7 @@ func readElement(r io.Reader, element interface{}) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
case **ChannelID:
|
||||
case *ChannelID:
|
||||
var blockHeight [4]byte
|
||||
if _, err = io.ReadFull(r, blockHeight[1:]); err != nil {
|
||||
return err
|
||||
@ -685,7 +685,7 @@ func readElement(r io.Reader, element interface{}) error {
|
||||
return err
|
||||
}
|
||||
|
||||
*e = &ChannelID{
|
||||
*e = ChannelID{
|
||||
BlockHeight: binary.BigEndian.Uint32(blockHeight[:]),
|
||||
TxIndex: binary.BigEndian.Uint32(txIndex[:]),
|
||||
TxPosition: binary.BigEndian.Uint16(txPosition[:]),
|
||||
|
@ -7,10 +7,11 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"net"
|
||||
|
||||
"github.com/roasbeef/btcd/btcec"
|
||||
"github.com/roasbeef/btcd/txscript"
|
||||
"github.com/roasbeef/btcd/wire"
|
||||
"net"
|
||||
)
|
||||
|
||||
// Common variables and functions for the message tests
|
||||
@ -103,7 +104,7 @@ var (
|
||||
|
||||
someAddress = &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 8333}
|
||||
|
||||
someChannelID = &ChannelID{
|
||||
someChannelID = ChannelID{
|
||||
BlockHeight: maxUint24,
|
||||
TxIndex: maxUint24,
|
||||
TxPosition: maxUint16,
|
||||
|
Loading…
Reference in New Issue
Block a user