forked from lightningnetwork/lnd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
neighbor_hello.go
47 lines (36 loc) · 1.01 KB
/
neighbor_hello.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// 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"
"io"
"github.com/BitfuryLightning/tools/rt"
)
type NeighborHelloMessage struct {
RT *rt.RoutingTable
}
func (msg *NeighborHelloMessage) Decode(r io.Reader, pver uint32) error {
rt1, err := rt.UnmarshallRoutingTable(r)
msg.RT = rt1
return err
}
func (msg *NeighborHelloMessage) Encode(w io.Writer, pver uint32) error {
err := msg.RT.Marshall(w)
return err
}
func (msg *NeighborHelloMessage) Command() uint32 {
return CmdNeighborHelloMessage
}
func (msg *NeighborHelloMessage) MaxPayloadLength(uint32) uint32 {
// TODO: Insert some estimations
return 1000000
}
func (msg *NeighborHelloMessage) Validate() error {
// TODO: Add validation
return nil
}
func (msg *NeighborHelloMessage) String() string {
return fmt.Sprintf("NeighborHelloMessage{%v}", msg.RT)
}
var _ Message = (*NeighborHelloMessage)(nil)