public BitcoinPeerInfo(IPEndPoint ipEndpoint, VersionMessage versionMessage) { IpEndpoint = ipEndpoint; VersionMessage = versionMessage; }
private VersionMessage CreateVersionMessage() { long timestamp = UnixTime.ToTimestamp(SystemTime.UtcNow); IPEndPoint remoteEndPoint = conn.RemoteEndPoint; IPEndPoint localEndPoint = conn.LocalEndPoint; //todo: should it always be a public address ? VersionMessage message = new VersionMessage( UserAgent, protocolVersion, Services, timestamp, Nonce, localEndPoint, remoteEndPoint, StartHeight, AcceptBroadcasts); return message; }
public static VersionMessage Read(BitcoinStreamReader reader) { int protocolVersion = reader.ReadInt32(); ulong services = reader.ReadUInt64(); long timestamp = reader.ReadInt64(); ulong remoteServices = reader.ReadUInt64(); IPAddress remoteAddress = reader.ReadAddress(); ushort remotePort = reader.ReadUInt16BigEndian(); IPEndPoint remoteEndpoint = new IPEndPoint(remoteAddress, remotePort); ulong localServices = reader.ReadUInt64(); IPAddress localAddress = reader.ReadAddress(); ushort localPort = reader.ReadUInt16BigEndian(); IPEndPoint localEndpoint = new IPEndPoint(localAddress, localPort); ulong nonce = reader.ReadUInt64(); string userAgent = reader.ReadText(MaxUserAgentLength); int startHeight = reader.ReadInt32(); //todo: support clients that don't send relay bit bool acceptBroadcasts = reader.ReadBoolean(); VersionMessage versionMessage = new VersionMessage( userAgent, protocolVersion, services, timestamp, nonce, localEndpoint, remoteEndpoint, startHeight, acceptBroadcasts); versionMessage.LocalServices = localServices; versionMessage.RemoteServices = remoteServices; return versionMessage; }