public LinkNode(OpLink link, LinkTree parent) { Link = link; ParentView = parent; Trust = parent.Trust; Locations = parent.Core.Locations; UpdateStatus(); }
public PlanNode( ScheduleView view, OpLink link, bool local) { View = view; Link = link; if (local) Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold); SubItems.Add(new BlockRow(this)); UpdateName(); UpdateBlock(); }
private OpLink TraverseUp(OpLink link, int distance) { // needs to get unconfiremd ids so unconfirmed above / below are updated with link status if (distance == 0) return link; int traverse = 0; OpLink uplink = link.GetHigher(false); while (uplink != null) { traverse++; if (traverse == distance) return uplink; uplink = uplink.GetHigher(false); } return null; }
private void RemoveDownlink(OpLink downlink) { if (Downlinks.Contains(downlink)) Downlinks.Remove(downlink); // uplink requests are invalidated on verion update also // not the local ones, but the ones this link issued to previous uplink foreach (UplinkRequest request in Requests) if (request.KeyID == downlink.UserID) { Requests.Remove(request); break; } }
private void LinkupRequest(OpLink remoteLink) { // create uplink request, publish UplinkRequest request = new UplinkRequest(); request.ProjectID = remoteLink.Project; request.LinkVersion = LocalTrust.File.Header.Version; request.TargetVersion = remoteLink.Trust.File.Header.Version; request.Key = LocalTrust.File.Key; request.KeyID = LocalTrust.UserID; request.Target = remoteLink.Trust.File.Key; request.TargetID = remoteLink.UserID; byte[] signed = SignedData.Encode(Network.Protocol, Core.User.Settings.KeyPair, request); if(Network.Established) Store.PublishNetwork(request.TargetID, ServiceID, DataTypeFile, signed); // store locally Process_UplinkReq(null, new SignedData(Network.Protocol, Core.User.Settings.KeyPair, request), request); // publish at neighbors so they are aware of request status List<LocationData> locations = new List<LocationData>(); GetLocs(Core.UserID, remoteLink.Project, 1, 1, locations); GetLocsBelow(Core.UserID, remoteLink.Project, locations); Store.PublishDirect(locations, request.TargetID, ServiceID, DataTypeFile, signed); }
private void GetLinkLocs(OpLink parent, int depth, List<LocationData> locations) { AddLinkLocations(parent, locations); if (depth > 0) foreach (OpLink child in parent.Downlinks) if (!parent.IsLoopedTo(child)) GetLinkLocs(child, depth - 1, locations); }
void DoToBranch(Action<OpLink> action, OpLink link, int depth) { action(link); if (depth > 0) foreach (OpLink downlink in link.Downlinks) DoToBranch(action, downlink, depth - 1); }
public void Reset() { // find nodes we're uplinked to and remove ourselves from their downlink list ResetUplink(); // only clear downlinks that are no longer uplinked to us List<OpLink> remove = new List<OpLink>(); foreach (OpLink downlink in Downlinks) if (downlink.Uplink == null || downlink.Uplink != this) remove.Add(downlink); foreach (OpLink downlink in remove) Downlinks.Remove(downlink); Active = false; Uplink = null; Titles.Clear(); Confirmed.Clear(); }
private void AddRoot(OpLink link) { ThreadedList<OpLink> roots = null; if (!ProjectRoots.SafeTryGetValue(link.Project, out roots)) { roots = new ThreadedList<OpLink>(); ProjectRoots.SafeAdd(link.Project, roots); } if (!roots.SafeContains(link)) // possible it wasnt removed above because link might not be part of project locally but others think it does (uplink) roots.SafeAdd(link); }
private bool AddLinkLocations(OpLink link, List<LocationData> locations) { List<ClientInfo> clients = Core.Locations.GetClients(link.UserID); foreach (ClientInfo info in clients) { if (info.Data.UserID == Core.UserID && info.Data.Source.ClientID == Core.Network.Local.ClientID) continue; if (!locations.Contains(info.Data)) locations.Add(info.Data); } return (locations.Count > 0); }
private OpLink GetTreeHigher(OpLink link) { if (link.LoopRoot != null) return link.LoopRoot; return link.GetHigher(false); }
private PlanNode CreateNode(OpLink link) { PlanNode node = new PlanNode(this, link, link.UserID == UserID); NodeMap[link.UserID] = node; return node; }
private void SetupRoot(OpLink root) { LinkNode node = CreateNode(root); LoadRoot(node); List<ulong> uplinks = Trust.GetUnconfirmedUplinkIDs(Core.UserID, Project); uplinks.Add(Core.UserID); ExpandPath(node, uplinks); node.Expand(); // expand first level of roots regardless }
public void AddProject(uint project, bool active) { OpLink link = GetLink(project); if (link == null) { link = new OpLink(this, project); Links.Add(project, link); } // setting project to non-active has to be done manually if(!link.Active) // only allow false->true, not true->false link.Active = active; }
public bool IsLoopedTo(OpLink test) { if (test.LoopRoot != null && test.LoopRoot == LoopRoot) return true; return false; }
public bool IsLooped(OpLink local) { // this function is the same as getUplinkIDs with minor mods List<ulong> list = new List<ulong>(); OpLink uplink = local.GetHigher(false); while (uplink != null) { // if loop lead back to self, link is in loop if (uplink == local) return true; // if there is a loop higher up, but link is not in it, return if (list.Contains(uplink.UserID)) return false; list.Add(uplink.UserID); uplink = uplink.GetHigher(false); } return false; }
private LinkNode CreateNode(OpLink link) { LinkNode node = new LinkNode(link, this); NodeMap[link.UserID] = node; return node; }