lnwire: rename routing files to match current naming conventions

This commit drops the “_message” at the end of each of the newly added
routing files.
This commit is contained in:
Olaoluwa Osuntokun 2016-08-11 11:54:44 -07:00
parent 3563d0e6b9
commit c0d59a2d85
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
8 changed files with 69 additions and 59 deletions

@ -3,6 +3,7 @@
// file LICENSE or http://www.opensource.org/licenses/mit-license.php
package lnwire
import (
"fmt"
"io"
@ -16,24 +17,24 @@ func (msg *NeighborAckMessage) String() string {
return fmt.Sprintf("NeighborAckMessage{%v %v}", msg.SenderID, msg.ReceiverID)
}
func (msg *NeighborAckMessage) Command() uint32{
func (msg *NeighborAckMessage) Command() uint32 {
return CmdNeighborAckMessage
}
func (msg *NeighborAckMessage) Encode(w io.Writer, pver uint32) error{
func (msg *NeighborAckMessage) Encode(w io.Writer, pver uint32) error {
return nil
}
func (msg *NeighborAckMessage) Decode(r io.Reader, pver uint32) error{
func (msg *NeighborAckMessage) Decode(r io.Reader, pver uint32) error {
return nil
}
func (msg *NeighborAckMessage) MaxPayloadLength(uint32) uint32{
func (msg *NeighborAckMessage) MaxPayloadLength(uint32) uint32 {
return 0
}
func (msg *NeighborAckMessage) Validate() error{
func (msg *NeighborAckMessage) Validate() error {
return nil
}
var _ Message = (*NeighborAckMessage)(nil)
var _ Message = (*NeighborAckMessage)(nil)

@ -5,18 +5,19 @@
package lnwire
import (
"io"
"github.com/BitfuryLightning/tools/rt"
"encoding/gob"
"fmt"
"io"
"github.com/BitfuryLightning/tools/rt"
)
type NeighborHelloMessage struct{
type NeighborHelloMessage struct {
RoutingMessageBase
RT *rt.RoutingTable
}
func (msg *NeighborHelloMessage) Decode(r io.Reader, pver uint32) error{
func (msg *NeighborHelloMessage) Decode(r io.Reader, pver uint32) error {
decoder := gob.NewDecoder(r)
rt1 := rt.NewRoutingTable()
err := decoder.Decode(rt1.G)
@ -24,29 +25,28 @@ func (msg *NeighborHelloMessage) Decode(r io.Reader, pver uint32) error{
return err
}
func (msg *NeighborHelloMessage) Encode(w io.Writer, pver uint32) error{
func (msg *NeighborHelloMessage) Encode(w io.Writer, pver uint32) error {
encoder := gob.NewEncoder(w)
err := encoder.Encode(msg.RT.G)
return err
}
func (msg *NeighborHelloMessage) Command() uint32{
func (msg *NeighborHelloMessage) Command() uint32 {
return CmdNeighborHelloMessage
}
func (msg *NeighborHelloMessage) MaxPayloadLength(uint32) uint32{
func (msg *NeighborHelloMessage) MaxPayloadLength(uint32) uint32 {
// TODO: Insert some estimations
return 1000000
}
func (msg *NeighborHelloMessage) Validate() error{
func (msg *NeighborHelloMessage) Validate() error {
// TODO: Add validation
return nil
}
func (msg *NeighborHelloMessage) String() string{
func (msg *NeighborHelloMessage) String() string {
return fmt.Sprintf("NeighborHelloMessage{%v %v %v}", msg.SenderID, msg.ReceiverID, msg.RT)
}
var _ Message = (*NeighborHelloMessage)(nil)
var _ Message = (*NeighborHelloMessage)(nil)

@ -5,37 +5,36 @@
package lnwire
import (
"testing"
"bytes"
"testing"
"github.com/BitfuryLightning/tools/rt"
"github.com/BitfuryLightning/tools/rt/graph"
)
func TestNeighborHelloMessageEncodeDecode(t *testing.T){
func TestNeighborHelloMessageEncodeDecode(t *testing.T) {
Id1 := graph.NewID(1)
Id2 := graph.NewID(2)
rt1 := rt.NewRoutingTable()
rt1.AddChannel(Id1, Id2, graph.NewEdgeID("1"), &rt.ChannelInfo{1, 1})
b := new(bytes.Buffer)
msg1 := NeighborHelloMessage{RT:rt1}
msg1 := NeighborHelloMessage{RT: rt1}
err := msg1.Encode(b, 0)
if err != nil{
if err != nil {
t.Fatalf("Can't encode message ", err)
}
msg2 := new(NeighborHelloMessage)
err = msg2.Decode(b, 0)
if err != nil{
if err != nil {
t.Fatalf("Can't decode message ", err)
}
if msg2.RT == nil{
if msg2.RT == nil {
t.Fatal("After decoding RT should not be nil")
}
if !msg2.RT.HasChannel(Id1, Id2, nil){
if !msg2.RT.HasChannel(Id1, Id2, nil) {
t.Errorf("msg2.RT.HasChannel(Id1, Id2) = false, want true")
}
if !msg2.RT.HasChannel(Id2, Id1, nil){
if !msg2.RT.HasChannel(Id2, Id1, nil) {
t.Errorf("msg2.RT.HasChannel(Id2, Id1) = false, want true")
}
}

@ -3,6 +3,7 @@
// file LICENSE or http://www.opensource.org/licenses/mit-license.php
package lnwire
import (
"fmt"
"io"
@ -16,24 +17,24 @@ func (msg *NeighborRstMessage) String() string {
return fmt.Sprintf("NeighborRstMessage{%v %v}", msg.SenderID, msg.ReceiverID)
}
func (msg *NeighborRstMessage) Command() uint32{
func (msg *NeighborRstMessage) Command() uint32 {
return CmdNeighborRstMessage
}
func (msg *NeighborRstMessage) Encode(w io.Writer, pver uint32) error{
func (msg *NeighborRstMessage) Encode(w io.Writer, pver uint32) error {
return nil
}
func (msg *NeighborRstMessage) Decode(r io.Reader, pver uint32) error{
func (msg *NeighborRstMessage) Decode(r io.Reader, pver uint32) error {
return nil
}
func (msg *NeighborRstMessage) MaxPayloadLength(uint32) uint32{
func (msg *NeighborRstMessage) MaxPayloadLength(uint32) uint32 {
return 0
}
func (msg *NeighborRstMessage) Validate() error{
func (msg *NeighborRstMessage) Validate() error {
return nil
}
var _ Message = (*NeighborRstMessage)(nil)
var _ Message = (*NeighborRstMessage)(nil)

@ -5,10 +5,11 @@
package lnwire
import (
"fmt"
"github.com/BitfuryLightning/tools/rt"
"encoding/gob"
"fmt"
"io"
"github.com/BitfuryLightning/tools/rt"
)
type NeighborUpdMessage struct {
@ -16,7 +17,7 @@ type NeighborUpdMessage struct {
DiffBuff *rt.DifferenceBuffer
}
func (msg *NeighborUpdMessage) Decode(r io.Reader, pver uint32) error{
func (msg *NeighborUpdMessage) Decode(r io.Reader, pver uint32) error {
decoder := gob.NewDecoder(r)
diffBuff := new(rt.DifferenceBuffer)
err := decoder.Decode(diffBuff)
@ -24,22 +25,22 @@ func (msg *NeighborUpdMessage) Decode(r io.Reader, pver uint32) error{
return err
}
func (msg *NeighborUpdMessage) Encode(w io.Writer, pver uint32) error{
func (msg *NeighborUpdMessage) Encode(w io.Writer, pver uint32) error {
encoder := gob.NewEncoder(w)
err := encoder.Encode(msg.DiffBuff)
return err
}
func (msg *NeighborUpdMessage) Command() uint32{
func (msg *NeighborUpdMessage) Command() uint32 {
return CmdNeighborUpdMessage
}
func (msg *NeighborUpdMessage) MaxPayloadLength(uint32) uint32{
func (msg *NeighborUpdMessage) MaxPayloadLength(uint32) uint32 {
// TODO: Insert some estimations
return 1000000
}
func (msg *NeighborUpdMessage) Validate() error{
func (msg *NeighborUpdMessage) Validate() error {
// TODO: Add validation
return nil
}
@ -48,4 +49,4 @@ func (msg *NeighborUpdMessage) String() string {
return fmt.Sprintf("NeighborUpdMessage{%v %v %v}", msg.SenderID, msg.ReceiverID, *msg.DiffBuff)
}
var _ Message = (*NeighborUpdMessage)(nil)
var _ Message = (*NeighborUpdMessage)(nil)

@ -8,20 +8,27 @@ import (
"github.com/BitfuryLightning/tools/rt/graph"
)
// RoutingMessageBase is the base struct for all routing messages within the
// lnwire package.
type RoutingMessageBase struct {
// SenderID is the ID of the sender of the routing message.
SenderID graph.ID
// ReceiverID is the ID of the receiver of the routig message.
ReceiverID graph.ID
}
func (msg RoutingMessageBase) GetReceiverID() graph.ID{
// GetReceiverID returns the ID of the receiver of routing message.
func (msg RoutingMessageBase) GetReceiverID() graph.ID {
return msg.ReceiverID
}
func (msg RoutingMessageBase) GetSenderID() graph.ID{
// GetSenderID returns the ID of the sender of the routing message.
func (msg RoutingMessageBase) GetSenderID() graph.ID {
return msg.SenderID
}
// Interface for all routing messages. All messages have sender and receiver
// RoutingMessageBase is a shared interface for all routing messages.
type RoutingMessage interface {
GetSenderID() graph.ID
GetReceiverID() graph.ID

@ -3,6 +3,7 @@
// file LICENSE or http://www.opensource.org/licenses/mit-license.php
package lnwire
import (
"fmt"
"io"
@ -16,25 +17,24 @@ func (msg *RoutingTableRequestMessage) String() string {
return fmt.Sprintf("RoutingTableRequestMessage{%v %v}", msg.SenderID, msg.ReceiverID)
}
func (msg *RoutingTableRequestMessage) Command() uint32{
func (msg *RoutingTableRequestMessage) Command() uint32 {
return CmdRoutingTableRequestMessage
}
func (msg *RoutingTableRequestMessage) Encode(w io.Writer, pver uint32) error{
func (msg *RoutingTableRequestMessage) Encode(w io.Writer, pver uint32) error {
return nil
}
func (msg *RoutingTableRequestMessage) Decode(r io.Reader, pver uint32) error{
func (msg *RoutingTableRequestMessage) Decode(r io.Reader, pver uint32) error {
return nil
}
func (msg *RoutingTableRequestMessage) MaxPayloadLength(uint32) uint32{
func (msg *RoutingTableRequestMessage) MaxPayloadLength(uint32) uint32 {
return 0
}
func (msg *RoutingTableRequestMessage) Validate() error{
func (msg *RoutingTableRequestMessage) Validate() error {
return nil
}
var _ Message = (*RoutingTableRequestMessage)(nil)
var _ Message = (*RoutingTableRequestMessage)(nil)

@ -5,10 +5,11 @@
package lnwire
import (
"io"
"github.com/BitfuryLightning/tools/rt"
"encoding/gob"
"fmt"
"io"
"github.com/BitfuryLightning/tools/rt"
)
type RoutingTableTransferMessage struct {
@ -20,7 +21,7 @@ func (msg *RoutingTableTransferMessage) String() string {
return fmt.Sprintf("RoutingTableTransferMessage{%v %v %v}", msg.SenderID, msg.ReceiverID, msg.RT)
}
func (msg *RoutingTableTransferMessage) Decode(r io.Reader, pver uint32) error{
func (msg *RoutingTableTransferMessage) Decode(r io.Reader, pver uint32) error {
decoder := gob.NewDecoder(r)
rt1 := rt.NewRoutingTable()
err := decoder.Decode(rt1.G)
@ -28,24 +29,24 @@ func (msg *RoutingTableTransferMessage) Decode(r io.Reader, pver uint32) error{
return err
}
func (msg *RoutingTableTransferMessage) Encode(w io.Writer, pver uint32) error{
func (msg *RoutingTableTransferMessage) Encode(w io.Writer, pver uint32) error {
encoder := gob.NewEncoder(w)
err := encoder.Encode(msg.RT.G)
return err
}
func (msg *RoutingTableTransferMessage) Command() uint32{
func (msg *RoutingTableTransferMessage) Command() uint32 {
return CmdRoutingTableTransferMessage
}
func (msg *RoutingTableTransferMessage) MaxPayloadLength(uint32) uint32{
func (msg *RoutingTableTransferMessage) MaxPayloadLength(uint32) uint32 {
// TODO: Insert some estimations
return 1000000
}
func (msg *RoutingTableTransferMessage) Validate() error{
func (msg *RoutingTableTransferMessage) Validate() error {
// TODO: Add validation
return nil
}
var _ Message = (*RoutingTableTransferMessage)(nil)
var _ Message = (*RoutingTableTransferMessage)(nil)