private void SaveRollbackInformation(UInt256 blockHash, SpentTransactionsCache spentTransactionsCache, SpentOutputsCache spentOutputsCache) { spentTransactionsCache[blockHash] = this.spentTransactions.ToImmutable(); this.spentTransactions.Clear(); spentOutputsCache[blockHash] = this.spentOutputs.ToImmutable(); this.spentOutputs.Clear(); }
public PruningWorker(WorkerConfig workerConfig, Func <ChainStateBuilder> getChainStateBuilder, Logger logger, IBlockchainRules rules, BlockTxHashesCache blockTxHashesCache, TransactionCache transactionCache, SpentTransactionsCache spentTransactionsCache, SpentOutputsCache spentOutputsCache) : base("PruningWorker", workerConfig.initialNotify, workerConfig.minIdleTime, workerConfig.maxIdleTime, logger) { this.getChainStateBuilder = getChainStateBuilder; this.rules = rules; this.blockTxHashesCache = blockTxHashesCache; this.transactionCache = transactionCache; this.spentTransactionsCache = spentTransactionsCache; this.spentOutputsCache = spentOutputsCache; this.Mode = PruningMode.SpentOnly; }
public ChainStateWorker(TargetChainWorker targetChainWorker, ChainStateBuilder chainStateBuilder, Func <Chain> getTargetChain, WorkerConfig workerConfig, Logger logger, IKernel kernel, IBlockchainRules rules, BlockCache blockCache, SpentTransactionsCache spentTransactionsCache, InvalidBlockCache invalidBlockCache) : base("ChainStateWorker", workerConfig.initialNotify, workerConfig.minIdleTime, workerConfig.maxIdleTime, logger) { this.logger = logger; this.getTargetChain = getTargetChain; this.kernel = kernel; this.rules = rules; this.blockCache = blockCache; this.spentTransactionsCache = spentTransactionsCache; this.invalidBlockCache = invalidBlockCache; this.blockProcessingDurationMeasure = new DurationMeasure(); this.targetChainWorker = targetChainWorker; this.chainStateBuilder = chainStateBuilder; this.currentChain = this.chainStateBuilder.Chain.ToImmutable(); this.pruningWorker = kernel.Get <PruningWorker>( new ConstructorArgument("workerConfig", new WorkerConfig(initialNotify: false, minIdleTime: TimeSpan.FromSeconds(30), maxIdleTime: TimeSpan.FromMinutes(5))), new ConstructorArgument("getChainStateBuilder", (Func <ChainStateBuilder>)(() => this.chainStateBuilder))); }
public ChainStateBuilder(ChainBuilder chain, Utxo parentUtxo, Logger logger, IKernel kernel, IBlockchainRules rules, BlockHeaderCache blockHeaderCache, BlockCache blockCache, SpentTransactionsCache spentTransactionsCache, SpentOutputsCache spentOutputsCache) { this.logger = logger; this.sha256 = new SHA256Managed(); this.rules = rules; this.blockHeaderCache = blockHeaderCache; this.blockCache = blockCache; this.spentTransactionsCache = spentTransactionsCache; this.spentOutputsCache = spentOutputsCache; this.chainStateMonitor = new ChainStateMonitor(this.logger); this.scriptValidator = new ScriptValidator(this.logger, this.rules); this.chainStateMonitor.Subscribe(this.scriptValidator); this.chain = chain; this.chainStateBuilderStorage = kernel.Get <IChainStateBuilderStorage>(new ConstructorArgument("parentUtxo", parentUtxo.Storage)); this.spentTransactions = ImmutableList.CreateBuilder <KeyValuePair <UInt256, SpentTx> >(); this.spentOutputs = ImmutableList.CreateBuilder <KeyValuePair <TxOutputKey, TxOutput> >(); this.stats = new BuilderStats(); }