Skip to content

Commit

Permalink
Replace bytes.Equal(...) with bytes.HasPrefix(...) (#2305)
Browse files Browse the repository at this point in the history
  • Loading branch information
kirugan authored Dec 5, 2024
1 parent ec24744 commit 2a82a59
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ func TransactionsByBlockNumber(txn db.Transaction, number uint64) ([]core.Transa

prefix := db.TransactionsByBlockNumberAndIndex.Key(numBytes)
for iterator.Seek(prefix); iterator.Valid(); iterator.Next() {
if !bytes.Equal(iterator.Key()[:len(prefix)], prefix) {
if !bytes.HasPrefix(iterator.Key(), prefix) {
break
}

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

prefix := db.ReceiptsByBlockNumberAndIndex.Key(numBytes)
for iterator.Seek(prefix); iterator.Valid(); iterator.Next() {
if !bytes.Equal(iterator.Key()[:len(prefix)], prefix) {
if !bytes.HasPrefix(iterator.Key(), prefix) {
break
}

Expand Down
2 changes: 1 addition & 1 deletion migration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func relocateContractStorageRootKeys(txn db.Transaction, _ *utils.Network) error
var value []byte
for it.Seek(oldPrefix); it.Valid(); it.Next() {
// Stop iterating once we're out of the old bucket.
if !bytes.Equal(it.Key()[:len(oldPrefix)], oldPrefix) {
if !bytes.HasPrefix(it.Key(), oldPrefix) {
break
}

Expand Down

0 comments on commit 2a82a59

Please sign in to comment.