Exemplo n.º 1
0
        private ResultWrapper <byte[]> GetStorage(Address address, BigInteger index, BlockParameter blockParameter)
        {
            if (blockParameter.Type == BlockParameterType.Pending)
            {
                var storageValue = _blockchainBridge.GetStorage(address, index);
                return(ResultWrapper <byte[]> .Success(storageValue));
            }

            var block = GetBlock(blockParameter);

            if (block.Result.ResultType == ResultType.Failure)
            {
                return(ResultWrapper <byte[]> .Fail(block.Result.Error));
            }

            return(GetAccountStorage(address, index, block.Data.Header.StateRoot));
        }
Exemplo n.º 2
0
        private ResultWrapper <byte[]> GetAccountStorage(Address address, UInt256 index, Keccak stateRoot)
        {
            Account account = _blockchainBridge.GetAccount(address, stateRoot);

            if (account == null)
            {
                return(ResultWrapper <byte[]> .Success(Bytes.Empty));
            }

            return(ResultWrapper <byte[]> .Success(_blockchainBridge.GetStorage(address, index, stateRoot)));
        }
Exemplo n.º 3
0
        public ResultWrapper <byte[]> eth_getStorageAt(Address address, UInt256 positionIndex, BlockParameter blockParameter = null)
        {
            SearchResult <BlockHeader> searchResult = _blockchainBridge.SearchForHeader(blockParameter);

            if (searchResult.IsError)
            {
                return(ResultWrapper <byte[]> .Fail(searchResult));
            }

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

            if (account == null)
            {
                return(ResultWrapper <byte[]> .Success(Bytes.Empty));
            }

            return(ResultWrapper <byte[]> .Success(_blockchainBridge.GetStorage(address, positionIndex, header.StateRoot)));
        }