private ResultWrapper <UInt256?> EstimateGas(TransactionForRpc transactionCall, BlockHeader head) { // 2021-03-04 08:54:18.6489|DEBUG|101|Responded to ID 40, eth_estimateGas({ // "from": "0x2b5ad5c4795c026514f8317c7a215e218dccd6cf", // "to": "0xa28afda14be5789564ae5fa03665c4180e3c680b", // "data": "0x25936984" // }) // 2021-03-04 08:54:18.6533|DEBUG|13|Responded to ID 41, eth_sendTransaction({ // "gas": "0x1f815f1", // "from": "0x2b5ad5c4795c026514f8317c7a215e218dccd6cf", // "to": "0xa28afda14be5789564ae5fa03665c4180e3c680b", // "data": "0x25936984", // "gasPrice": "0x4a817c800" // }) FixCallTx(transactionCall); // using CancellationTokenSource cancellationTokenSource = new(_cancellationTokenTimeout); CancellationToken cancellationToken = CancellationToken.None; BlockchainBridge.CallOutput result = _blockchainBridge.EstimateGas(head, transactionCall.ToTransaction(), cancellationToken); if (result.Error == null) { return(ResultWrapper <UInt256?> .Success((UInt256)result.GasSpent)); } return(ResultWrapper <UInt256?> .Fail(result.Error, result.InputError?ErrorCodes.InvalidInput : ErrorCodes.InternalError)); }
public ResultWrapper <UInt256?> eth_estimateGas(TransactionForRpc transactionCall) { BlockHeader head = _blockchainBridge.FindLatestHeader(); FixCallTx(transactionCall, head); long result = _blockchainBridge.EstimateGas(head, transactionCall.ToTransaction()); return(ResultWrapper <UInt256?> .Success((UInt256)result)); }
public ResultWrapper <UInt256?> eth_estimateGas(TransactionForRpc transactionCall) { Block headBlock = _blockchainBridge.FindHeadBlock(); if (transactionCall.Gas == null) { transactionCall.Gas = headBlock.GasLimit; } long result = _blockchainBridge.EstimateGas(headBlock, transactionCall.ToTransaction()); return(ResultWrapper <UInt256?> .Success((UInt256)result)); }
public ResultWrapper <UInt256?> eth_estimateGas(TransactionForRpc transactionCall) { BlockHeader head = _blockchainBridge.FindLatestHeader(); FixCallTx(transactionCall, head); BlockchainBridge.CallOutput result = _blockchainBridge.EstimateGas(head, transactionCall.ToTransaction()); if (result.Error == null) { return(ResultWrapper <UInt256?> .Success((UInt256)result.GasSpent)); } return(ResultWrapper <UInt256?> .Fail(result.Error)); }
private ResultWrapper <UInt256?> EstimateGas(TransactionForRpc transactionCall, BlockHeader head) { FixCallTx(transactionCall, head); var tokenTimeout = TimeSpan.FromMilliseconds(_rpcConfig.TracerTimeout); CancellationToken cancellationToken = new CancellationTokenSource(tokenTimeout).Token; BlockchainBridge.CallOutput result = _blockchainBridge.EstimateGas(head, transactionCall.ToTransaction(), cancellationToken); if (result.Error == null) { return(ResultWrapper <UInt256?> .Success((UInt256)result.GasSpent)); } return(ResultWrapper <UInt256?> .Fail(result.Error)); }
private ResultWrapper <UInt256?> EstimateGas(TransactionForRpc transactionCall, BlockHeader head) { FixCallTx(transactionCall, head); using CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(_cancellationTokenTimeout); CancellationToken cancellationToken = cancellationTokenSource.Token; BlockchainBridge.CallOutput result = _blockchainBridge.EstimateGas(head, transactionCall.ToTransaction(), cancellationToken); if (result.Error == null) { return(ResultWrapper <UInt256?> .Success((UInt256)result.GasSpent)); } return(ResultWrapper <UInt256?> .Fail(result.Error)); }
public ResultWrapper <BigInteger?> eth_estimateGas(TransactionForRpc transactionCall) { try { _readerWriterLockSlim.EnterWriteLock(); Block headBlock = _blockchainBridge.RetrieveHeadBlock(); if (transactionCall.Gas == null) { transactionCall.Gas = headBlock.GasLimit; } long result = _blockchainBridge.EstimateGas(headBlock, transactionCall.ToTransaction()); return(ResultWrapper <BigInteger?> .Success(result)); } finally { _readerWriterLockSlim.ExitWriteLock(); } }
public ResultWrapper <UInt256?> eth_estimateGas(TransactionForRpc transactionCall) { BlockHeader head = _blockchainBridge.FindLatestHeader(); if (!HasStateForBlock(head)) { return(ResultWrapper <UInt256?> .Fail($"No state available for block {head.Hash}", ErrorCodes.ResourceUnavailable)); } FixCallTx(transactionCall, head); BlockchainBridge.CallOutput result = _blockchainBridge.EstimateGas(head, transactionCall.ToTransaction()); if (result.Error == null) { return(ResultWrapper <UInt256?> .Success((UInt256)result.GasSpent)); } return(ResultWrapper <UInt256?> .Fail(result.Error)); }