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
8b230ecf
Commit
8b230ecf
authored
3 years ago
by
Jonah Husson
Browse files
Options
Downloads
Patches
Plain Diff
Add text output for integration
parent
384985a3
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!510
Release
,
!240
Integration update, allow client to use both broadcast methods
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmd/broadcast.go
+58
-33
58 additions, 33 deletions
cmd/broadcast.go
with
58 additions
and
33 deletions
cmd/broadcast.go
+
58
−
33
View file @
8b230ecf
...
...
@@ -13,6 +13,7 @@ import (
"gitlab.com/xx_network/crypto/signature/rsa"
"gitlab.com/xx_network/primitives/utils"
"os"
"sync"
"time"
)
...
...
@@ -83,6 +84,7 @@ var broadcastCmd = &cobra.Command{
}
else
{
fmt
.
Printf
(
"Private key generated for channel: %+v"
,
rsa
.
CreatePrivateKeyPem
(
pk
))
}
fmt
.
Printf
(
"New broadcast channel generated"
)
}
else
{
// Read rest of info from config & build object manually
pubKeyBytes
:=
[]
byte
(
viper
.
GetString
(
"rsaPub"
))
...
...
@@ -176,22 +178,35 @@ var broadcastCmd = &cobra.Command{
/* Broadcast messages to the channel */
if
symmetric
!=
""
||
asymmetric
!=
""
{
wg
:=
sync
.
WaitGroup
{}
wg
.
Add
(
1
)
go
func
()
{
jww
.
INFO
.
Printf
(
"Attempting to send broadcasts..."
)
// Wait for sendDelay before sending (to allow connection to establish)
sendDelay
:=
time
.
Duration
(
viper
.
GetUint
(
"sendDelay"
))
time
.
Sleep
(
sendDelay
)
maxRetries
:=
10
retries
:=
0
for
{
// Wait for sendDelay before sending (to allow connection to establish)
if
maxRetries
==
retries
{
jww
.
FATAL
.
Panicf
(
"Max retries reached"
)
}
time
.
Sleep
(
sendDelay
*
time
.
Millisecond
*
time
.
Duration
(
retries
)
+
1
)
/* Send symmetric broadcast */
if
symmetric
!=
""
{
// Create properly sized broadcast message
broadcastMessage
,
err
:=
broadcast
.
NewSizedBroadcast
(
bcl
.
MaxPayloadSize
(),
[]
byte
(
symmetric
))
if
err
!=
nil
{
jww
.
ERROR
.
Print
f
(
"Failed to create sized broadcast: %+v"
,
err
)
jww
.
FATAL
.
Panic
f
(
"Failed to create sized broadcast: %+v"
,
err
)
}
rid
,
eid
,
err
:=
bcl
.
Broadcast
(
broadcastMessage
,
cmix
.
GetDefaultCMIXParams
())
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"Failed to send symmetric broadcast message: %+v"
,
err
)
jww
.
ERROR
.
Printf
(
"Failed to send symmetric broadcast message: %+v"
,
err
)
retries
++
continue
}
fmt
.
Printf
(
"Sent symmetric broadcast message: %s"
,
symmetric
)
jww
.
INFO
.
Printf
(
"Sent symmetric broadcast message to %s over round %d"
,
eid
,
rid
)
}
...
...
@@ -200,17 +215,27 @@ var broadcastCmd = &cobra.Command{
// Create properly sized broadcast message
broadcastMessage
,
err
:=
broadcast
.
NewSizedBroadcast
(
bcl
.
MaxAsymmetricPayloadSize
(),
[]
byte
(
asymmetric
))
if
err
!=
nil
{
jww
.
ERROR
.
Print
f
(
"Failed to create sized broadcast: %+v"
,
err
)
jww
.
FATAL
.
Panic
f
(
"Failed to create sized broadcast: %+v"
,
err
)
}
if
pk
==
nil
{
jww
.
FATAL
.
Panicf
(
"CANNOT SEND ASYMMETRIC BROADCAST WITHOUT PRIVATE KEY"
)
}
rid
,
eid
,
err
:=
bcl
.
BroadcastAsymmetric
(
pk
,
broadcastMessage
,
cmix
.
GetDefaultCMIXParams
())
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"Failed to send asymmetric broadcast message: %+v"
,
err
)
jww
.
ERROR
.
Printf
(
"Failed to send asymmetric broadcast message: %+v"
,
err
)
retries
++
continue
}
fmt
.
Printf
(
"Sent asymmetric broadcast message: %s"
,
asymmetric
)
jww
.
INFO
.
Printf
(
"Sent asymmetric broadcast message to %s over round %d"
,
eid
,
rid
)
}
wg
.
Done
()
break
}
}()
wg
.
Wait
()
}
/* Receive broadcast messages over the channel */
...
...
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