-
Notifications
You must be signed in to change notification settings - Fork 670
/
no_ops_handlers.go
205 lines (162 loc) · 6.87 KB
/
no_ops_handlers.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
// Copyright (C) 2019-2021, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package common
import (
"time"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/logging"
)
var (
_ StateSummaryFrontierHandler = &noOpStateSummaryFrontierHandler{}
_ AcceptedStateSummaryHandler = &noOpAcceptedStateSummaryHandler{}
_ AcceptedFrontierHandler = &noOpAcceptedFrontierHandler{}
_ AcceptedHandler = &noOpAcceptedHandler{}
_ AncestorsHandler = &noOpAncestorsHandler{}
_ PutHandler = &noOpPutHandler{}
_ QueryHandler = &noOpQueryHandler{}
_ ChitsHandler = &noOpChitsHandler{}
_ AppHandler = &noOpAppHandler{}
)
type noOpStateSummaryFrontierHandler struct {
log logging.Logger
}
func NewNoOpStateSummaryFrontierHandler(log logging.Logger) StateSummaryFrontierHandler {
return &noOpStateSummaryFrontierHandler{log: log}
}
func (nop *noOpStateSummaryFrontierHandler) StateSummaryFrontier(validatorID ids.NodeID, requestID uint32, summary []byte) error {
nop.log.Debug("StateSummaryFrontier(%s, %d) unhandled by this gear. Dropped.", validatorID, requestID)
return nil
}
func (nop *noOpStateSummaryFrontierHandler) GetStateSummaryFrontierFailed(validatorID ids.NodeID, requestID uint32) error {
nop.log.Debug("GetStateSummaryFrontierFailed(%s, %d) unhandled by this gear. Dropped.", validatorID, requestID)
return nil
}
type noOpAcceptedStateSummaryHandler struct {
log logging.Logger
}
func NewNoOpAcceptedStateSummaryHandler(log logging.Logger) AcceptedStateSummaryHandler {
return &noOpAcceptedStateSummaryHandler{log: log}
}
func (nop *noOpAcceptedStateSummaryHandler) AcceptedStateSummary(validatorID ids.NodeID, requestID uint32, summaryIDs []ids.ID) error {
nop.log.Debug("AcceptedStateSummary(%s, %d) unhandled by this gear. Dropped.", validatorID, requestID)
return nil
}
func (nop *noOpAcceptedStateSummaryHandler) GetAcceptedStateSummaryFailed(validatorID ids.NodeID, requestID uint32) error {
nop.log.Debug("GetAcceptedStateSummaryFailed(%s, %d) unhandled by this gear. Dropped.", validatorID, requestID)
return nil
}
type noOpAcceptedFrontierHandler struct {
log logging.Logger
}
func NewNoOpAcceptedFrontierHandler(log logging.Logger) AcceptedFrontierHandler {
return &noOpAcceptedFrontierHandler{log: log}
}
func (nop *noOpAcceptedFrontierHandler) AcceptedFrontier(validatorID ids.NodeID, requestID uint32, containerIDs []ids.ID) error {
nop.log.Debug("AcceptedFrontier(%s, %d) unhandled by this gear. Dropped.", validatorID, requestID)
return nil
}
func (nop *noOpAcceptedFrontierHandler) GetAcceptedFrontierFailed(validatorID ids.NodeID, requestID uint32) error {
nop.log.Debug("GetAcceptedFrontierFailed(%s, %d) unhandled by this gear. Dropped.", validatorID, requestID)
return nil
}
type noOpAcceptedHandler struct {
log logging.Logger
}
func NewNoOpAcceptedHandler(log logging.Logger) AcceptedHandler {
return &noOpAcceptedHandler{log: log}
}
func (nop *noOpAcceptedHandler) Accepted(validatorID ids.NodeID, requestID uint32, containerIDs []ids.ID) error {
nop.log.Debug("Accepted(%s, %d) unhandled by this gear. Dropped.", validatorID, requestID)
return nil
}
func (nop *noOpAcceptedHandler) GetAcceptedFailed(validatorID ids.NodeID, requestID uint32) error {
nop.log.Debug("GetAcceptedFailed(%s, %d) unhandled by this gear. Dropped.", validatorID, requestID)
return nil
}
type noOpAncestorsHandler struct {
log logging.Logger
}
func NewNoOpAncestorsHandler(log logging.Logger) AncestorsHandler {
return &noOpAncestorsHandler{log: log}
}
func (nop *noOpAncestorsHandler) Ancestors(validatorID ids.NodeID, requestID uint32, containers [][]byte) error {
nop.log.Debug("Ancestors(%s, %d) unhandled by this gear. Dropped.", validatorID, requestID)
return nil
}
func (nop *noOpAncestorsHandler) GetAncestorsFailed(validatorID ids.NodeID, requestID uint32) error {
nop.log.Debug("GetAncestorsFailed(%s, %d) unhandled by this gear. Dropped.", validatorID, requestID)
return nil
}
type noOpPutHandler struct {
log logging.Logger
}
func NewNoOpPutHandler(log logging.Logger) PutHandler {
return &noOpPutHandler{log: log}
}
func (nop *noOpPutHandler) Put(vdr ids.NodeID, requestID uint32, blkBytes []byte) error {
if requestID == constants.GossipMsgRequestID {
nop.log.Verbo("Gossip Put(%s, %d) unhandled by this gear. Dropped.", vdr, requestID)
} else {
nop.log.Debug("Put(%s, %d) unhandled by this gear. Dropped.", vdr, requestID)
}
return nil
}
func (nop *noOpPutHandler) GetFailed(validatorID ids.NodeID, requestID uint32) error {
nop.log.Debug("GetFailed(%s, %d) unhandled by this gear. Dropped.", validatorID, requestID)
return nil
}
type noOpQueryHandler struct {
log logging.Logger
}
func NewNoOpQueryHandler(log logging.Logger) QueryHandler {
return &noOpQueryHandler{log: log}
}
func (nop *noOpQueryHandler) PullQuery(vdr ids.NodeID, requestID uint32, blkID ids.ID) error {
nop.log.Debug("PullQuery(%s, %d, %s) unhandled by this gear. Dropped.", vdr, requestID, blkID)
return nil
}
func (nop *noOpQueryHandler) PushQuery(vdr ids.NodeID, requestID uint32, blkBytes []byte) error {
nop.log.Debug("PushQuery(%s, %d) unhandled by this gear. Dropped.", vdr, requestID)
return nil
}
type noOpChitsHandler struct {
log logging.Logger
}
func NewNoOpChitsHandler(log logging.Logger) ChitsHandler {
return &noOpChitsHandler{log: log}
}
func (nop *noOpChitsHandler) Chits(vdr ids.NodeID, requestID uint32, _ []ids.ID) error {
nop.log.Debug("Chits(%s, %d) unhandled by this gear. Dropped.", vdr, requestID)
return nil
}
func (nop *noOpChitsHandler) ChitsV2(vdr ids.NodeID, requestID uint32, _ []ids.ID, _ ids.ID) error {
nop.log.Debug("ChitsV2(%s, %d) unhandled by this gear. Dropped.", vdr, requestID)
return nil
}
func (nop *noOpChitsHandler) QueryFailed(vdr ids.NodeID, requestID uint32) error {
nop.log.Debug("QueryFailed(%s, %d) unhandled by this gear. Dropped.", vdr, requestID)
return nil
}
type noOpAppHandler struct {
log logging.Logger
}
func NewNoOpAppHandler(log logging.Logger) AppHandler {
return &noOpAppHandler{log: log}
}
func (nop *noOpAppHandler) AppRequest(nodeID ids.NodeID, requestID uint32, deadline time.Time, request []byte) error {
nop.log.Debug("AppRequest(%s, %d) unhandled by this gear. Dropped.", nodeID, requestID)
return nil
}
func (nop *noOpAppHandler) AppRequestFailed(nodeID ids.NodeID, requestID uint32) error {
nop.log.Debug("AppRequestFailed(%s, %d) unhandled by this gear. Dropped.", nodeID, requestID)
return nil
}
func (nop *noOpAppHandler) AppResponse(nodeID ids.NodeID, requestID uint32, response []byte) error {
nop.log.Debug("AppResponse(%s, %d) unhandled by this gear. Dropped.", nodeID, requestID)
return nil
}
func (nop *noOpAppHandler) AppGossip(nodeID ids.NodeID, msg []byte) error {
nop.log.Debug("AppGossip(%s) unhandled by this gear. Dropped.", nodeID)
return nil
}