fix: use global []byte slice to avoid conversions in loop (#595)

Co-authored-by: Muggle-Du <adudu@CNMAC0342.local>
This commit is contained in:
Adu 2021-09-28 14:03:08 +08:00 committed by GitHub
parent bbb54a6d17
commit fdb92ee788
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}
}