Ejemplo n.º 1
0
Archivo: DPoS.cs Proyecto: wyk125/AElf
        public async Task Update()
        {
            Helper.LogDPoSInformation(await BlockChain.GetCurrentBlockHeightAsync());

            if (ConsensusMemory == Helper.CurrentRoundNumber.Value)
            {
                return;
            }

            // Dispose previous observer.
            if (ConsensusDisposable != null)
            {
                ConsensusDisposable.Dispose();
                _logger?.Trace("Disposed previous consensus observables list. Will update DPoS information.");
            }

            // Update observer.
            var address = _nodeKeyPair.Address.DumpHex().RemoveHexPrefix();
            var miners  = Helper.Miners;

            if (!miners.Nodes.Contains(address))
            {
                return;
            }

            var blockProducerInfoOfCurrentRound = Helper[address];

            ConsensusDisposable = AElfDPoSObserver.SubscribeAElfDPoSMiningProcess(blockProducerInfoOfCurrentRound,
                                                                                  Helper.ExtraBlockTimeSlot);

            // Update current round number.
            ConsensusMemory = Helper.CurrentRoundNumber.Value;
        }
Ejemplo n.º 2
0
Archivo: DPoS.cs Proyecto: wyk125/AElf
 public void Stop()
 {
     ConsensusDisposable?.Dispose();
     _logger?.Trace("Mining stopped. Disposed previous consensus observables list.");
 }