From fdb92ee788160a2bb9c7a8613d3dd1c5f2e0636e Mon Sep 17 00:00:00 2001 From: Adu Date: Tue, 28 Sep 2021 14:03:08 +0800 Subject: [PATCH] fix: use global []byte slice to avoid conversions in loop (#595) Co-authored-by: Muggle-Du --- ethereum/rpc/backend/backend.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ethereum/rpc/backend/backend.go b/ethereum/rpc/backend/backend.go index 871e4772..6c1ffea1 100644 --- a/ethereum/rpc/backend/backend.go +++ b/ethereum/rpc/backend/backend.go @@ -67,6 +67,8 @@ type Backend interface { var _ Backend = (*EVMBackend)(nil) +var bAttributeKeyEthereumBloom = []byte(evmtypes.AttributeKeyEthereumBloom) + // EVMBackend implements the Backend interface type EVMBackend struct { ctx context.Context @@ -205,7 +207,7 @@ func (e *EVMBackend) BlockBloom(height *int64) (ethtypes.Bloom, error) { } for _, attr := range event.Attributes { - if bytes.Equal(attr.Key, []byte(evmtypes.AttributeKeyEthereumBloom)) { + if bytes.Equal(attr.Key, bAttributeKeyEthereumBloom) { return ethtypes.BytesToBloom(attr.Value), nil } }