Add a Priority Queue for Most Common Contacts #481

Merged
dan merged 4 commits from priority into master 2022-12-07 21:37:30 +00:00
Owner
No description provided.
dan was assigned by sarah 2022-12-07 19:34:18 +00:00
sarah added 2 commits 2022-12-07 19:34:18 +00:00
Member
Drone Build Status: success https://build.openprivacy.ca/cwtch.im/cwtch/90
dan reviewed 2022-12-07 20:44:13 +00:00
@ -179,0 +180,4 @@
// do priority connections first...
for connectingCount < cr.maxTorCircuitsPending() && len(cr.priorityQueue.queue) > 0 {
for {
Owner

why the nested inner for loop?

why the nested inner for loop?
dan marked this conversation as resolved
@ -182,3 +198,1 @@
if contact.state == connections.DISCONNECTED {
cr.publishConnectionRequest(contact)
connectingCount++
for {
Owner

ditto

ditto
@ -826,3 +826,3 @@
lastSeen = cp.GetConversationLastSeenTime(ci.ID)
}
cp.eventBus.Publish(event.NewEvent(event.QueuePeerRequest, map[event.Field]string{event.RemotePeer: handle, event.LastSeen: lastSeen.Format(time.RFC3339Nano)}))
if !ci.ACL[ci.Handle].Blocked && ci.Accepted {
Owner

eek good catch thanks

eek good catch thanks
dan reviewed 2022-12-07 20:45:46 +00:00
@ -179,0 +182,4 @@
for connectingCount < cr.maxTorCircuitsPending() && len(cr.priorityQueue.queue) > 0 {
for {
contact := cr.priorityQueue.dequeue()
if contact == nil {
Owner

you shouldnt need this if it's just in the outer loop, as there's a reoccuring check the queue len is > 0

you shouldnt need this if it's just in the outer loop, as there's a reoccuring check the queue len is > 0
dan reviewed 2022-12-07 20:46:42 +00:00
@ -223,1 +247,3 @@
cr.pendingQueue.insert(contact)
// prioritize connections made in the last week
if time.Since(contact.lastSeen).Hours() < 168 {
Owner

define 168 as something like PriorityQueueTimeSinceQualifierHours or... umm.. something less unwordly so we can tweak it in one place instead of two

define 168 as something like PriorityQueueTimeSinceQualifierHours or... umm.. something less unwordly so we can tweak it in one place instead of two
dan marked this conversation as resolved
sarah added 1 commit 2022-12-07 20:56:22 +00:00
continuous-integration/drone/pr Build is passing Details
5ef2f6f94c
Make priority queue criteria a const. Remove inner loop
Member
Drone Build Status: success https://build.openprivacy.ca/cwtch.im/cwtch/91
dan requested changes 2022-12-07 21:17:31 +00:00
@ -179,0 +183,4 @@
// do priority connections first...
for connectingCount < cr.maxTorCircuitsPending() && len(cr.priorityQueue.queue) > 0 {
contact := cr.priorityQueue.dequeue()
if contact == nil {
Owner

this shouldn't be needed, the outer loop checks len, so it should be redundant

this shouldn't be needed, the outer loop checks len, so it should be redundant
@ -179,0 +190,4 @@
if contact.state == connections.DISCONNECTED {
cr.publishConnectionRequest(contact)
connectingCount++
break
Owner

this breaks the priority queue, it'll pull one item off it then break

this breaks the priority queue, it'll pull one item off it then break
sarah added 1 commit 2022-12-07 21:23:24 +00:00
continuous-integration/drone/pr Build is passing Details
continuous-integration/drone/push Build is pending Details
667fc15294
Remove Queue Breaks
dan approved these changes 2022-12-07 21:32:39 +00:00
Member
Drone Build Status: success https://build.openprivacy.ca/cwtch.im/cwtch/92
dan merged commit 667fc15294 into master 2022-12-07 21:37:30 +00:00
Sign in to join this conversation.
No description provided.