Exemple #1
0
        private bool HasStateForBlock(BlockHeader header)
        {
            RootCheckVisitor rootCheckVisitor = new RootCheckVisitor();

            _blockchainBridge.RunTreeVisitor(rootCheckVisitor, header.StateRoot);
            return(rootCheckVisitor.HasRoot);
        }
Exemple #2
0
    // https://github.com/ethereum/EIPs/issues/1186
    public ResultWrapper <AccountProof> eth_getProof(Address accountAddress, byte[][] storageKeys,
                                                     BlockParameter blockParameter)
    {
        BlockHeader header;

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

            if (!HasStateForBlock(_blockchainBridge, 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(accountAddress, storageKeys);

        _blockchainBridge.RunTreeVisitor(accountProofCollector, header.StateRoot);

        return(ResultWrapper <AccountProof> .Success(accountProofCollector.BuildResult()));
    }
Exemple #3
0
    private static bool HasStateForBlock(IBlockchainBridge blockchainBridge, BlockHeader header)
    {
        RootCheckVisitor rootCheckVisitor = new();

        blockchainBridge.RunTreeVisitor(rootCheckVisitor, header.StateRoot);
        return(rootCheckVisitor.HasRoot);
    }
Exemple #4
0
        // https://github.com/ethereum/EIPs/issues/1186
        public ResultWrapper <AccountProof> eth_getProof(Address accountAddress, byte[][] storageKeys, BlockParameter blockParameter)
        {
            BlockHeader header;

            try
            {
                header = _blockchainBridge.GetHeader(blockParameter);
            }
            catch (JsonRpcException ex)
            {
                return(ResultWrapper <AccountProof> .Fail(ex.Message, ex.ErrorType, null));
            }

            ProofCollector proofCollector = new ProofCollector(accountAddress, storageKeys);

            _blockchainBridge.RunTreeVisitor(proofCollector, header.StateRoot);

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