Exemplo n.º 1
0
        public async void should_verify_incoming_transaction()
        {
            await _subject.RecieveTransaction(new Transaction()
            {
                TransactionId = new byte[0]
            });

            A.CallTo(() => _blockVerifier.VerifyTransaction(A <Transaction> .Ignored, A <ICollection <Transaction> > .Ignored))
            .MustHaveHappened();
        }
Exemplo n.º 2
0
        public async Task <PeerDataResult> RecieveTransaction(Transaction transaction)
        {
            _logger.LogDebug($"Recv txn {BitConverter.ToString(transaction.TransactionId)}");
            var txnResult = await _blockVerifier.VerifyTransaction(transaction, _unconfirmedTransactionPool.Get);

            if (txnResult == 0)
            {
                if (_unconfirmedTransactionPool.Add(transaction))
                {
                    _logger.LogDebug($"Accepted txn {BitConverter.ToString(transaction.TransactionId)}");
                    return(PeerDataResult.Relay);
                }

                return(PeerDataResult.Ignore);
            }
            _logger.LogDebug($"Rejected txn {BitConverter.ToString(transaction.TransactionId)} code: {txnResult}");
            return(PeerDataResult.Ignore);
        }