示例#1
0
        public ResultWrapper <Transaction> eth_getTransactionByHash(Data transactionHash)
        {
            var transaction = _blockchainBridge.GetTransaction(new Keccak(transactionHash.Value));

            if (transaction == null)
            {
                return(ResultWrapper <Transaction> .Fail($"Cannot find transaction for hash: {transactionHash.Value}", ErrorType.NotFound));
            }
            var blockHash = _blockchainBridge.GetBlockHash(new Keccak(transactionHash.Value));

            if (blockHash == null)
            {
                return(ResultWrapper <Transaction> .Fail($"Cannot find block hash for transaction: {transactionHash.Value}", ErrorType.NotFound));
            }
            var block = _blockchainBridge.FindBlock(blockHash, false);

            if (block == null)
            {
                return(ResultWrapper <Transaction> .Fail($"Cannot find block for hash: {blockHash}", ErrorType.NotFound));
            }

            var transactionModel = _modelMapper.MapTransaction(transaction, block);

            if (Logger.IsTrace)
            {
                Logger.Trace($"eth_getTransactionByHash request {transactionHash.ToJson()}, result: {GetJsonLog(transactionModel.ToJson())}");
            }
            return(ResultWrapper <Transaction> .Success(transactionModel));
        }
示例#2
0
        public ResultWrapper <Data> eth_sendTransaction(Transaction transaction)
        {
            Core.Transaction tx     = _modelMapper.MapTransaction(transaction);
            Keccak           txHash = _blockchainBridge.SendTransaction(tx);

            return(ResultWrapper <Data> .Success(new Data(txHash)));
        }