2016-07-15 14:02:59 +03:00
|
|
|
// Copyright (c) 2016 Bitfury Group Limited
|
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file LICENSE or http://www.opensource.org/licenses/mit-license.php
|
|
|
|
|
|
|
|
package lnwire
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2016-08-11 21:54:44 +03:00
|
|
|
"io"
|
|
|
|
|
|
|
|
"github.com/BitfuryLightning/tools/rt"
|
2016-07-15 14:02:59 +03:00
|
|
|
)
|
|
|
|
|
2016-08-11 21:54:44 +03:00
|
|
|
type NeighborHelloMessage struct {
|
2016-07-15 14:02:59 +03:00
|
|
|
RT *rt.RoutingTable
|
|
|
|
}
|
|
|
|
|
2016-08-11 21:54:44 +03:00
|
|
|
func (msg *NeighborHelloMessage) Decode(r io.Reader, pver uint32) error {
|
2016-08-20 23:49:35 +03:00
|
|
|
rt1, err := rt.UnmarshallRoutingTable(r)
|
2016-07-15 14:02:59 +03:00
|
|
|
msg.RT = rt1
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2016-08-11 21:54:44 +03:00
|
|
|
func (msg *NeighborHelloMessage) Encode(w io.Writer, pver uint32) error {
|
2016-08-20 23:49:35 +03:00
|
|
|
err := msg.RT.Marshall(w)
|
2016-07-15 14:02:59 +03:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2016-08-11 21:54:44 +03:00
|
|
|
func (msg *NeighborHelloMessage) Command() uint32 {
|
2016-07-15 14:02:59 +03:00
|
|
|
return CmdNeighborHelloMessage
|
|
|
|
}
|
|
|
|
|
2016-08-11 21:54:44 +03:00
|
|
|
func (msg *NeighborHelloMessage) MaxPayloadLength(uint32) uint32 {
|
2016-07-15 14:02:59 +03:00
|
|
|
// TODO: Insert some estimations
|
|
|
|
return 1000000
|
|
|
|
}
|
|
|
|
|
2016-08-11 21:54:44 +03:00
|
|
|
func (msg *NeighborHelloMessage) Validate() error {
|
2016-07-15 14:02:59 +03:00
|
|
|
// TODO: Add validation
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-08-11 21:54:44 +03:00
|
|
|
func (msg *NeighborHelloMessage) String() string {
|
2016-08-23 22:41:41 +03:00
|
|
|
return fmt.Sprintf("NeighborHelloMessage{%v}", msg.RT)
|
2016-07-15 14:02:59 +03:00
|
|
|
}
|
|
|
|
|
2016-08-11 21:54:44 +03:00
|
|
|
var _ Message = (*NeighborHelloMessage)(nil)
|