public MemoryChainStateBuilderStorage(IChainStateStorage parentUtxo) { if (parentUtxo is MemoryChainStateStorage) { this.unspentTransactions = ((MemoryChainStateStorage)parentUtxo).UnspentTransactions.ToBuilder(); this.unspentOutputs = ((MemoryChainStateStorage)parentUtxo).UnspentOutputs.ToBuilder(); } else { this.unspentTransactions = ImmutableDictionary.CreateRange(parentUtxo.UnspentTransactions()).ToBuilder(); this.unspentOutputs = ImmutableDictionary.CreateRange(parentUtxo.UnspentOutputs()).ToBuilder(); } }
public ChainStateBuilderStorage(string baseDirectory, IChainStateStorage parentUtxo, Logger logger) { this.isSnapshot = false; this.logger = logger; this.jetDirectory = Path.Combine(baseDirectory, "ChainState"); this.jetDatabase = Path.Combine(this.jetDirectory, "ChainState.edb"); //TODO currently configured by PersistentDictionary //SystemParameters.DatabasePageSize = 8192; //var maxDbSizeInPages = 500.MILLION() / SystemParameters.DatabasePageSize; this.jetInstance = CreateInstance(this.jetDirectory); this.jetInstance.Init(); CreateDatabase(this.jetDatabase, this.jetInstance); OpenDatabase(this.jetDatabase, this.jetInstance, false /*readOnly*/, out this.jetSession, out this.utxoDbId, out this.globalTableId, out this.blockHashColumnId, out this.unspentTxTableId, out this.txHashColumnId, out this.confirmedBlockHashColumnId, out this.outputStatesColumnId, out this.unspentTxOutputsTableId, out this.txOutputKeyColumnId, out this.txOutputSmallColumnId, out this.txOutputLargeColumnId, out this.outputScriptHashColumnId); this.BlockHash = parentUtxo.BlockHash; foreach (var unspentTx in parentUtxo.UnspentTransactions()) { this.AddTransaction(unspentTx.Key, unspentTx.Value); } foreach (var unspentOutput in parentUtxo.UnspentOutputs()) { this.AddOutput(unspentOutput.Key, unspentOutput.Value); } }
internal Utxo(IChainStateStorage chainStateStorage) { this.chainStateStorage = chainStateStorage; }