Beispiel #1
0
        // https://github.com/ethereum/EIPs/issues/1186
        public ResultWrapper <AccountProof> eth_getProof(Address accountAddress, byte[][] storageKeys, BlockParameter blockParameter)
        {
            BlockHeader header;

            try
            {
                header = _blockchainBridge.FindHeader(blockParameter);
                if (header == null)
                {
                    return(ResultWrapper <AccountProof> .Fail($"{blockParameter} block not found", ErrorCodes.ResourceNotFound, null));
                }

                if (!HasStateForBlock(header))
                {
                    return(ResultWrapper <AccountProof> .Fail($"No state available for block {header.Hash}", ErrorCodes.ResourceUnavailable));
                }
            }
            catch (Exception ex)
            {
                return(ResultWrapper <AccountProof> .Fail(ex.Message, ErrorCodes.InternalError, null));
            }

            AccountProofCollector accountProofCollector = new AccountProofCollector(accountAddress, storageKeys);

            _blockchainBridge.RunTreeVisitor(accountProofCollector, header.StateRoot);

            return(ResultWrapper <AccountProof> .Success(accountProofCollector.BuildResult()));
        }