MCPcopy Create free account
hub / github.com/CPChain/chain / GetModifiedAccountsByHash

Method GetModifiedAccountsByHash

protocols/cpc/api.go:450–470  ·  view source on GitHub ↗

GetModifiedAccountsByHash returns all accounts that have changed between the two blocks specified. A change is defined as a difference in nonce, balance, code hash, or storage hash. With one parameter, returns the list of accounts modified in the specified block.

(startHash common.Hash, endHash *common.Hash)

Source from the content-addressed store, hash-verified

448//
449// With one parameter, returns the list of accounts modified in the specified block.
450func (api *PrivateDebugAPI) GetModifiedAccountsByHash(startHash common.Hash, endHash *common.Hash) ([]common.Address, error) {
451 var startBlock, endBlock *types.Block
452 startBlock = api.cpc.blockchain.GetBlockByHash(startHash)
453 if startBlock == nil {
454 return nil, fmt.Errorf("start block %x not found", startHash)
455 }
456
457 if endHash == nil {
458 endBlock = startBlock
459 startBlock = api.cpc.blockchain.GetBlockByHash(startBlock.ParentHash())
460 if startBlock == nil {
461 return nil, fmt.Errorf("block %x has no parent", endBlock.Number())
462 }
463 } else {
464 endBlock = api.cpc.blockchain.GetBlockByHash(*endHash)
465 if endBlock == nil {
466 return nil, fmt.Errorf("end block %x not found", *endHash)
467 }
468 }
469 return api.getModifiedAccounts(startBlock, endBlock)
470}
471
472func (api *PrivateDebugAPI) getModifiedAccounts(startBlock, endBlock *types.Block) ([]common.Address, error) {
473 if startBlock.Number().Uint64() >= endBlock.Number().Uint64() {

Callers

nothing calls this directly

Calls 4

ParentHashMethod · 0.95
NumberMethod · 0.95
getModifiedAccountsMethod · 0.95
GetBlockByHashMethod · 0.65

Tested by

no test coverage detected