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