Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Elixxir dApps SDK Swift
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
mobile
iOS
Elixxir dApps SDK Swift
Merge requests
!33
XXMessengerClient
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
XXMessengerClient
feature/messenger-client
into
development
Overview
0
Commits
27
Pipelines
0
Changes
4
Merged
Dariusz Rybicki
requested to merge
feature/messenger-client
into
development
2 years ago
Overview
0
Commits
27
Pipelines
0
Changes
4
Expand
Breaking changes:
Rename
Environment
to
NDFEnvironment
.
Update
NewOrLoadUd
functor parameters.
New features:
Add
XXMessengerClient
library.
Update documentation.
Edited
2 years ago
by
Dariusz Rybicki
0
0
Merge request reports
Viewing commit
efb3ba76
Prev
Next
Show latest version
4 files
+
173
−
2
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
efb3ba76
Add MessengerWaitForNodes functor
· efb3ba76
Dariusz Rybicki
authored
2 years ago
Sources/XXMessengerClient/Messenger/Functors/MessengerWaitForNodes.swift
0 → 100644
+
57
−
0
Options
import
XXClient
import
XCTestDynamicOverlay
public
struct
MessengerWaitForNodes
{
public
typealias
Progress
=
(
Double
)
->
Void
public
enum
Error
:
Swift
.
Error
{
case
notLoaded
case
timeout
}
public
var
run
:
(
Double
,
Int
,
Int
,
@escaping
Progress
)
throws
->
Void
public
func
callAsFunction
(
targetRatio
:
Double
=
0.8
,
sleepMS
:
Int
=
1_000
,
retries
:
Int
=
10
,
onProgress
:
@escaping
Progress
=
{
_
in
}
)
throws
{
try
run
(
targetRatio
,
sleepMS
,
retries
,
onProgress
)
}
}
extension
MessengerWaitForNodes
{
public
static
func
live
(
_
env
:
MessengerEnvironment
)
->
MessengerWaitForNodes
{
MessengerWaitForNodes
{
targetRatio
,
sleepMS
,
retries
,
onProgress
in
guard
let
cMix
=
env
.
ctx
.
getCMix
()
else
{
throw
Error
.
notLoaded
}
func
getProgress
(
_
report
:
NodeRegistrationReport
)
->
Double
{
min
(
1
,
((
report
.
ratio
/
targetRatio
)
*
100
)
.
rounded
()
/
100
)
}
var
report
=
try
cMix
.
getNodeRegistrationStatus
()
var
retries
=
retries
onProgress
(
getProgress
(
report
))
while
report
.
ratio
<
targetRatio
&&
retries
>
0
{
env
.
sleep
(
sleepMS
)
retries
-=
1
report
=
try
cMix
.
getNodeRegistrationStatus
()
onProgress
(
getProgress
(
report
))
}
if
report
.
ratio
<
targetRatio
{
throw
Error
.
timeout
}
}
}
}
extension
MessengerWaitForNodes
{
public
static
let
unimplemented
=
MessengerWaitForNodes
(
run
:
XCTUnimplemented
(
"
\(
Self
.
self
)
"
)
)
}
Loading