From c3c4274d67df42687af60c10c0fc861f46ca0801 Mon Sep 17 00:00:00 2001 From: William Banfield Date: Wed, 21 Jul 2021 09:22:13 -0400 Subject: [PATCH] re-arrange benchmark file --- light/client_benchmark_test.go | 78 +++++++++++++++++----------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/light/client_benchmark_test.go b/light/client_benchmark_test.go index d0aa02cba..f70965ff2 100644 --- a/light/client_benchmark_test.go +++ b/light/client_benchmark_test.go @@ -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") +}