Ejemplo n.º 1
0
        public async Task Persist(Transaction transaction)
        {
            await SpendOutputs(transaction.Inputs);
            await GainOutputs(transaction.Hash, transaction.Outputs);

            switch (transaction)
            {
            case ContractTransaction _:
            case MinerTransaction _:
                break;

            case ClaimTransaction claim:
                await _claimTransactionPersister.Persist(claim);

                break;

            case InvocationTransaction invocation:
                await _invocationTransactionPersister.Persist(invocation);

                break;

            case StateTransaction state:
                await _stateTransactionPersister.Persist(state);

                break;

            case IssueTransaction issue:
                await _issueTransactionPersister.Persist(issue);

                break;

            case PublishTransaction publish:
                await _publishTransactionPersister.Persist(publish);

                break;

            case RegisterTransaction register:
                await _registerTransactionPersister.Persist(register);

                break;

            case EnrollmentTransaction enrollment:
                await _enrollmentTransactionPersister.Persist(enrollment);

                break;

            default:
                throw new ArgumentException("Unknown Transaction Type");
            }

            await _repository.AddTransaction(transaction);

            _transactionPool.Remove(transaction.Hash);
        }