/// <summary>Create a new node in the public overlay and a matching one in /// the private overlay.</summary> override public Node AddNode() { Node snode = _shared_overlay.AddNode(); NodeMapping snm = _shared_overlay.Nodes[snode.Address]; // Must do this to remove it after successfully creating the new node Node.StateChangeHandler add_node = null; // Delayed add, removes ~15 seconds off bootstrapping time add_node = delegate(Node n, Node.ConnectionState cs) { if (cs != Node.ConnectionState.Connected) { return; } snm.Node.StateChangeEvent -= add_node; Node node = AddNode(snm.ID, snode.Address as AHAddress); EdgeListener el = new SubringEdgeListener(snode, node); if (_secure_edges) { NodeMapping pnm = Nodes[node.Address] as NodeMapping; el = new SecureEdgeListener(el, pnm.SO); } node.AddEdgeListener(el); node.AddTADiscovery(new DhtDiscovery(node as StructuredNode, snm.Dht, snm.Node.Realm, snm.DhtProxy)); CurrentNetworkSize--; }; // Check will return true, since the Node is unregistered CurrentNetworkSize++; snm.Node.StateChangeEvent += add_node; return(snode); }
/// <summary>Create a PrivateNode given a shared node and a node_config.</summary> protected void CreatePrivateNode(ApplicationNode shared, NodeConfig node_config) { // Not necessary, but its nice to map the public and private overlay nodes node_config.NodeAddress = shared.Node.Address.ToString(); ApplicationNode app_node = CreateNode(node_config); EdgeListener el = new SubringEdgeListener(shared.Node, app_node.Node); if (node_config.Security.SecureEdgesEnabled) { el = new SecureEdgeListener(el, app_node.SecurityOverlord); } app_node.Node.AddEdgeListener(el); Discovery d = new DhtDiscovery(app_node.Node as StructuredNode, shared.Dht, shared.Node.Realm, shared.DhtProxy); app_node.Node.AddTADiscovery(d); shared.PrivateNode = app_node; }