forked from lightningnetwork/lnd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
neighbor_ack.go
53 lines (42 loc) · 1.25 KB
/
neighbor_ack.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
48
49
50
51
52
53
// 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"
"bytes"
)
type NeighborAckMessage struct {
}
func (msg *NeighborAckMessage) String() string {
return fmt.Sprintf("NeighborAckMessage{}",)
}
func (msg *NeighborAckMessage) Command() uint32 {
return CmdNeighborAckMessage
}
func (msg *NeighborAckMessage) Encode(w io.Writer, pver uint32) error {
// Transmission function work incorrect with empty messages so write some random string to make message not empty
w.Write([]byte("NeighborAckMessage"))
return nil
}
func (msg *NeighborAckMessage) Decode(r io.Reader, pver uint32) error {
buff := make([]byte, 18)
_, err := r.Read(buff)
if err != nil {
return err
}
if !bytes.Equal(buff, []byte("NeighborAckMessage")) {
fmt.Errorf("Can't decode NeighborAckMessage message")
}
return nil
}
func (msg *NeighborAckMessage) MaxPayloadLength(uint32) uint32 {
// Length of the string "NeighborAckMessage" used in Encode
// Transmission functions work bad if it is 0
return 18
}
func (msg *NeighborAckMessage) Validate() error {
return nil
}
var _ Message = (*NeighborAckMessage)(nil)