Ejemplo n.º 1
0
        void HandleNodeResponse(NetworkPacket packet)
        {
            // Check that the packet is valid.
            if (networkPacketSwitch.VerifyPendingPacket(packet))
            {
                NodeInfoResponse nir = new NodeInfoResponse();
                nir.Deserialize(packet.Data);

               // DebugPrint("NodeResponse from " + packet.PublicKeySource + " : " + packet.Data.Length + " Bytes, Nodes : " + nir.TotalRequestedNodes, DisplayType.Warning);

                foreach (NodeDataEntity nde in nir.RequestedNodes)
                {
                    PendingNodesToBeFetched.Enqueue(nde);
                }
            }
            else
            {
                DebugPrint("Packet VER FAILED : HandleNodeResponse().", DisplayType.Warning);
            }
        }
Ejemplo n.º 2
0
        void HandleNodeRequest(NetworkPacket packet)
        {
            NodeInfoRequest nir = new NodeInfoRequest();
            nir.Deserialize(packet.Data);

               // DebugPrint("NodeRequest from " + packet.PublicKeySource + " Nodes : " + nir.TotalRequestedNodes, DisplayType.Warning);

            if ((Common.LSYNC_MAX_REQUESTED_NODES >= nir.TotalRequestedNodes) &&
                (nir.TotalRequestedNodes == nir.RequestedNodesAdresses.Count))
            {
                NodeInfoResponse responseData = new NodeInfoResponse();

                foreach (Hash nodeAddress in nir.RequestedNodesAdresses)
                {
                    ListTreeNode ltn;
                    if (LedgerTree.TraverseToNode(nodeAddress, out ltn) == TraverseResult.Success)
                    {
                        responseData.Add(new NodeDataEntity(ltn));
                    }
                }

                NetworkPacket response = new NetworkPacket(nodeConfig.PublicKey, PacketType.TPT_LSYNC_NODE_RESPONSE,
                   responseData.Serialize(), packet.Token);

                networkPacketSwitch.AddToQueue(packet.PublicKeySource, response);
            }
        }