示例#1
0
        public Task <ResultWrapper <UInt256?> > eth_getBalance(Address address, BlockParameter blockParameter = null)
        {
            SearchResult <BlockHeader> searchResult = _blockchainBridge.SearchForHeader(blockParameter);

            if (searchResult.IsError)
            {
                return(Task.FromResult(ResultWrapper <UInt256?> .Fail(searchResult)));
            }

            BlockHeader header  = searchResult.Object;
            Account     account = _blockchainBridge.GetAccount(address, header.StateRoot);

            return(Task.FromResult(ResultWrapper <UInt256?> .Success(account?.Balance ?? UInt256.Zero)));
        }
示例#2
0
        public Task <ResultWrapper <UInt256?> > eth_getBalance(Address address, BlockParameter blockParameter = null)
        {
            SearchResult <BlockHeader> searchResult = _blockchainBridge.SearchForHeader(blockParameter);

            if (searchResult.IsError)
            {
                return(Task.FromResult(ResultWrapper <UInt256?> .Fail(searchResult)));
            }

            BlockHeader header = searchResult.Object;

            if (!HasStateForBlock(header))
            {
                return(Task.FromResult(ResultWrapper <UInt256?> .Fail($"No state available for block {header.Hash}", ErrorCodes.ResourceUnavailable)));
            }

            Account account = _blockchainBridge.GetAccount(address, header.StateRoot);

            return(Task.FromResult(ResultWrapper <UInt256?> .Success(account?.Balance ?? UInt256.Zero)));
        }