public void ProcessBlockTransactions(Block block) { if (block == null) { throw new ArgumentNullException("block"); } if (!block.IsCorrect()) { throw new MethodArgumentException("block", "The block is invalid."); } var transactions = block.Transactions; foreach (var trx in transactions) { // The solver is responsible for processing the data from the transaction for specific purposes string typeUnit = trx.GetTypeUnit(); ITransactionSolver solver = GetSolver(typeUnit); if (solver != null) { solver.Solve(this, trx); } // TODO: remove the transaction from the pool of pending transactions, if it exists } }
public void RegisterSolver(ITransactionSolver solver) { if (solver == null) { throw new ArgumentNullException("solver"); } string sign = solver.Sign; fSolvers[sign] = solver; }
public bool VerifyTransactions(Transaction transaction) { if (transaction == null) { throw new ArgumentNullException("transaction"); } if (!transaction.IsCorrect()) { throw new MethodArgumentException("transaction", "The transaction is invalid."); } try { string typeUnit = transaction.GetTypeUnit(); ITransactionSolver solver = GetSolver(typeUnit); return((solver != null) && solver.Verify(transaction)); } catch { return(false); } }