Skip to content

Commit 2a82a59

Browse files
authored
Replace bytes.Equal(...) with bytes.HasPrefix(...) (#2305)
1 parent ec24744 commit 2a82a59

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

blockchain/blockchain.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ func TransactionsByBlockNumber(txn db.Transaction, number uint64) ([]core.Transa
546546

547547
prefix := db.TransactionsByBlockNumberAndIndex.Key(numBytes)
548548
for iterator.Seek(prefix); iterator.Valid(); iterator.Next() {
549-
if !bytes.Equal(iterator.Key()[:len(prefix)], prefix) {
549+
if !bytes.HasPrefix(iterator.Key(), prefix) {
550550
break
551551
}
552552

@@ -581,7 +581,7 @@ func receiptsByBlockNumber(txn db.Transaction, number uint64) ([]*core.Transacti
581581

582582
prefix := db.ReceiptsByBlockNumberAndIndex.Key(numBytes)
583583
for iterator.Seek(prefix); iterator.Valid(); iterator.Next() {
584-
if !bytes.Equal(iterator.Key()[:len(prefix)], prefix) {
584+
if !bytes.HasPrefix(iterator.Key(), prefix) {
585585
break
586586
}
587587

migration/migration.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func relocateContractStorageRootKeys(txn db.Transaction, _ *utils.Network) error
217217
var value []byte
218218
for it.Seek(oldPrefix); it.Valid(); it.Next() {
219219
// Stop iterating once we're out of the old bucket.
220-
if !bytes.Equal(it.Key()[:len(oldPrefix)], oldPrefix) {
220+
if !bytes.HasPrefix(it.Key(), oldPrefix) {
221221
break
222222
}
223223

0 commit comments

Comments
 (0)