Skip to content

Commit 0ac260a

Browse files
committed
nits
1 parent 90ac2f6 commit 0ac260a

File tree

8 files changed

+98
-109
lines changed

8 files changed

+98
-109
lines changed

proto/p2p/p2p.proto

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,6 @@ enum EngineType {
217217
// Only the X-Chain uses avalanche consensus
218218
ENGINE_TYPE_AVALANCHE = 1;
219219
ENGINE_TYPE_SNOWMAN = 2;
220-
// For simplex consensus
221-
ENGINE_TYPE_SIMPLEX = 3;
222220
}
223221

224222
// GetAcceptedFrontier requests the accepted frontier from a peer.
@@ -463,7 +461,6 @@ message ProtocolMetadata {
463461

464462
message BlockHeader {
465463
ProtocolMetadata metadata = 1;
466-
467464
// digest is the short representation of the inner block's bytes
468465
bytes digest = 2;
469466
}

proto/pb/p2p/p2p.pb.go

Lines changed: 5 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

simplex/bls.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var (
1313
errSignatureVerificationFailed = fmt.Errorf("signature verification failed")
1414
)
1515

16-
type SignFunc func(msg []byte) (*bls.Signature, error)
16+
type SignFunc func(msg []byte) (*bls.Signature, error)
1717

1818
// BLSSigner signs messages encoded with the provided ChainID and NetworkID
1919
// using the SignBLS function.

simplex/bls_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ func newTestValidatorInfo(nodeIds []ids.NodeID, pks []*bls.PublicKey) *testValid
4949

5050
vds := make(map[ids.NodeID]validators.Validator, len(pks))
5151
for i, pk := range pks {
52-
5352
validator := validators.Validator{
5453
PublicKey: pk,
5554
NodeID: nodeIds[i],
@@ -63,17 +62,17 @@ func newTestValidatorInfo(nodeIds []ids.NodeID, pks []*bls.PublicKey) *testValid
6362
}
6463

6564
func newEngineConfig(ls *localsigner.LocalSigner) *Config {
66-
nodeId := ids.GenerateTestNodeID()
65+
nodeID := ids.GenerateTestNodeID()
6766

6867
SimplexChainContext := SimplexChainContext{
69-
NodeID: nodeId,
68+
NodeID: nodeID,
7069
ChainID: ids.GenerateTestID(),
7170
SubnetID: ids.GenerateTestID(),
7271
}
7372

7473
return &Config{
7574
Ctx: SimplexChainContext,
76-
Validators: newTestValidatorInfo([]ids.NodeID{nodeId}, []*bls.PublicKey{ls.PublicKey()}),
75+
Validators: newTestValidatorInfo([]ids.NodeID{nodeID}, []*bls.PublicKey{ls.PublicKey()}),
7776
SignBLS: ls.Sign,
7877
}
7978
}

simplex/config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ type ValidatorInfo interface {
1616

1717
// Config wraps all the parameters needed for a simplex engine
1818
type Config struct {
19-
Ctx SimplexChainContext
20-
Log logging.Logger
21-
Validators ValidatorInfo
22-
SignBLS SignFunc
19+
Ctx SimplexChainContext
20+
Log logging.Logger
21+
Validators ValidatorInfo
22+
SignBLS SignFunc
2323
}
2424

2525
// Context is information about the current execution.

snow/consensus/snowball/tree.go

Lines changed: 84 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ func (u *unaryNode) DecidedPrefix() int {
175175
return u.decidedPrefix
176176
}
177177

178+
//nolint:gci,gofmt,gofumpt // this comment is formatted as intended
179+
//
178180
// This is by far the most complicated function in this algorithm.
179181
// The intuition is that this instance represents a series of consecutive unary
180182
// snowball instances, and this function's purpose is convert one of these unary
@@ -186,23 +188,23 @@ func (u *unaryNode) DecidedPrefix() int {
186188
//
187189
// For example, attempting to insert the value "00001" in this node:
188190
//
189-
// +-------------------+ <-- This node will not be split
190-
// | |
191-
// | 0 0 0 |
192-
// | |
193-
// +-------------------+ <-- Pass the add to the child
194-
// ^
195-
// |
191+
// +-------------------+ <-- This node will not be split
192+
// | |
193+
// | 0 0 0 |
194+
// | |
195+
// +-------------------+ <-- Pass the add to the child
196+
// ^
197+
// |
196198
//
197199
// Results in:
198200
//
199-
// +-------------------+
200-
// | |
201-
// | 0 0 0 |
202-
// | |
203-
// +-------------------+ <-- With the modified child
204-
// ^
205-
// |
201+
// +-------------------+
202+
// | |
203+
// | 0 0 0 |
204+
// | |
205+
// +-------------------+ <-- With the modified child
206+
// ^
207+
// |
206208
//
207209
// 2. This instance represents a series of only one unary instance and it must
208210
// be split.
@@ -213,19 +215,19 @@ func (u *unaryNode) DecidedPrefix() int {
213215
//
214216
// For example, attempting to insert the value "1" in this tree:
215217
//
216-
// +-------------------+
217-
// | |
218-
// | 0 |
219-
// | |
220-
// +-------------------+
218+
// +-------------------+
219+
// | |
220+
// | 0 |
221+
// | |
222+
// +-------------------+
221223
//
222224
// Results in:
223225
//
224-
// +-------------------+
225-
// | | |
226-
// | 0 | 1 |
227-
// | | |
228-
// +-------------------+
226+
// +-------------------+
227+
// | | |
228+
// | 0 | 1 |
229+
// | | |
230+
// +-------------------+
229231
//
230232
// 3. This instance must be split on the first bit
231233
//
@@ -235,26 +237,26 @@ func (u *unaryNode) DecidedPrefix() int {
235237
//
236238
// For example, attempting to insert the value "10" in this tree:
237239
//
238-
// +-------------------+
239-
// | |
240-
// | 0 0 |
241-
// | |
242-
// +-------------------+
240+
// +-------------------+
241+
// | |
242+
// | 0 0 |
243+
// | |
244+
// +-------------------+
243245
//
244246
// Results in:
245247
//
246-
// +-------------------+
247-
// | | |
248-
// | 0 | 1 |
249-
// | | |
250-
// +-------------------+
251-
// ^ ^
252-
// / \
253-
// +-------------------+ +-------------------+
254-
// | | | |
255-
// | 0 | | 0 |
256-
// | | | |
257-
// +-------------------+ +-------------------+
248+
// +-------------------+
249+
// | | |
250+
// | 0 | 1 |
251+
// | | |
252+
// +-------------------+
253+
// ^ ^
254+
// / \
255+
// +-------------------+ +-------------------+
256+
// | | | |
257+
// | 0 | | 0 |
258+
// | | | |
259+
// +-------------------+ +-------------------+
258260
//
259261
// 4. This instance must be split on the last bit
260262
//
@@ -265,26 +267,26 @@ func (u *unaryNode) DecidedPrefix() int {
265267
//
266268
// For example, attempting to insert the value "01" in this tree:
267269
//
268-
// +-------------------+
269-
// | |
270-
// | 0 0 |
271-
// | |
272-
// +-------------------+
270+
// +-------------------+
271+
// | |
272+
// | 0 0 |
273+
// | |
274+
// +-------------------+
273275
//
274276
// Results in:
275277
//
276-
// +-------------------+
277-
// | |
278-
// | 0 |
279-
// | |
280-
// +-------------------+
281-
// ^
282-
// |
283-
// +-------------------+
284-
// | | |
285-
// | 0 | 1 |
286-
// | | |
287-
// +-------------------+
278+
// +-------------------+
279+
// | |
280+
// | 0 |
281+
// | |
282+
// +-------------------+
283+
// ^
284+
// |
285+
// +-------------------+
286+
// | | |
287+
// | 0 | 1 |
288+
// | | |
289+
// +-------------------+
288290
//
289291
// 5. This instance must be split on an interior bit
290292
//
@@ -296,35 +298,33 @@ func (u *unaryNode) DecidedPrefix() int {
296298
//
297299
// For example, attempting to insert the value "010" in this tree:
298300
//
299-
// +-------------------+
300-
// | |
301-
// | 0 0 0 |
302-
// | |
303-
// +-------------------+
301+
// +-------------------+
302+
// | |
303+
// | 0 0 0 |
304+
// | |
305+
// +-------------------+
304306
//
305307
// Results in:
306308
//
307-
// +-------------------+
308-
// | |
309-
// | 0 |
310-
// | |
311-
// +-------------------+
312-
// ^
313-
// |
314-
// +-------------------+
315-
// | | |
316-
// | 0 | 1 |
317-
// | | |
318-
// +-------------------+
319-
// ^ ^
320-
// / \
321-
// +-------------------+ +-------------------+
322-
// | | | |
323-
// | 0 | | 0 |
324-
// | | | |
325-
// +-------------------+ +-------------------+
326-
//
327-
//nolint:gci,gofmt,gofumpt // this comment is formatted as intended
309+
// +-------------------+
310+
// | |
311+
// | 0 |
312+
// | |
313+
// +-------------------+
314+
// ^
315+
// |
316+
// +-------------------+
317+
// | | |
318+
// | 0 | 1 |
319+
// | | |
320+
// +-------------------+
321+
// ^ ^
322+
// / \
323+
// +-------------------+ +-------------------+
324+
// | | | |
325+
// | 0 | | 0 |
326+
// | | | |
327+
// +-------------------+ +-------------------+
328328
func (u *unaryNode) Add(newChoice ids.ID) node {
329329
if u.Finalized() {
330330
return u // Only happens if the tree is finalized, or it's a leaf node

snow/networking/handler/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ func (h *handler) handleSyncMsg(ctx context.Context, msg Message) error {
485485

486486
var engineType p2ppb.EngineType
487487
switch msg.EngineType {
488-
case p2ppb.EngineType_ENGINE_TYPE_AVALANCHE, p2ppb.EngineType_ENGINE_TYPE_SNOWMAN, p2ppb.EngineType_ENGINE_TYPE_SIMPLEX:
488+
case p2ppb.EngineType_ENGINE_TYPE_AVALANCHE, p2ppb.EngineType_ENGINE_TYPE_SNOWMAN:
489489
// The peer is requesting an engine type that has been initialized, so
490490
// we should attempt to honor the request.
491491
engineType = msg.EngineType

snow/networking/router/chain_router.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ func (cr *ChainRouter) HandleInbound(ctx context.Context, msg message.InboundMes
208208
op := msg.Op()
209209

210210
m := msg.Message()
211-
212211
chainID, err := message.GetChainID(m)
213212
if err != nil {
214213
cr.log.Debug("dropping message with invalid field",

0 commit comments

Comments
 (0)