This repository was archived by the owner on Aug 2, 2021. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathmsg.go
More file actions
98 lines (79 loc) · 3.15 KB
/
Copy pathmsg.go
File metadata and controls
98 lines (79 loc) · 3.15 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// MsgID is a value that uniquely identifies a message,
// and its publisher. Nodes SHOULD assume that two messages
// with the same MessageID are the same, even if their payloads
// are not identical. (The burden is on the publishers to )
type MsgID []byte
// NewMsgID constructs a MsgID from given values. The format is:
// <varint-msgid-length><peer.ID-multihash><seqno>
func NewMsgID(publisher peer.ID, seqno []byte) MsgID {}
// Publisher returns the peer.ID of the author of this message.
// (it is a public key or a hash of a public key)
func (mid MsgID) Publisher() peer.ID {}
// SeqNo is a publisher-unique "sequence number" for this message.
// SeqNo need not be sequential (maybe rename this?), it only
// needs to be unique. It could be generated from an incrementing
// sequence number, a UUID4, a hash, a datetime + sequence number,
// etc. It is up to the publisher to enforce that SeqNo is unique
// for ever (local dates and uuid4s can work well). Receivers will keep a
// cache of undetermined length, so publishers which reuse SeqNos will
// perceive undefined behavior. (subscribers may supress or receive the
// message depending on the size of their caches, or their recency).
//
// Note that SeqNo is more useful than enforcing unique payloads, as
// the sender may wish to send identical payloads twice as two different
// messages, and these should not be supressed automatically.
func (mid MsgID) SeqNo() []byte {}
// Message is an ipld object.
// it carries a payload (an embedded ipld object)
//
// the format of this message is:
// ---
// # pubsub message
// id: <MsgID-value>
// t: [<Topic>, ...]
// p: <Payload>
type Message interface {
Publisher() peer.ID
// Valid checks the integrity of this message. Invalid messages
// (false) MUST be discarded. Valid checks the signature.
Valid() bool
// MsgID returns the unique value for this message.
// It is used to discard duplicates.
// Nodes SHOULD discard messages with the same MsgID().
MsgID() MsgID
// Publisher returns the publisher of this message.
Publisher() peer.ID
// Topics returns the topics this message is going to.
Topics() []Topic
// Payload returns an ipld.Object descriptor. This is the message
// published through pubsub.
// it may be the same memory as Message (i.e. an embedded buffer).
Payload() ipld.Object
}
// NewMessage constructs a message from given ipld.Object.
// object may be nil (in which case this allocates a new
// object).
func NewMessage(o ipld.Object) (Message, error) {
}
// SignedMessage is a signed Message.
// it carries a payload (an embedded ipld object)
//
// the format of this message is:
// ---
// # SignedMessage
// # wrapper object is a keychain.SignedObject
// key: <keychain.Key>
// sig: <keychain.Signature>
// p:
// # the pubsub message
// id: <MsgID-value>
// t: [<Topic>, ...]
// p: <Payload>
type SignedMessage interface {
Message
// Signature returns a cryptographic signature on this object.
// this signature must be derived from peer.ID. It does not
// need to be the same key, but needs to trace back to it.
// (i.e. keychain key derivation).
Signature() keychain.Signature
}