eth: minor polishes on error capitalization

This commit is contained in:
Péter Szilágyi 2017-11-20 16:22:30 +02:00
parent c0108a45aa
commit 98b8134d68
No known key found for this signature in database
GPG key ID: E9AE538CEDF8293D

View file

@ -640,67 +640,67 @@ func storageRangeAt(st state.Trie, start []byte, maxResult int) StorageRangeResu
// GetModifiedAccountsByumber returns all accounts that have changed between the // GetModifiedAccountsByumber returns all accounts that have changed between the
// two blocks specified. A change is defined as a difference in nonce, balance, // two blocks specified. A change is defined as a difference in nonce, balance,
// code hash, or storage hash. // code hash, or storage hash.
//
// With one parameter, returns the list of accounts modified in the specified block. // With one parameter, returns the list of accounts modified in the specified block.
func (api *PrivateDebugAPI) GetModifiedAccountsByNumber(startNum uint64, endNum *uint64) ([]common.Address, error) { func (api *PrivateDebugAPI) GetModifiedAccountsByNumber(startNum uint64, endNum *uint64) ([]common.Address, error) {
var startBlock, endBlock *types.Block var startBlock, endBlock *types.Block
startBlock = api.eth.blockchain.GetBlockByNumber(startNum) startBlock = api.eth.blockchain.GetBlockByNumber(startNum)
if startBlock == nil { if startBlock == nil {
return nil, fmt.Errorf("Start block %x not found", startNum) return nil, fmt.Errorf("start block %x not found", startNum)
} }
if endNum == nil { if endNum == nil {
endBlock = startBlock endBlock = startBlock
startBlock = api.eth.blockchain.GetBlockByHash(startBlock.ParentHash()) startBlock = api.eth.blockchain.GetBlockByHash(startBlock.ParentHash())
if startBlock == nil { if startBlock == nil {
return nil, fmt.Errorf("Block %x has no parent", endBlock.Number()) return nil, fmt.Errorf("block %x has no parent", endBlock.Number())
} }
} else { } else {
endBlock = api.eth.blockchain.GetBlockByNumber(*endNum) endBlock = api.eth.blockchain.GetBlockByNumber(*endNum)
if endBlock == nil { if endBlock == nil {
return nil, fmt.Errorf("End block %d not found", *endNum) return nil, fmt.Errorf("end block %d not found", *endNum)
} }
} }
return api.getModifiedAccounts(startBlock, endBlock) return api.getModifiedAccounts(startBlock, endBlock)
} }
// GetModifiedAccountsByHash returns all accounts that have changed between the // GetModifiedAccountsByHash returns all accounts that have changed between the
// two blocks specified. A change is defined as a difference in nonce, balance, // two blocks specified. A change is defined as a difference in nonce, balance,
// code hash, or storage hash. // code hash, or storage hash.
//
// With one parameter, returns the list of accounts modified in the specified block.
func (api *PrivateDebugAPI) GetModifiedAccountsByHash(startHash common.Hash, endHash *common.Hash) ([]common.Address, error) { func (api *PrivateDebugAPI) GetModifiedAccountsByHash(startHash common.Hash, endHash *common.Hash) ([]common.Address, error) {
var startBlock, endBlock *types.Block var startBlock, endBlock *types.Block
startBlock = api.eth.blockchain.GetBlockByHash(startHash) startBlock = api.eth.blockchain.GetBlockByHash(startHash)
if startBlock == nil { if startBlock == nil {
return nil, fmt.Errorf("Start block %x not found", startHash) return nil, fmt.Errorf("start block %x not found", startHash)
} }
if endHash == nil { if endHash == nil {
endBlock = startBlock endBlock = startBlock
startBlock = api.eth.blockchain.GetBlockByHash(startBlock.ParentHash()) startBlock = api.eth.blockchain.GetBlockByHash(startBlock.ParentHash())
if startBlock == nil { if startBlock == nil {
return nil, fmt.Errorf("Block %x has no parent", endBlock.Number()) return nil, fmt.Errorf("block %x has no parent", endBlock.Number())
} }
} else { } else {
endBlock = api.eth.blockchain.GetBlockByHash(*endHash) endBlock = api.eth.blockchain.GetBlockByHash(*endHash)
if endBlock == nil { if endBlock == nil {
return nil, fmt.Errorf("End block %x not found", *endHash) return nil, fmt.Errorf("end block %x not found", *endHash)
} }
} }
return api.getModifiedAccounts(startBlock, endBlock) return api.getModifiedAccounts(startBlock, endBlock)
} }
func (api *PrivateDebugAPI) getModifiedAccounts(startBlock, endBlock *types.Block) ([]common.Address, error) { func (api *PrivateDebugAPI) getModifiedAccounts(startBlock, endBlock *types.Block) ([]common.Address, error) {
if startBlock.Number().Uint64() >= endBlock.Number().Uint64() { if startBlock.Number().Uint64() >= endBlock.Number().Uint64() {
return nil, fmt.Errorf("Start block height (%d) must be less than end block height (%d)", startBlock.Number().Uint64(), endBlock.Number().Uint64()) return nil, fmt.Errorf("start block height (%d) must be less than end block height (%d)", startBlock.Number().Uint64(), endBlock.Number().Uint64())
} }
oldTrie, err := trie.NewSecure(startBlock.Root(), api.eth.chainDb, 0) oldTrie, err := trie.NewSecure(startBlock.Root(), api.eth.chainDb, 0)
if err != nil { if err != nil {
return nil, err return nil, err
} }
newTrie, err := trie.NewSecure(endBlock.Root(), api.eth.chainDb, 0) newTrie, err := trie.NewSecure(endBlock.Root(), api.eth.chainDb, 0)
if err != nil { if err != nil {
return nil, err return nil, err
@ -708,11 +708,12 @@ func (api *PrivateDebugAPI) getModifiedAccounts(startBlock, endBlock *types.Bloc
diff, _ := trie.NewDifferenceIterator(oldTrie.NodeIterator([]byte{}), newTrie.NodeIterator([]byte{})) diff, _ := trie.NewDifferenceIterator(oldTrie.NodeIterator([]byte{}), newTrie.NodeIterator([]byte{}))
iter := trie.NewIterator(diff) iter := trie.NewIterator(diff)
var dirty []common.Address var dirty []common.Address
for iter.Next() { for iter.Next() {
key := newTrie.GetKey(iter.Key) key := newTrie.GetKey(iter.Key)
if(key == nil) { if key == nil {
return nil, fmt.Errorf("No preimage found for hash %x", iter.Key) return nil, fmt.Errorf("no preimage found for hash %x", iter.Key)
} }
dirty = append(dirty, common.BytesToAddress(key)) dirty = append(dirty, common.BytesToAddress(key))
} }