예제 #1
0
 /// <summary>
 ///   Called every time that the Kademlia node notice a new node in the network. Can be
 ///   either because the new node make a RPC request or was found in a node lookUp procedure.
 /// </summary>
 /// <param name = "nodeIdentifier">New node identifier.</param>
 public virtual void RegisterNewNode(NodeIdentifier <TKey> nodeIdentifier)
 {
     if (!RoutingTable.Contains(nodeIdentifier))
     {
         RoutingTable.Add(nodeIdentifier);
     }
 }
예제 #2
0
        /// <summary>
        ///   this node joins to the network, process:
        ///   1. add know nodes to this nodes k-bucket
        ///   2. perform a NodeLookUp
        /// </summary>
        /// <remarks>
        ///   After FindNode is called the <paramref name = "knownNodesIdentifiers" /> knows about
        ///   the existence of this node...
        /// </remarks>
        /// <param name = "knownNodesIdentifiers"></param>
        public void JoinToNetwork(IEnumerable <NodeIdentifier <TKey> > knownNodesIdentifiers)
        {
            // 1. add known items to the routing table
            foreach (var nodeIdentifier in knownNodesIdentifiers)
            {
                RoutingTable.Add(nodeIdentifier);
            }

            // 2. Perform a Node Look up on the own node id
            JoinToNetwork();
        }