public PrefetcherCoinView(CoinView inner) { if (inner == null) { throw new ArgumentNullException("inner"); } _Inner = inner; }
public ParallelCoinView(TaskScheduler taskScheduler, CoinView inner) { if (inner == null) { throw new ArgumentNullException("inner"); } TaskScheduler = taskScheduler; _Inner = inner; BatchMaxSize = 100; }
public BackgroundCommiterCoinView(CoinView inner) { if (inner == null) { throw new ArgumentNullException("inner"); } _Inner = inner; _InnerCommitable = new CommitableCoinView(Inner); _Commitable = new CommitableCoinView(_InnerCommitable); FlushPeriod = TimeSpan.FromSeconds(5); }
public CoinViewStack(CoinView top) { Top = top; var current = top; while (current is IBackedCoinView) { current = ((IBackedCoinView)current).Inner; } Bottom = current; }
public CommitableCoinView(ChainedBlock newTip, CoinView inner) { if (inner == null) { throw new ArgumentNullException("inner"); } if (newTip == null) { throw new ArgumentNullException("newTip"); } _Inner = inner; _Uncommited.SaveChanges(newTip, new[] { new UnspentOutputs(new uint256(), new Coins()) }); }
public CommitableCoinView(ChainedBlock newTip, CoinView inner) { if (inner == null) { throw new ArgumentNullException("inner"); } if (newTip == null) { throw new ArgumentNullException("newTip"); } _Inner = inner; _Uncommited.SaveChanges(newTip, NullUItn256s, NullCoins); }
private void CheckIntputs(Transaction tx, CoinView inputs, int nSpendHeight) { if (!inputs.HaveInputs(tx)) { ConsensusErrors.BadTransactionMissingInput.Throw(); } Money nValueIn = Money.Zero; Money nFees = Money.Zero; for (int i = 0; i < tx.Inputs.Count; i++) { var prevout = tx.Inputs[i].PrevOut; var coins = inputs.AccessCoins(prevout.Hash); // If prev is coinbase, check that it's matured if (coins.Coinbase) { if (nSpendHeight - coins.Height < COINBASE_MATURITY) { ConsensusErrors.BadTransactionPrematureCoinbaseSpending.Throw(); } } // Check for negative or overflow input values nValueIn += coins.TryGetOutput(prevout.N).Value; if (!MoneyRange(coins.TryGetOutput(prevout.N).Value) || !MoneyRange(nValueIn)) { ConsensusErrors.BadTransactionInputValueOutOfRange.Throw(); } } if (nValueIn < tx.TotalOut) { ConsensusErrors.BadTransactionInBelowOut.Throw(); } // Tally transaction fees Money nTxFee = nValueIn - tx.TotalOut; if (nTxFee < 0) { ConsensusErrors.BadTransactionNegativeFee.Throw(); } nFees += nTxFee; if (!MoneyRange(nFees)) { ConsensusErrors.BadTransactionFeeOutOfRange.Throw(); } }
public CacheCoinView(CoinView inner) { if (inner == null) { throw new ArgumentNullException("inner"); } _Inner = inner; _Cache = new InMemoryCoinView(_Inner.Tip) { RemovePrunableCoins = false }; ReadThrough = true; WriteThrough = true; MaxItems = 100000; }
private uint GetP2SHSigOpCount(Transaction tx, CoinView inputs) { if (tx.IsCoinBase) { return(0); } uint nSigOps = 0; for (uint i = 0; i < tx.Inputs.Count; i++) { var prevout = inputs.GetOutputFor(tx.Inputs[i]); if (prevout.ScriptPubKey.IsPayToScriptHash) { nSigOps += prevout.ScriptPubKey.GetSigOpCount(tx.Inputs[i].ScriptSig); } } return(nSigOps); }
private long GetTransactionSigOpCost(Transaction tx, CoinView inputs, ConsensusFlags flags) { long nSigOps = GetLegacySigOpCount(tx) * WITNESS_SCALE_FACTOR; if (tx.IsCoinBase) { return(nSigOps); } if (flags.ScriptFlags.HasFlag(ScriptVerify.P2SH)) { nSigOps += GetP2SHSigOpCount(tx, inputs) * WITNESS_SCALE_FACTOR; } for (var i = 0; i < tx.Inputs.Count; i++) { var prevout = inputs.GetOutputFor(tx.Inputs[i]); nSigOps += CountWitnessSigOps(tx.Inputs[i].ScriptSig, prevout.ScriptPubKey, tx.Inputs[i].WitScript, flags); } return(nSigOps); }
public ParallelCoinView(CoinView inner) : this(null, inner) { }
public CommitableCoinView(CoinView inner) : this(inner.Tip, inner) { }
public void Commit(CoinView coinview) { var changedCoins = GetChangedCoins(); coinview.SaveChanges(_Uncommited.Tip, changedCoins); }
public void SetInner(CoinView inner) { _Inner = inner; }
public void SaveChanges(CoinView coinview) { coinview.SaveChanges(_Uncommited.Tip, _Uncommited.coins.Keys, _Uncommited.coins.Values); }