-
Notifications
You must be signed in to change notification settings - Fork 670
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Interval tree syncing integration (#2855)
- Loading branch information
1 parent
9a0c852
commit 617a9e2
Showing
10 changed files
with
957 additions
and
1,254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package bootstrap | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/prometheus/client_golang/prometheus" | ||
|
||
"github.com/ava-labs/avalanchego/snow" | ||
"github.com/ava-labs/avalanchego/snow/consensus/snowman" | ||
"github.com/ava-labs/avalanchego/snow/engine/snowman/block" | ||
) | ||
|
||
var ( | ||
_ block.Parser = (*parseAcceptor)(nil) | ||
_ snowman.Block = (*blockAcceptor)(nil) | ||
) | ||
|
||
type parseAcceptor struct { | ||
parser block.Parser | ||
ctx *snow.ConsensusContext | ||
numAccepted prometheus.Counter | ||
} | ||
|
||
func (p *parseAcceptor) ParseBlock(ctx context.Context, bytes []byte) (snowman.Block, error) { | ||
blk, err := p.parser.ParseBlock(ctx, bytes) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &blockAcceptor{ | ||
Block: blk, | ||
ctx: p.ctx, | ||
numAccepted: p.numAccepted, | ||
}, nil | ||
} | ||
|
||
type blockAcceptor struct { | ||
snowman.Block | ||
|
||
ctx *snow.ConsensusContext | ||
numAccepted prometheus.Counter | ||
} | ||
|
||
func (b *blockAcceptor) Accept(ctx context.Context) error { | ||
if err := b.ctx.BlockAcceptor.Accept(b.ctx, b.ID(), b.Bytes()); err != nil { | ||
return err | ||
} | ||
err := b.Block.Accept(ctx) | ||
b.numAccepted.Inc() | ||
return err | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.