Exemplo n.º 1
0
 public void AddKnownPeer(PeerData peer)
 {
     if (peer.CheckValidity())
     {
         // in case of two: use the more recent one
         KnownPeers.AddOrUpdate(peer.PubKey, peer, (ok, ov) => (ov.TimeStamp > peer.TimeStamp) ? ov : peer);
     }
     else
     {
         Print("PeerData with invalid signature.");
     }
 }
Exemplo n.º 2
0
        public void Deserialize(byte[] data)
        {
            List<ProtocolDataType> PDTs = ProtocolPackager.UnPackRaw(data);
            knownPeers = new ConcurrentDictionary<Hash, PeerData>();

            for (int i = 0; i < PDTs.Count; i++)
            {
                byte[] tmpData = new byte[0];
                ProtocolPackager.UnpackByteVector(PDTs[i], 0, ref tmpData);
                if (tmpData.Length > 0)
                {
                    PeerData conn = new PeerData();
                    conn.Deserialize(tmpData);
                    knownPeers[conn.PubKey] = conn;
                }
            }
        }