Esempio n. 1
0
        public PassthroughBoundedCache(IBoundedCache <TKey, TValue> cache)
            : base(cache)
        {
            this.cache = cache;

            this.onAddition = (blockHash, TValue) => { var handler = this.OnAddition; if (handler != null)
                                                       {
                                                           handler(blockHash, TValue);
                                                       }
            };
            this.onModification = (blockHash, TValue) => { var handler = this.OnModification; if (handler != null)
                                                           {
                                                               handler(blockHash, TValue);
                                                           }
            };
            this.onRemoved = (blockHash) => { var handler = this.OnRemoved; if (handler != null)
                                              {
                                                  handler(blockHash);
                                              }
            };

            this.cache.OnAddition     += this.onAddition;
            this.cache.OnModification += this.OnModification;
            this.cache.OnRemoved      += this.OnRemoved;
        }
Esempio n. 2
0
        public override void Load()
        {
            var blockHeaderStorage = this.Kernel.Get <IBlockHeaderStorage>();

            this.blockHeaderCache = this.Kernel.Get <BoundedFullCache <UInt256, BlockHeader> >(
                new ConstructorArgument("name", "Block Header Cache"), new ConstructorArgument("dataStorage", blockHeaderStorage));

            var chainedHeaderStorage = this.Kernel.Get <IChainedHeaderStorage>();

            this.chainedHeaderCache = this.Kernel.Get <BoundedFullCache <UInt256, ChainedHeader> >(
                new ConstructorArgument("name", "Chained Block Cache"), new ConstructorArgument("dataStorage", chainedHeaderStorage));

            var blockStorage = this.Kernel.Get <IBlockStorage>();

            this.blockCache = this.Kernel.Get <BoundedCache <UInt256, Block> >(
                new ConstructorArgument("name", "Block Cache"), new ConstructorArgument("dataStorage", blockStorage));

            var blockTxHashesStorage = this.Kernel.Get <IBlockTxHashesStorage>();

            this.blockTxHashesCache = this.Kernel.Get <BoundedCache <UInt256, IImmutableList <UInt256> > >(
                new ConstructorArgument("name", "Block TX Hashes Cache"), new ConstructorArgument("dataStorage", blockTxHashesStorage));

            var transactionStorage = this.Kernel.Get <ITransactionStorage>();

            this.transactionCache = this.Kernel.Get <UnboundedCache <UInt256, Transaction> >(
                new ConstructorArgument("name", "Transaction Cache"), new ConstructorArgument("dataStorage", transactionStorage));

            var spentTransactionsStorage = this.Kernel.Get <ISpentTransactionsStorage>();

            this.spentTransactionsCache = this.Kernel.Get <BoundedCache <UInt256, IImmutableList <KeyValuePair <UInt256, SpentTx> > > >(
                new ConstructorArgument("name", "Spent Transactions Cache"), new ConstructorArgument("dataStorage", spentTransactionsStorage));

            var spentOutputsStorage = this.Kernel.Get <ISpentOutputsStorage>();

            this.spentOutputsCache = this.Kernel.Get <BoundedCache <UInt256, IImmutableList <KeyValuePair <TxOutputKey, TxOutput> > > >(
                new ConstructorArgument("name", "Spent Outputs Cache"), new ConstructorArgument("dataStorage", spentOutputsStorage));

            var invalidBlockStorage = this.Kernel.Get <IInvalidBlockStorage>();

            this.invalidBlockCache = this.Kernel.Get <BoundedCache <UInt256, string> >(
                new ConstructorArgument("name", "Invalid Block Cache"), new ConstructorArgument("dataStorage", invalidBlockStorage));

            this.Bind <BlockHeaderCache>().ToSelf().InSingletonScope().WithConstructorArgument(this.blockHeaderCache);
            this.Bind <ChainedHeaderCache>().ToSelf().InSingletonScope().WithConstructorArgument(this.chainedHeaderCache);
            this.Bind <BlockCache>().ToSelf().InSingletonScope().WithConstructorArgument(this.blockCache);
            this.Bind <BlockTxHashesCache>().ToSelf().InSingletonScope().WithConstructorArgument(this.blockTxHashesCache);
            this.Bind <TransactionCache>().ToSelf().InSingletonScope().WithConstructorArgument(this.transactionCache);
            this.Bind <SpentTransactionsCache>().ToSelf().InSingletonScope().WithConstructorArgument(this.spentTransactionsCache);
            this.Bind <SpentOutputsCache>().ToSelf().InSingletonScope().WithConstructorArgument(this.spentOutputsCache);
            this.Bind <InvalidBlockCache>().ToSelf().InSingletonScope().WithConstructorArgument(this.invalidBlockCache);

            if (false)
            {
                this.blockCache = this.Kernel.Get <BlockCompositeCache>();
                this.Bind <BlockCache>().ToSelf().InSingletonScope().WithConstructorArgument(this.blockCache);
            }
        }
Esempio n. 3
0
        public override void Load()
        {
            var networkPeerStorage = this.Kernel.Get <INetworkPeerStorage>();

            this.networkPeerCache = this.Kernel.Get <BoundedCache <NetworkAddressKey, NetworkAddressWithTime> >(
                new ConstructorArgument("name", "Network Peer Cache"), new ConstructorArgument("dataStorage", networkPeerStorage));

            this.Bind <NetworkPeerCache>().ToSelf().InSingletonScope().WithConstructorArgument(this.networkPeerCache);
        }
Esempio n. 4
0
 public NetworkPeerCache(IBoundedCache <NetworkAddressKey, NetworkAddressWithTime> cache)
     : base(cache)
 {
 }
Esempio n. 5
0
 public InvalidBlockCache(IBoundedCache <UInt256, string> cache)
     : base(cache)
 {
 }
Esempio n. 6
0
 public SpentOutputsCache(IBoundedCache <UInt256, IImmutableList <KeyValuePair <TxOutputKey, TxOutput> > > cache)
     : base(cache)
 {
 }
Esempio n. 7
0
 public SpentTransactionsCache(IBoundedCache <UInt256, IImmutableList <KeyValuePair <UInt256, SpentTx> > > cache)
     : base(cache)
 {
 }
Esempio n. 8
0
 public BlockTxHashesCache(IBoundedCache <UInt256, IImmutableList <UInt256> > cache)
     : base(cache)
 {
 }
Esempio n. 9
0
 public BlockCache(IBoundedCache <UInt256, Block> cache)
     : base(cache)
 {
 }
Esempio n. 10
0
 public ChainedHeaderCache(IBoundedCache <UInt256, ChainedHeader> cache)
     : base(cache)
 {
 }
Esempio n. 11
0
 public BlockHeaderCache(IBoundedCache <UInt256, BlockHeader> cache)
     : base(cache)
 {
 }