public void Initialize() { var utxoHash = _utxoSet.GetBlockHashAsync().GetAwaiter().GetResult(); while (true) { _Tip = Chain.GetBlock(utxoHash); if (_Tip != null) { break; } utxoHash = _utxoSet.Rewind().GetAwaiter().GetResult(); } Puller.SetLocation(Tip); bip9 = new ThresholdConditionCache(_Validator.ConsensusParams); }
public override async Task <uint256> Rewind() { if (_InnerBlockHash == null) { _InnerBlockHash = await _Inner.GetBlockHashAsync().ConfigureAwait(false); } var innerHash = _InnerBlockHash; Task <uint256> rewinding = null; using (_Lock.LockWrite()) { WaitOngoingTasks(); if (_BlockHash == _InnerBlockHash) { _Unspents.Clear(); } if (_Unspents.Count != 0) { //More intelligent version can restore without throwing away the cache. (as the rewind data is in the cache) _Unspents.Clear(); _BlockHash = _InnerBlockHash; return(_BlockHash); } else { rewinding = _Inner.Rewind(); _Rewinding = rewinding; } } var h = await rewinding.ConfigureAwait(false); using (_Lock.LockWrite()) { _InnerBlockHash = h; _BlockHash = h; } return(h); }
public override async Task <uint256> Rewind() { if (innerBlockHash == null) { innerBlockHash = await inner.GetBlockHashAsync().ConfigureAwait(false); } Task <uint256> rewindinginner = null; using (this.lockobj.LockWrite()) { WaitOngoingTasks(); if (blockHash == innerBlockHash) { this.unspents.Clear(); } if (this.unspents.Count != 0) { //More intelligent version can restore without throwing away the cache. (as the rewind data is in the cache) this.unspents.Clear(); blockHash = innerBlockHash; return(blockHash); } else { rewindinginner = inner.Rewind(); this.rewinding = rewindinginner; } } var h = await rewindinginner.ConfigureAwait(false); using (lockobj.LockWrite()) { innerBlockHash = h; blockHash = h; } return(h); }