/// <summary> /// Generates a new local nonce and add it to the list of known local nonces. /// </summary> public void AddLocalNonce() { /// thread safety concerns: currently the process of allocating new nonces is not thread safe but server are generated synchronously, /// this mean that we shouldn't have thread problems on this. ulong localNonce = _randomNumberGenerator.GetUint64(); _logger.LogDebug("Generated new local nonce {LocalNonce}", localNonce); _localNonces.Add(localNonce); }
private VersionMessage CreateVersionMessage() { var version = new VersionMessage { Version = KnownVersion.CurrentVersion, Timestamp = _dateTimeProvider.GetTimeOffset(), Nonce = _randomNumberGenerator.GetUint64(), UserAgent = _userAgentBuilder.GetUserAgent(), }; return(version); }
private VersionMessage CreateVersionMessage() { var version = new VersionMessage { Version = KnownVersion.CurrentVersion, /// TODO: it's part of the node settings and depends on the configured features/shards, shouldn't be hard coded /// if/when pruned will be implemented, remember to remove Network service flag /// ref: https://github.com/bitcoin/bitcoin/blob/99813a9745fe10a58bedd7a4cb721faf14f907a4/src/init.cpp#L1671-L1680 Services = (ulong)_localServiceProvider.GetServices(), Timestamp = _dateTimeProvider.GetTimeOffset(), ReceiverAddress = new Types.NetworkAddressNoTime { EndPoint = PeerContext.RemoteEndPoint }, SenderAddress = new Types.NetworkAddressNoTime { EndPoint = PeerContext.PublicEndPoint ?? PeerContext.LocalEndPoint }, Nonce = _randomNumberGenerator.GetUint64(), UserAgent = _userAgentBuilder.GetUserAgent(), StartHeight = _headersTree.GetTip().Height, Relay = true //this.IsRelay, TODO: it's part of the node settings }; return(version); }