Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpcs
dfss
Commits
6ae6a780
Commit
6ae6a780
authored
Apr 04, 2016
by
Richer Maximilien
Committed by
Loïck Bonniot
Apr 15, 2016
Browse files
[c] Add goroutine to signature round
parent
3139fa6c
Changes
1
Show whitespace changes
Inline
Side-by-side
dfssc/sign/signatures.go
View file @
6ae6a780
...
...
@@ -15,8 +15,11 @@ import (
)
// SendAllSigns creates and sends signatures to all the signers of the contract
// TODO Use goroutines to send in parallel
func
(
m
*
SignatureManager
)
SendAllSigns
()
error
{
allRecieved
:=
make
(
chan
error
)
go
m
.
RecieveAllSigns
(
allRecieved
)
myID
,
err
:=
m
.
FindID
()
if
err
!=
nil
{
return
err
...
...
@@ -25,18 +28,40 @@ func (m *SignatureManager) SendAllSigns() error {
// compute a set of all signers exept me
sendSet
:=
common
.
GetAllButOne
(
m
.
sequence
,
myID
)
errorChan
:=
make
(
chan
error
)
for
_
,
id
:=
range
sendSet
{
go
func
(
id
uint32
)
{
signature
,
err
:=
m
.
CreateSignature
(
myID
,
id
)
if
err
!=
nil
{
return
err
errorChan
<-
err
return
}
dAPI
.
DLog
(
"{"
+
fmt
.
Sprintf
(
"%d"
,
myID
)
+
"} Send sign to "
+
fmt
.
Sprintf
(
"%d"
,
id
))
_
,
err
=
m
.
SendSignature
(
signature
,
id
)
if
err
!=
nil
{
errorChan
<-
err
return
}
errorChan
<-
nil
return
}(
id
)
}
for
range
sendSet
{
err
=
<-
errorChan
if
err
!=
nil
{
return
err
}
}
err
=
<-
allRecieved
if
err
!=
nil
{
return
err
}
return
nil
}
...
...
@@ -81,11 +106,12 @@ func (m *SignatureManager) SendSignature(signature *cAPI.Signature, to uint32) (
return
errCode
,
nil
}
// RecieveAllSigns
is not done yet
func
(
m
*
SignatureManager
)
RecieveAllSigns
(
)
error
{
// RecieveAllSigns
recieve all the signatures
func
(
m
*
SignatureManager
)
RecieveAllSigns
(
out
chan
error
)
{
myID
,
err
:=
m
.
FindID
()
if
err
!=
nil
{
return
err
out
<-
err
return
}
// compute a set of all signers exept me
...
...
@@ -107,5 +133,6 @@ func (m *SignatureManager) RecieveAllSigns() error {
}
}
return
nil
out
<-
nil
return
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment