Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

refactor: using slices.Contains to simplify the code #2532

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions core/rawdb/accessors_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"encoding/binary"
"fmt"
"math/big"
"slices"
"sort"

"github.com/dominant-strategies/go-quai/common"
Expand Down Expand Up @@ -739,12 +740,7 @@ func DeleteReceipts(db ethdb.KeyValueWriter, hash common.Hash, number uint64) {

func IsGenesisHash(db ethdb.Reader, hash common.Hash) bool {
genesisHashes := ReadGenesisHashes(db)
for _, genesisHash := range genesisHashes {
if hash == genesisHash {
return true
}
}
return false
return slices.Contains(genesisHashes, hash)
}

// FindCommonAncestor returns the last common ancestor of two block headers
Expand Down
8 changes: 2 additions & 6 deletions quai/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"bytes"
"fmt"
"math/big"
"slices"
"sync"
"time"

Expand Down Expand Up @@ -353,12 +354,7 @@ func (s *Quai) isLocalBlock(header *types.WorkObject) bool {
}
// Check whether the given address is specified by `txpool.local`
// CLI flag.
for _, account := range s.config.TxPool.Locals {
if account == internal {
return true
}
}
return false
return slices.Contains(s.config.TxPool.Locals, internal)
}

// shouldPreserve checks whether we should preserve the given block
Expand Down
Loading