public void ScanTree(TrieNode node, TrieKey key, IScanAction scan_action) { if (node != null) { if (node.Hash != null) { scan_action.OnNode(node.Hash, node); } if (node.NodeType == TrieNode.TrieNodeType.BranchNode) { if (node.BranchNodeGetValue() != null) { scan_action.OnValue(node.Hash, node, key.ToNormal(), node.BranchNodeGetValue()); } for (int i = 0; i < 16; i++) { ScanTree(node.BranchNodeGetChild(i), key.Concat(TrieKey.SingleHex(i)), scan_action); } } else if (node.NodeType == TrieNode.TrieNodeType.KVNodeNode) { ScanTree(node.KVNodeGetChildNode(), key.Concat(node.KVNodeGetKey()), scan_action); } else { scan_action.OnValue(node.Hash, node, key.Concat(node.KVNodeGetKey()).ToNormal(), node.KVNodeGetValue()); } } }