aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2017-01-06 23:44:20 +0800
committerFelix Lange <fjl@twurst.com>2017-01-07 01:18:07 +0800
commitf2da6581ba827a2aab091f764ace8017b26450d8 (patch)
tree3bf7ed2ec48812064c5eb6191c9848ad7985561b /core
parent35a7dcb162546f7f31cb6492f716cb93159218d7 (diff)
downloadgo-tangerine-f2da6581ba827a2aab091f764ace8017b26450d8.tar
go-tangerine-f2da6581ba827a2aab091f764ace8017b26450d8.tar.gz
go-tangerine-f2da6581ba827a2aab091f764ace8017b26450d8.tar.bz2
go-tangerine-f2da6581ba827a2aab091f764ace8017b26450d8.tar.lz
go-tangerine-f2da6581ba827a2aab091f764ace8017b26450d8.tar.xz
go-tangerine-f2da6581ba827a2aab091f764ace8017b26450d8.tar.zst
go-tangerine-f2da6581ba827a2aab091f764ace8017b26450d8.zip
all: fix issues reported by honnef.co/go/simple/cmd/gosimple
Diffstat (limited to 'core')
-rw-r--r--core/blockchain.go5
-rw-r--r--core/dao.go4
-rw-r--r--core/database_util_test.go4
-rw-r--r--core/state/iterator.go2
-rw-r--r--core/state/sync_test.go4
-rw-r--r--core/types/bloom9.go8
6 files changed, 9 insertions, 18 deletions
diff --git a/core/blockchain.go b/core/blockchain.go
index 3c9e1f7cb..8c2be7231 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -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.
diff --git a/core/dao.go b/core/dao.go
index 1260c310a..a7f544c3d 100644
--- a/core/dao.go
+++ b/core/dao.go
@@ -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)
}
}
diff --git a/core/database_util_test.go b/core/database_util_test.go
index c8fd857ea..d96aa71ba 100644
--- a/core/database_util_test.go
+++ b/core/database_util_test.go
@@ -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])
}
}
diff --git a/core/state/iterator.go b/core/state/iterator.go
index 14265b277..a58a15ad3 100644
--- a/core/state/iterator.go
+++ b/core/state/iterator.go
@@ -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 {
diff --git a/core/state/sync_test.go b/core/state/sync_test.go
index cb585f78c..43d146e3a 100644
--- a/core/state/sync_test.go
+++ b/core/state/sync_test.go
@@ -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
}
diff --git a/core/types/bloom9.go b/core/types/bloom9.go
index bcca59907..32aa47a41 100644
--- a/core/types/bloom9.go
+++ b/core/types/bloom9.go
@@ -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[:]))
}
}