コード例 #1
0
        public bool Update(Chain chain, IndexedBlockStore store)
        {
            if (_CurrentChain == null || !chain.SameTip(_CurrentChain))
            {
                List <ChainedBlock> unprocessed = null;
                Accounts.Update(chain);
                if (_CurrentChain == null)
                {
                    _CurrentChain = chain.Clone(new StreamObjectStream <ChainChange>());
                    unprocessed   = chain.ToEnumerable(false).ToList();
                }
                else
                {
                    var fork = _CurrentChain.SetTip(chain.Tip);
                    unprocessed = _CurrentChain.EnumerateAfter(fork).ToList();
                }

                foreach (var block in unprocessed)
                {
                    ReceiveBlock(store.Get(block.HashBlock));
                }
                return(true);
            }
            return(false);
        }
コード例 #2
0
ファイル: BlockRepository.cs プロジェクト: nikropht/NBitcoin
 public BlockRepository(IndexedBlockStore blockStore, 
     IndexedBlockStore headerStore)
 {
     if(blockStore == null)
         throw new ArgumentNullException("blockStore");
     if(headerStore == null)
         throw new ArgumentNullException("headerStore");
     if(blockStore == headerStore)
         throw new ArgumentException("The two stores should be different");
     _BlockStore = blockStore;
     _HeaderStore = headerStore;
 }
コード例 #3
0
 public BlockRepository(IndexedBlockStore blockStore,
                        IndexedBlockStore headerStore)
 {
     if (blockStore == null)
     {
         throw new ArgumentNullException("blockStore");
     }
     if (headerStore == null)
     {
         throw new ArgumentNullException("headerStore");
     }
     if (blockStore == headerStore)
     {
         throw new ArgumentException("The two stores should be different");
     }
     _BlockStore  = blockStore;
     _HeaderStore = headerStore;
 }
コード例 #4
0
ファイル: Wallet.cs プロジェクト: nikropht/NBitcoin
        public bool Update(Chain chain, IndexedBlockStore store)
        {
            if(_CurrentChain == null || !chain.SameTip(_CurrentChain))
            {
                List<ChainedBlock> unprocessed = null;
                Accounts.Update(chain);
                if(_CurrentChain == null)
                {
                    _CurrentChain = chain.Clone(new StreamObjectStream<ChainChange>());
                    unprocessed = chain.ToEnumerable(false).ToList();
                }
                else
                {
                    var fork = _CurrentChain.SetTip(chain.Tip);
                    unprocessed = _CurrentChain.EnumerateAfter(fork).ToList();
                }

                foreach(var block in unprocessed)
                {
                    ReceiveBlock(store.Get(block.HashBlock));
                }
                return true;
            }
            return false;
        }