Exemple #1
0
        public ChainStateBuilder(Logger logger, IBlockchainRules rules, CoreStorage coreStorage)
        {
            this.logger      = logger;
            this.sha256      = new SHA256Managed();
            this.rules       = rules;
            this.coreStorage = coreStorage;

            this.blockValidator = new BlockValidator(this.coreStorage, this.rules, this.logger);

            this.chainStateCursorHandle = coreStorage.OpenChainStateCursor();
            this.chainStateCursor       = this.chainStateCursorHandle.Item;

            this.chain       = new ChainBuilder(chainStateCursor.ReadChain());
            this.utxoBuilder = new UtxoBuilder(chainStateCursor, logger);

            this.commitLock = new ReaderWriterLockSlim();

            this.stats = new BuilderStats();
        }
Exemple #2
0
        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();
        }