-
Notifications
You must be signed in to change notification settings - Fork 211
/
wire_types.go
95 lines (78 loc) · 2.14 KB
/
wire_types.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package fetch
import (
"github.com/spacemeshos/go-spacemesh/common/types"
"github.com/spacemeshos/go-spacemesh/datastore"
"github.com/spacemeshos/go-spacemesh/log"
"github.com/spacemeshos/go-spacemesh/p2p"
)
//go:generate scalegen
// RequestMessage is sent to the peer for hash query.
type RequestMessage struct {
Hint datastore.Hint
Hash types.Hash32
}
// ResponseMessage is sent to the node as a response.
type ResponseMessage struct {
Hash types.Hash32
Data []byte
}
// RequestBatch is a batch of requests and a hash of all requests as ID.
type RequestBatch struct {
ID types.Hash32
Requests []RequestMessage
}
// ResponseBatch is the response struct send for a RequestBatch. the ResponseBatch ID must be the same
// as stated in RequestBatch even if not all Data is present.
type ResponseBatch struct {
ID types.Hash32
Responses []ResponseMessage
}
type MeshHashRequest struct {
From, To types.LayerID
Delta, Steps uint32
}
func (r *MeshHashRequest) MarshalLogObject(encoder log.ObjectEncoder) error {
encoder.AddUint32("from", r.From.Uint32())
encoder.AddUint32("to", r.To.Uint32())
encoder.AddUint32("delta", r.Delta)
encoder.AddUint32("steps", r.Steps)
return nil
}
type MeshHashes struct {
Layers []types.LayerID
Hashes []types.Hash32
}
type MaliciousIDs struct {
NodeIDs []types.NodeID
}
type EpochData struct {
AtxIDs []types.ATXID
}
// LayerData is the data response for a given layer ID.
type LayerData struct {
Ballots []types.BallotID
Blocks []types.BlockID
}
// LayerOpinion is the response for opinion for a given layer.
type LayerOpinion struct {
PrevAggHash types.Hash32
Cert *types.Certificate
peer p2p.Peer
}
// SetPeer ...
func (lo *LayerOpinion) SetPeer(p p2p.Peer) {
lo.peer = p
}
// Peer ...
func (lo *LayerOpinion) Peer() p2p.Peer {
return lo.peer
}
// MarshalLogObject implements logging encoder for LayerOpinion.
func (lo *LayerOpinion) MarshalLogObject(encoder log.ObjectEncoder) error {
encoder.AddString("peer", lo.peer.String())
encoder.AddString("prev_hash", lo.PrevAggHash.String())
if lo.Cert != nil {
encoder.AddString("cert_block_id", lo.Cert.BlockID.String())
}
return nil
}