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); }
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; }
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; }
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; }