Пример #1
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);
            }
        }
Пример #2
0
        public PassthroughUnboundedCache(IUnboundedCache <TKey, TValue> cache)
        {
            this.cache = cache;

            this.onMissing = (blockHash) => { var handler = this.OnMissing; if (handler != null)
                                              {
                                                  handler(blockHash);
                                              }
            };
            this.cache.OnMissing += this.OnMissing;
        }
Пример #3
0
 public TransactionCache(IUnboundedCache <UInt256, Transaction> cache)
     : base(cache)
 {
 }