mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-29 04:07:07 +00:00
re-arrange benchmark file
This commit is contained in:
@@ -26,45 +26,6 @@ var (
|
||||
genesisBlock, _ = benchmarkFullNode.LightBlock(context.Background(), 1)
|
||||
)
|
||||
|
||||
type providerBenchmarkImpl struct {
|
||||
chainID string
|
||||
currentHeight int64
|
||||
blocks map[int64]*types.LightBlock
|
||||
}
|
||||
|
||||
func newProviderBenchmarkImpl(chainID string, headers map[int64]*types.SignedHeader,
|
||||
vals map[int64]*types.ValidatorSet) provider.Provider {
|
||||
impl := providerBenchmarkImpl{
|
||||
chainID: chainID,
|
||||
blocks: make(map[int64]*types.LightBlock, len(headers)),
|
||||
}
|
||||
for height, header := range headers {
|
||||
if height > impl.currentHeight {
|
||||
impl.currentHeight = height
|
||||
}
|
||||
impl.blocks[height] = &types.LightBlock{
|
||||
SignedHeader: header,
|
||||
ValidatorSet: vals[height],
|
||||
}
|
||||
}
|
||||
return &impl
|
||||
}
|
||||
|
||||
func (impl *providerBenchmarkImpl) LightBlock(ctx context.Context, height int64) (*types.LightBlock, error) {
|
||||
if height == 0 {
|
||||
return impl.blocks[impl.currentHeight], nil
|
||||
}
|
||||
lb, ok := impl.blocks[height]
|
||||
if !ok {
|
||||
return nil, provider.ErrLightBlockNotFound
|
||||
}
|
||||
return lb, nil
|
||||
}
|
||||
|
||||
func (impl *providerBenchmarkImpl) ReportEvidence(_ context.Context, _ types.Evidence) error {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func BenchmarkSequence(b *testing.B) {
|
||||
c, err := light.NewClient(
|
||||
context.Background(),
|
||||
@@ -147,3 +108,42 @@ func BenchmarkBackwards(b *testing.B) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type providerBenchmarkImpl struct {
|
||||
chainID string
|
||||
currentHeight int64
|
||||
blocks map[int64]*types.LightBlock
|
||||
}
|
||||
|
||||
func newProviderBenchmarkImpl(chainID string, headers map[int64]*types.SignedHeader,
|
||||
vals map[int64]*types.ValidatorSet) provider.Provider {
|
||||
impl := providerBenchmarkImpl{
|
||||
chainID: chainID,
|
||||
blocks: make(map[int64]*types.LightBlock, len(headers)),
|
||||
}
|
||||
for height, header := range headers {
|
||||
if height > impl.currentHeight {
|
||||
impl.currentHeight = height
|
||||
}
|
||||
impl.blocks[height] = &types.LightBlock{
|
||||
SignedHeader: header,
|
||||
ValidatorSet: vals[height],
|
||||
}
|
||||
}
|
||||
return &impl
|
||||
}
|
||||
|
||||
func (impl *providerBenchmarkImpl) LightBlock(ctx context.Context, height int64) (*types.LightBlock, error) {
|
||||
if height == 0 {
|
||||
return impl.blocks[impl.currentHeight], nil
|
||||
}
|
||||
lb, ok := impl.blocks[height]
|
||||
if !ok {
|
||||
return nil, provider.ErrLightBlockNotFound
|
||||
}
|
||||
return lb, nil
|
||||
}
|
||||
|
||||
func (impl *providerBenchmarkImpl) ReportEvidence(_ context.Context, _ types.Evidence) error {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user