public Task Handle(TransactionReceived message, IMessageHandlerContext context) { Data.TransactionId = message.TransactionId; return(context.Send(new AddTransaction() { ToAccount = message.ToAccount, FromAccount = message.FromAccount, Amount = message.Amount, MessageId = message.MessageId, TransactionId = message.TransactionId })); }
void OnTransactionReceived(TransactionReceived transactionReceived) { try { this.WalletSemaphore.Wait(); base.ReceiveTransactionFromMemoryPool(transactionReceived.ReceivedTransaction); } finally { this.WalletSemaphore.Release(); } }
public void Process(Transaction tx) { lock (ProcessedLock) { if (ProcessedTransactionHashes.Add(tx.GetHash())) { TransactionReceived?.Invoke(this, new SmartTransaction(tx, Height.Mempool)); } else { Interlocked.Increment(ref _duplicatedReceives); } Interlocked.Increment(ref _totalReceives); } }
public static bool TryReadSignedTransaction(TransactionReceived request, out SignedTransaction signed) { try { using (var stream = new ByteStream(Convert.FromBase64String(request.Transaction))) { signed = stream.ReadSignedTransaction(); } return(true); } catch { signed = null; return(false); } }
public void ReceiveAccountTransactions() { var t = new Transaction { CreatedAt = DateTime.Now.ToString(), FeePaid = 1, Hash = "ReceivedTransactionHash", Ledger = 1, Message = "ReceivedTransactionMessage", OperationCount = 1, SourceAccount = "SourceAccountId", TargetAccount = "TargetAccountId", SourceAccountSequence = 1 }; TransactionReceived?.Invoke(this, new TransactionEventArgs(t)); }
public async void MakeTransaction(string targetAccountId, decimal amount, string transactionMessage) { var t = new Transaction { CreatedAt = DateTime.Now.ToString(), FeePaid = 1, Hash = "MadeTransactionHash", Ledger = 1, Message = "MadeTransactionMessage", OperationCount = 1, SourceAccount = "SourceAccountId", TargetAccount = "TargetAccountId", SourceAccountSequence = 1 }; TransactionReceived?.Invoke(this, new TransactionEventArgs(t)); }
public async Task <bool> PostTransaction([FromBody] TransactionDTO transaction) { try { Guid guid = await _service.AddTransaction(_mapper.Map <TransactionModel>(transaction)); TransactionReceived transactionReceived = _mapper.Map <TransactionReceived>(transaction); transactionReceived.TransactionId = guid; transactionReceived.MessageId = Guid.NewGuid().ToString(); await _messageSession.Publish(transactionReceived); return(true); } catch { return(false); } }
private void GenerateTransactions() { for (int i = 0; i < 5; i++) { var t = new Transaction { CreatedAt = DateTime.Now.ToString(), FeePaid = i, Hash = $"TransactionHash{i}", Ledger = i, Message = $"TransactionMessage{i}", OperationCount = i, SourceAccount = "SourceAccountId", TargetAccount = "TargetAccountId", SourceAccountSequence = i }; TransactionReceived?.Invoke(this, new TransactionEventArgs(t)); } }
private void OnTransactionAvailable(TransactionReceived transactionReceived) { this.ProcessTransaction(transactionReceived.ReceivedTransaction); }
internal void OnTransactionReceived(SmartTransaction transaction) => TransactionReceived?.Invoke(this, transaction);
void OnTransactionAvailable(TransactionReceived transactionReceived) { ProcessTransaction(transactionReceived.ReceivedTransaction); }