Beispiel #1
0
        public void HintBlock(Keccak hash, long number, Node node)
        {
            if (!_pool.TryFind(node.Id, out PeerInfo peerInfo))
            {
                if (_logger.IsDebug)
                {
                    _logger.Debug($"Received a block hint from an unknown {node:c}, ignoring");
                }
                return;
            }

            if (number > _blockTree.BestKnownNumber + 8)
            {
                return;
            }

            if (number > peerInfo.HeadNumber)
            {
                if (_logger.IsTrace)
                {
                    _logger.Trace($"HINT Updating header of {peerInfo} from {peerInfo.HeadNumber} {peerInfo.TotalDifficulty} to {number}");
                }
                peerInfo.HeadNumber = number;
                peerInfo.HeadHash   = hash;

                lock (_recentlySuggested)
                {
                    if (_recentlySuggested.Get(hash) != null)
                    {
                        return;
                    }

                    /* do not add as this is a hint only */
                }

                if (!_blockTree.IsKnownBlock(number, hash))
                {
                    _pool.RefreshTotalDifficulty(peerInfo, hash);
                    _synchronizer.RequestSynchronization(SyncTriggerType.NewNearBlock);
                }
            }
        }