Пример #1
0
 private void SendKnownAddresses(BitcoinEndpoint endpoint)
 {
     List<NetAddr> addresses = new List<NetAddr>();
     List<NodeConnection> currentConnections = connectionCollection.GetConnections();
     foreach (NodeConnection connection in currentConnections)
     {
         //todo: filter loopback addresses
         NetAddr addr = new NetAddr(
             //todo: use last message date instead
             (uint) connection.Endpoint.PeerInfo.VersionMessage.Timestamp,
             connection.Endpoint.PeerInfo.VersionMessage.Services,
             endpoint.PeerInfo.IpEndpoint.Address,
             (ushort) endpoint.PeerInfo.IpEndpoint.Port);
         addresses.Add(addr);
     }
     AddrMessage addrMessage = new AddrMessage(addresses.Take(AddrMessage.MaxAddressesPerMessage).ToArray());
     endpoint.WriteMessage(addrMessage);
 }
Пример #2
0
 private void SaveReceivedAddresses(AddrMessage addrMessage)
 {
     foreach (NetAddr addr in addrMessage.AddressList)
     {
         //todo: check timestamp in address?
         //todo: prioritize connections to port 8333
         addressCollection.Add(new NodeAddress(addr.Address, addr.Port));
     }
 }