Пример #1
0
 public void BeginTransaction(
     out UncommittedRecord <ChainedHeader> chainTip,
     out UncommittedRecord <int> unspentTxCount,
     out UncommittedRecord <int> unspentOutputCount,
     out UncommittedRecord <int> totalTxCount,
     out UncommittedRecord <int> totalInputCount,
     out UncommittedRecord <int> totalOutputCount,
     out UncommittedRecord <ImmutableSortedDictionary <UInt256, ChainedHeader> .Builder> headers,
     out UncommittedRecord <ImmutableSortedDictionary <UInt256, UnspentTx> .Builder> unspentTransactions,
     out UncommittedRecord <ImmutableSortedDictionary <TxOutputKey, TxOutput> .Builder> unspentTxOutputs,
     out UncommittedRecord <ImmutableDictionary <int, BlockSpentTxes> .Builder> blockSpentTxes,
     out UncommittedRecord <ImmutableDictionary <UInt256, IImmutableList <UnmintedTx> > .Builder> blockUnmintedTxes)
 {
     lock (this.lockObject)
     {
         chainTip            = this.chainTip.AsUncommitted();
         unspentTxCount      = this.unspentTxCount.AsUncommitted();
         unspentOutputCount  = this.unspentOutputCount.AsUncommitted();
         totalTxCount        = this.totalTxCount.AsUncommitted();
         totalInputCount     = this.totalInputCount.AsUncommitted();
         totalOutputCount    = this.totalOutputCount.AsUncommitted();
         headers             = this.headers.AsUncommitted(x => x.ToImmutable().ToBuilder());
         unspentTransactions = this.unspentTransactions.AsUncommitted(x => x.ToImmutable().ToBuilder());
         unspentTxOutputs    = this.unspentTxOutputs.AsUncommitted(x => x.ToImmutable().ToBuilder());
         blockSpentTxes      = this.blockSpentTxes.AsUncommitted(x => x.ToImmutable().ToBuilder());
         blockUnmintedTxes   = this.blockUnmintedTxes.AsUncommitted(x => x.ToImmutable().ToBuilder());
     }
 }
Пример #2
0
        public MemoryChainStateStorage(ChainedHeader chainTip = null, int?unspentTxCount = null, int?totalTxCount = null, int?totalInputCount = null, int?totalOutputCount = null, int?unspentOutputCount = null, ImmutableSortedDictionary <UInt256, ChainedHeader> headers = null, ImmutableSortedDictionary <UInt256, UnspentTx> unspentTransactions = null, ImmutableDictionary <int, BlockSpentTxes> blockSpentTxes = null, ImmutableDictionary <UInt256, IImmutableList <UnmintedTx> > blockUnmintedTxes = null)
        {
            this.chainTip = CommittedRecord <ChainedHeader> .Initial(chainTip);

            this.unspentTxCount = CommittedRecord <int> .Initial(unspentTxCount ?? 0);

            this.unspentOutputCount = CommittedRecord <int> .Initial(unspentOutputCount ?? 0);

            this.totalTxCount = CommittedRecord <int> .Initial(totalTxCount ?? 0);

            this.totalInputCount = CommittedRecord <int> .Initial(totalInputCount ?? 0);

            this.totalOutputCount = CommittedRecord <int> .Initial(totalOutputCount ?? 0);

            this.headers = CommittedRecord <ImmutableSortedDictionary <UInt256, ChainedHeader> .Builder> .Initial(
                headers?.ToBuilder() ?? ImmutableSortedDictionary.CreateBuilder <UInt256, ChainedHeader>());

            this.unspentTransactions = CommittedRecord <ImmutableSortedDictionary <UInt256, UnspentTx> .Builder> .Initial(
                unspentTransactions?.ToBuilder() ?? ImmutableSortedDictionary.CreateBuilder <UInt256, UnspentTx>());

            this.unspentTxOutputs = CommittedRecord <ImmutableSortedDictionary <TxOutputKey, TxOutput> .Builder> .Initial(
                ImmutableSortedDictionary.CreateBuilder <TxOutputKey, TxOutput>());

            this.blockSpentTxes = CommittedRecord <ImmutableDictionary <int, BlockSpentTxes> .Builder> .Initial(
                blockSpentTxes?.ToBuilder() ?? ImmutableDictionary.CreateBuilder <int, BlockSpentTxes>());

            this.blockUnmintedTxes = CommittedRecord <ImmutableDictionary <UInt256, IImmutableList <UnmintedTx> > .Builder> .Initial(
                blockUnmintedTxes?.ToBuilder() ?? ImmutableDictionary.CreateBuilder <UInt256, IImmutableList <UnmintedTx> >());
        }
        public MemoryUnconfirmedTxesStorage()
        {
            this.chainTip = CommittedRecord <ChainedHeader> .Initial(null);

            this.unconfirmedTxCount = CommittedRecord <int> .Initial(0);

            this.unconfirmedTxes = CommittedRecord <ImmutableDictionary <UInt256, UnconfirmedTx> .Builder> .Initial(
                ImmutableDictionary.CreateBuilder <UInt256, UnconfirmedTx>());

            this.unconfirmedTxesByPrevTxOutputKey = CommittedRecord <ImmutableDictionary <TxOutputKey, ImmutableDictionary <UInt256, UnconfirmedTx> .Builder> .Builder> .Initial(
                ImmutableDictionary.CreateBuilder <TxOutputKey, ImmutableDictionary <UInt256, UnconfirmedTx> .Builder>());
        }
 public void BeginTransaction(
     out UncommittedRecord <ChainedHeader> chainTip,
     out UncommittedRecord <int> unconfirmedTxCount,
     out UncommittedRecord <ImmutableDictionary <UInt256, UnconfirmedTx> .Builder> unconfirmedTxes,
     out UncommittedRecord <ImmutableDictionary <TxOutputKey, ImmutableDictionary <UInt256, UnconfirmedTx> .Builder> .Builder> unconfirmedTxesByPrevTxOutputKey)
 {
     lock (this.lockObject)
     {
         chainTip           = this.chainTip.AsUncommitted();
         unconfirmedTxCount = this.unconfirmedTxCount.AsUncommitted();
         unconfirmedTxes    = this.unconfirmedTxes.AsUncommitted(x => x.ToImmutable().ToBuilder());
         unconfirmedTxesByPrevTxOutputKey = this.unconfirmedTxesByPrevTxOutputKey.AsUncommitted(x => x.ToImmutable().ToBuilder());
     }
 }