Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
7dc7ede6
Commit
7dc7ede6
authored
2 years ago
by
Benjamin Wenger
Browse files
Options
Downloads
Patches
Plain Diff
began impl sendtracker
parent
28a1e0f4
No related branches found
No related tags found
4 merge requests
!510
Release
,
!419
rewrote the health tracker to both consider if there are waiting rounds and...
,
!372
implemented the send tracker
,
!340
Project/channels
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
channels/sendTracker.go
+133
-0
133 additions, 0 deletions
channels/sendTracker.go
with
133 additions
and
0 deletions
channels/sendTracker.go
0 → 100644
+
133
−
0
View file @
7dc7ede6
package
channels
import
(
"gitlab.com/elixxir/client/cmix"
"gitlab.com/elixxir/client/cmix/rounds"
cryptoChannel
"gitlab.com/elixxir/crypto/channel"
"gitlab.com/xx_network/primitives/id"
"sync"
"time"
)
type
trackedRound
struct
{
msgID
cryptoChannel
.
MessageID
channelID
*
id
.
ID
}
type
trackedMessage
struct
{
roundID
id
.
Round
channelID
*
id
.
ID
}
type
sendTracker
struct
{
byRound
map
[
id
.
Round
][]
trackedRound
byMessageID
map
[
cryptoChannel
.
MessageID
]
trackedMessage
mux
sync
.
Mutex
em
EventModel
myUsername
string
net
Client
}
func
(
sr
*
sendTracker
)
Send
(
channelID
*
id
.
ID
,
messageID
cryptoChannel
.
MessageID
,
myUsername
string
,
text
string
,
timestamp
time
.
Time
,
lease
time
.
Duration
,
round
rounds
.
Round
)
{
}
func
(
sr
*
sendTracker
)
handleSend
(
channelID
*
id
.
ID
,
messageID
cryptoChannel
.
MessageID
,
round
rounds
.
Round
)
{
sr
.
mux
.
Lock
()
defer
sr
.
mux
.
Unlock
()
//skip if already added
_
,
existsMessage
:=
sr
.
byMessageID
[
messageID
]
if
existsMessage
{
return
}
//add the roundID
roundsList
,
existsRound
:=
sr
.
byRound
[
round
.
ID
]
sr
.
byRound
[
round
.
ID
]
=
append
(
roundsList
,
trackedRound
{
messageID
,
channelID
})
//add the round
sr
.
byMessageID
[
messageID
]
=
trackedMessage
{
round
.
ID
,
channelID
}
if
!
existsRound
{
callback
:=
func
(
allRoundsSucceeded
,
timedOut
bool
,
rounds
map
[
id
.
Round
]
cmix
.
RoundResult
)
{
}
sr
.
net
.
GetRoundResults
(
60
*
time
.
Second
)
}
}
type
roundResults
struct
{
round
id
.
Round
st
*
sendTracker
}
func
(
rr
roundResults
)
callback
(
allRoundsSucceeded
,
timedOut
bool
,
rounds
map
[
id
.
Round
]
cmix
.
RoundResult
)
{
rr
.
st
.
mux
.
Lock
()
//if the message was already handled, do nothing
registered
,
existsRound
:=
rr
.
st
.
byRound
[
rr
.
round
]
if
!
existsRound
{
rr
.
st
.
mux
.
Unlock
()
return
}
delete
(
rr
.
st
.
byRound
,
rr
.
round
)
for
i
:=
range
registered
{
delete
(
rr
.
st
.
byMessageID
,
registered
[
i
]
.
msgID
)
}
rr
.
st
.
mux
.
Unlock
()
for
i
:=
range
registered
{
rr
.
st
.
eventModel
.
}
}
//deleteUnsafe deletes a tracked message from the database
func
(
sr
*
sendTracker
)
deleteUnsafe
(
channelID
*
id
.
ID
,
messageID
cryptoChannel
.
MessageID
,
round
rounds
.
Round
)
{
sr
.
mux
.
Lock
()
defer
sr
.
mux
.
Unlock
()
//skip if already added
_
,
existsMessage
:=
sr
.
byMessageID
[
messageID
]
if
existsMessage
{
return
}
//add the roundID
roundsList
,
existsRound
:=
sr
.
byRound
[
round
.
ID
]
sr
.
byRound
[
round
.
ID
]
=
append
(
roundsList
,
trackedRound
{
messageID
,
channelID
})
//add the round
sr
.
byMessageID
[
messageID
]
=
trackedMessage
{
round
.
ID
,
channelID
}
if
!
existsRound
{
callback
:=
func
(
allRoundsSucceeded
,
timedOut
bool
,
rounds
map
[
id
.
Round
]
cmix
.
RoundResult
)
{
sr
.
mux
.
Lock
()
defer
sr
.
mux
.
Unlock
()
if
!
allRoundsSucceeded
}
sr
.
net
.
GetRoundResults
(
60
*
time
.
Second
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment