all: fix issues reported by honnef.co/go/simple/cmd/gosimple
This commit is contained in:
@ -402,10 +402,7 @@ func (bc *BlockChain) ResetWithGenesisBlock(genesis *types.Block) {
|
||||
|
||||
// Export writes the active chain to the given writer.
|
||||
func (self *BlockChain) Export(w io.Writer) error {
|
||||
if err := self.ExportN(w, uint64(0), self.currentBlock.NumberU64()); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return self.ExportN(w, uint64(0), self.currentBlock.NumberU64())
|
||||
}
|
||||
|
||||
// ExportN writes a subset of the active chain to the given writer.
|
||||
|
@ -45,11 +45,11 @@ func ValidateDAOHeaderExtraData(config *params.ChainConfig, header *types.Header
|
||||
}
|
||||
// Depending whether we support or oppose the fork, validate the extra-data contents
|
||||
if config.DAOForkSupport {
|
||||
if bytes.Compare(header.Extra, params.DAOForkBlockExtra) != 0 {
|
||||
if !bytes.Equal(header.Extra, params.DAOForkBlockExtra) {
|
||||
return ValidationError("DAO pro-fork bad block extra-data: 0x%x", header.Extra)
|
||||
}
|
||||
} else {
|
||||
if bytes.Compare(header.Extra, params.DAOForkBlockExtra) == 0 {
|
||||
if bytes.Equal(header.Extra, params.DAOForkBlockExtra) {
|
||||
return ValidationError("DAO no-fork bad block extra-data: 0x%x", header.Extra)
|
||||
}
|
||||
}
|
||||
|
@ -430,7 +430,7 @@ func TestReceiptStorage(t *testing.T) {
|
||||
rlpHave, _ := rlp.EncodeToBytes(r)
|
||||
rlpWant, _ := rlp.EncodeToBytes(receipt)
|
||||
|
||||
if bytes.Compare(rlpHave, rlpWant) != 0 {
|
||||
if !bytes.Equal(rlpHave, rlpWant) {
|
||||
t.Fatalf("receipt #%d [%x]: receipt mismatch: have %v, want %v", i, receipt.TxHash, r, receipt)
|
||||
}
|
||||
}
|
||||
@ -488,7 +488,7 @@ func TestBlockReceiptStorage(t *testing.T) {
|
||||
rlpHave, _ := rlp.EncodeToBytes(rs[i])
|
||||
rlpWant, _ := rlp.EncodeToBytes(receipts[i])
|
||||
|
||||
if bytes.Compare(rlpHave, rlpWant) != 0 {
|
||||
if !bytes.Equal(rlpHave, rlpWant) {
|
||||
t.Fatalf("receipt #%d: receipt mismatch: have %v, want %v", i, rs[i], receipts[i])
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ func (it *NodeIterator) step() error {
|
||||
if !it.dataIt.Next() {
|
||||
it.dataIt = nil
|
||||
}
|
||||
if bytes.Compare(account.CodeHash, emptyCodeHash) != 0 {
|
||||
if !bytes.Equal(account.CodeHash, emptyCodeHash) {
|
||||
it.codeHash = common.BytesToHash(account.CodeHash)
|
||||
it.code, err = it.state.db.Get(account.CodeHash)
|
||||
if err != nil {
|
||||
|
@ -84,7 +84,7 @@ func checkStateAccounts(t *testing.T, db ethdb.Database, root common.Hash, accou
|
||||
if nonce := state.GetNonce(acc.address); nonce != acc.nonce {
|
||||
t.Errorf("account %d: nonce mismatch: have %v, want %v", i, nonce, acc.nonce)
|
||||
}
|
||||
if code := state.GetCode(acc.address); bytes.Compare(code, acc.code) != 0 {
|
||||
if code := state.GetCode(acc.address); !bytes.Equal(code, acc.code) {
|
||||
t.Errorf("account %d: code mismatch: have %x, want %x", i, code, acc.code)
|
||||
}
|
||||
}
|
||||
@ -294,7 +294,7 @@ func TestIncompleteStateSync(t *testing.T) {
|
||||
// Skim through the accounts and make sure the root hash is not a code node
|
||||
codeHash := false
|
||||
for _, acc := range srcAccounts {
|
||||
if bytes.Compare(root.Bytes(), crypto.Sha3(acc.code)) == 0 {
|
||||
if root == crypto.Keccak256Hash(acc.code) {
|
||||
codeHash = true
|
||||
break
|
||||
}
|
||||
|
@ -97,14 +97,8 @@ func CreateBloom(receipts Receipts) Bloom {
|
||||
func LogsBloom(logs []*Log) *big.Int {
|
||||
bin := new(big.Int)
|
||||
for _, log := range logs {
|
||||
data := make([]common.Hash, len(log.Topics))
|
||||
bin.Or(bin, bloom9(log.Address.Bytes()))
|
||||
|
||||
for i, topic := range log.Topics {
|
||||
data[i] = topic
|
||||
}
|
||||
|
||||
for _, b := range data {
|
||||
for _, b := range log.Topics {
|
||||
bin.Or(bin, bloom9(b[:]))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user