This commit is contained in:
Tristan B. Kildaire 2021-01-29 19:49:39 +02:00
parent 8116861986
commit 7c82b938b8
1 changed files with 46 additions and 26 deletions

View File

@ -10,6 +10,32 @@ import std.socket : Address;
import core.thread : Thread; import core.thread : Thread;
/**
* Link manager
*
* Given a set of original DLink objects, it will open connections to them
* It also facilitates DConnection making a call to `.addLink` here when an
* inbound peering request comes in
*/
public final class DLinkManager
{
this(DServer server, DLink[] seedLinks)
{
}
}
/** /**
* Represents a server link * Represents a server link
* *
@ -99,38 +125,32 @@ public final class DMeyer
/* TODO: Open connections to all servers we are yet to open a connection to (check the `links` array) */ /* TODO: Open connections to all servers we are yet to open a connection to (check the `links` array) */
} }
/**
* Locks the link list
*/
private void openAllOutboundConnections()
{
}
/* Initialize locks */ /* Initialize locks */
private void initLocks() private void initLocks()
{ {
linksMutex = new Mutex(); linksMutex = new Mutex();
} }
// /* Attach a direct peer */ /**
// public void attachDirectPeer(DConnection peer) * Adds a peer to the links list
// { */
// /* TODO: Add to `directPeers` */ public void addLink(DLink newLink)
// linksMutex.lock(); {
/* Lock the list */
linksMutex.lock();
// links ~= new DLink(peer); /* Add the link */
// writeln("Attached direct peer: "~to!(string)(peer)); links ~= newLink;
// linksMutex.unlock();
// }
/* Get a list of all servers we know of */
// public DLink getLink(DConnection peer)
// {
// DLink link;
// linksMutex.lock();
// linksMutex.unlock();
// return link;
// }
/* Unlock the list */
linksMutex.unlock();
}
} }