public async Task UpsertAsync(RPC.Eth.DTOs.Transaction transaction, TransactionReceipt receipt, bool failed, HexBigInteger timeStamp, bool hasVmStack = false, string error = null) { await _lock.WaitAsync(); try { using (var context = _contextFactory.CreateContext()) { var tx = await FindOrCreate(transaction, context).ConfigureAwait(false); tx.Map(transaction); tx.Map(receipt); tx.Failed = failed; tx.TimeStamp = (long)timeStamp.Value; tx.Error = error ?? string.Empty; tx.HasVmStack = hasVmStack; tx.UpdateRowDates(); context.Transactions.AddOrUpdate(tx); await context.SaveChangesAsync().ConfigureAwait(false); } } finally { _lock.Release(); } }
public static TransactionBase CreateTransaction( TransactionBase transaction, RPC.Eth.DTOs.Transaction transactionSource, TransactionReceipt transactionReceipt, bool failed, HexBigInteger timeStamp, string error = null, bool hasVmStack = false, string newContractAddress = null) { transaction.BlockHash = transactionSource.BlockHash; transaction.Hash = transactionSource.TransactionHash; transaction.AddressFrom = transactionSource.From; transaction.TransactionIndex = (long)transactionReceipt.TransactionIndex.Value; transaction.SetValue(transactionSource.Value); transaction.AddressTo = transactionSource.To ?? string.Empty; transaction.NewContractAddress = newContractAddress ?? string.Empty; transaction.SetBlockNumber(transactionSource.BlockNumber); transaction.SetGas(transactionSource.Gas); transaction.SetGasPrice(transactionSource.GasPrice); transaction.Input = transactionSource.Input ?? string.Empty; transaction.Nonce = (long)transactionSource.Nonce.Value; transaction.Failed = failed; transaction.SetGasUsed(transactionReceipt.GasUsed); transaction.SetCumulativeGasUsed(transactionReceipt.CumulativeGasUsed); transaction.HasLog = transactionReceipt.Logs.Count > 0; transaction.SetTimeStamp(timeStamp); transaction.Error = error ?? string.Empty; transaction.HasVmStack = hasVmStack; return(transaction); }
public async Task UpsertAsync( RPC.Eth.DTOs.Transaction transaction, TransactionReceipt receipt, bool failedCreatingContract, HexBigInteger blockTimestamp, string address, string error = null, bool hasVmStack = false, string newContractAddress = null) { using (var context = _contextFactory.CreateContext()) { var tx = await FindOrCreate(transaction, address, context).ConfigureAwait(false); tx.Map(transaction, address); tx.UpdateRowDates(); if (tx.IsNew()) { context.AddressTransactions.Add(tx); } else { context.AddressTransactions.Update(tx); } await context.SaveChangesAsync().ConfigureAwait(false); } }
public async Task UpsertAsync(string contractAddress, string code, RPC.Eth.DTOs.Transaction transaction, TransactionReceipt receipt, bool failedCreatingContract, HexBigInteger blockTimestamp) { await _lock.WaitAsync(); try { using (var context = _contextFactory.CreateContext()) { var tx = await FindOrCreate(transaction, context).ConfigureAwait(false); tx.Map(transaction); tx.Map(receipt); tx.NewContractAddress = contractAddress; tx.Failed = false; tx.TimeStamp = (long)blockTimestamp.Value; tx.Error = string.Empty; tx.HasVmStack = false; tx.UpdateRowDates(); context.Transactions.AddOrUpdate(tx); await context.SaveChangesAsync().ConfigureAwait(false); } } finally { _lock.Release(); } }
public async Task UpsertAsync(RPC.Eth.DTOs.Transaction transaction, TransactionReceipt transactionReceipt, bool failedCreatingContract, HexBigInteger blockTimestamp, string address, string error = null, bool hasVmStack = false, string newContractAddress = null) { var tx = new CosmosAddressTransaction(); tx.Map(transaction, address); tx.UpdateRowDates(); await UpsertDocumentAsync(tx); }
public static Transaction CreateTransaction(RPC.Eth.DTOs.Transaction transactionSource, TransactionReceipt transactionReceipt, bool failed, HexBigInteger timeStamp, string newContractAddress) { return ((Transaction) CreateTransaction(new Transaction(), transactionSource, transactionReceipt, failed, timeStamp, null, false, newContractAddress)); }
public static Transaction CreateTransaction(RPC.Eth.DTOs.Transaction transactionSource, TransactionReceipt transactionReceipt, bool failed, HexBigInteger timeStamp, bool hasVmStack = false, string error = null) { return ((Transaction) CreateTransaction(new Transaction(), transactionSource, transactionReceipt, failed, timeStamp, error, hasVmStack)); }
public async Task UpsertAsync(string contractAddress, string code, RPC.Eth.DTOs.Transaction transaction) { var contract = new Contract(); contract.Map(contractAddress, code, transaction); contract.UpdateRowDates(); await Write(contract).ConfigureAwait(false); CachedContracts.AddOrUpdate(contract.Address, contract, (s, existingContract) => contract); }
public async Task UpsertAsync(string contractAddress, string code, RPC.Eth.DTOs.Transaction transaction) { var contract = new MongoDbContract { }; contract.Map(contractAddress, code, transaction); contract.UpdateRowDates(); await UpsertDocumentAsync(contract); _cachedContracts.AddOrUpdate(contract.Address, contract, (s, existingContract) => contract); }
public static Contract CreateContract(string contractAddress, string code, RPC.Eth.DTOs.Transaction transactionSource) { var contract = new Contract() { Address = contractAddress, Creator = transactionSource.From, TransactionHash = transactionSource.TransactionHash }; contract.InitCode(code); cachedContracts?.Add(contract); return(contract); }
public async Task UpsertAsync(RPC.Eth.DTOs.Transaction transaction, TransactionReceipt receipt, bool failed, HexBigInteger timeStamp, bool hasVmStack = false, string error = null) { var tx = new MongoDbTransaction(); tx.Map(transaction); tx.Map(receipt); tx.Failed = failed; tx.TimeStamp = (long)timeStamp.Value; tx.Error = error ?? string.Empty; tx.HasVmStack = hasVmStack; tx.UpdateRowDates(); await UpsertDocumentAsync(tx); }
public async Task UpsertAsync(string contractAddress, string code, RPC.Eth.DTOs.Transaction transaction, TransactionReceipt transactionReceipt, bool failedCreatingContract, HexBigInteger blockTimestamp) { var tx = new MongoDbTransaction(); tx.Map(transaction); tx.Map(transactionReceipt); tx.NewContractAddress = contractAddress; tx.Failed = false; tx.TimeStamp = (long)blockTimestamp.Value; tx.Error = string.Empty; tx.HasVmStack = false; tx.UpdateRowDates(); await UpsertDocumentAsync(tx); }
public static AddressTransaction CreateAddressTransaction(RPC.Eth.DTOs.Transaction transactionSource, TransactionReceipt transactionReceipt, bool failed, HexBigInteger timeStamp, string address, string error = null, bool hasVmStack = false, string newContractAddress = null ) { var transaction = new AddressTransaction() { Address = address ?? string.Empty }; //transaction.SetRowKey(transactionSource.BlockNumber, transactionSource.TransactionHash); return ((AddressTransaction) CreateTransaction(transaction, transactionSource, transactionReceipt, failed, timeStamp, error, hasVmStack, newContractAddress)); }
private static async Task <BlockchainStore.Entities.AddressTransaction> FindOrCreate(RPC.Eth.DTOs.Transaction transaction, string address, BlockchainDbContextBase context) { return(await context.AddressTransactions .FindByBlockNumberAndHashAndAddressAsync(transaction.BlockNumber, transaction.TransactionHash, address).ConfigureAwait(false) ?? new BlockchainStore.Entities.AddressTransaction()); }
private async Task <BlockchainProcessing.BlockStorage.Entities.Transaction> FindOrCreate(RPC.Eth.DTOs.Transaction transaction, BlockchainDbContextBase context) { return(await context.Transactions.FindByBlockNumberAndHashAsync(transaction.BlockNumber, transaction.TransactionHash).ConfigureAwait(false) ?? new BlockchainProcessing.BlockStorage.Entities.Transaction()); }