-
Notifications
You must be signed in to change notification settings - Fork 200
/
message.go
71 lines (58 loc) · 1.63 KB
/
message.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package message
import (
"github.com/ElrondNetwork/elrond-go/core"
"github.com/ElrondNetwork/elrond-go/p2p"
)
var _ p2p.MessageP2P = (*Message)(nil)
// Message is a data holder struct
type Message struct {
FromField []byte
DataField []byte
PayloadField []byte
SeqNoField []byte
TopicField string
SignatureField []byte
KeyField []byte
PeerField core.PeerID
TimestampField int64
}
// From returns the message originator's peer ID
func (m *Message) From() []byte {
return m.FromField
}
// Data returns the useful message that was actually sent
func (m *Message) Data() []byte {
return m.DataField
}
// Payload returns the encapsulated message along with meta data such as timestamp
func (m *Message) Payload() []byte {
return m.PayloadField
}
// SeqNo returns the message sequence number
func (m *Message) SeqNo() []byte {
return m.SeqNoField
}
// Topic returns the topic on which the message was sent
func (m *Message) Topic() string {
return m.TopicField
}
// Signature returns the message signature
func (m *Message) Signature() []byte {
return m.SignatureField
}
// Key returns the message public key (if it can not be recovered from From field)
func (m *Message) Key() []byte {
return m.KeyField
}
// Peer returns the peer that originated the message
func (m *Message) Peer() core.PeerID {
return m.PeerField
}
// Timestamp returns the message timestamp to prevent endless re-processing of the same message
func (m *Message) Timestamp() int64 {
return m.TimestampField
}
// IsInterfaceNil returns true if there is no value under the interface
func (m *Message) IsInterfaceNil() bool {
return m == nil
}