(startBlock, endBlock *types.Block)
| 470 | } |
| 471 | |
| 472 | func (api *PrivateDebugAPI) getModifiedAccounts(startBlock, endBlock *types.Block) ([]common.Address, error) { |
| 473 | if startBlock.Number().Uint64() >= endBlock.Number().Uint64() { |
| 474 | return nil, fmt.Errorf("start block height (%d) must be less than end block height (%d)", startBlock.Number().Uint64(), endBlock.Number().Uint64()) |
| 475 | } |
| 476 | |
| 477 | oldTrie, err := trie.NewSecure(startBlock.StateRoot(), trie.NewDatabase(api.cpc.chainDb), 0) |
| 478 | if err != nil { |
| 479 | return nil, err |
| 480 | } |
| 481 | newTrie, err := trie.NewSecure(endBlock.StateRoot(), trie.NewDatabase(api.cpc.chainDb), 0) |
| 482 | if err != nil { |
| 483 | return nil, err |
| 484 | } |
| 485 | |
| 486 | diff, _ := trie.NewDifferenceIterator(oldTrie.NodeIterator([]byte{}), newTrie.NodeIterator([]byte{})) |
| 487 | iter := trie.NewIterator(diff) |
| 488 | |
| 489 | var dirty []common.Address |
| 490 | for iter.Next() { |
| 491 | key := newTrie.GetKey(iter.Key) |
| 492 | if key == nil { |
| 493 | return nil, fmt.Errorf("no preimage found for hash %x", iter.Key) |
| 494 | } |
| 495 | dirty = append(dirty, common.BytesToAddress(key)) |
| 496 | } |
| 497 | return dirty, nil |
| 498 | } |
no test coverage detected