Ejemplo n.º 1
0
 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
     }));
 }
Ejemplo n.º 2
0
        void OnTransactionReceived(TransactionReceived transactionReceived)
        {
            try
            {
                this.WalletSemaphore.Wait();

                base.ReceiveTransactionFromMemoryPool(transactionReceived.ReceivedTransaction);
            }
            finally
            {
                this.WalletSemaphore.Release();
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
 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);
     }
 }
Ejemplo n.º 5
0
        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));
        }
Ejemplo n.º 6
0
        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));
        }
Ejemplo n.º 7
0
        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);
            }
        }
Ejemplo n.º 8
0
        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);
Ejemplo n.º 11
0
 void OnTransactionAvailable(TransactionReceived transactionReceived)
 {
     ProcessTransaction(transactionReceived.ReceivedTransaction);
 }