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
62211b63
Commit
62211b63
authored
May 26, 2016
by
Loïck Bonniot
Browse files
[p] Fix ready sign timeout
parent
be66c841
Pipeline
#2290
passed with stage
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
dfssp/contract/ready.go
View file @
62211b63
...
...
@@ -21,6 +21,11 @@ type readySignal struct {
sequence
[]
uint32
// Only used to broadcast signature sequence
}
// ReadySignTimeout is the delay users have to confirm the signature.
// A high value is not recommended, as there is no way to create any other signature on the same contract before the timeout
// if a client has connection issues.
var
ReadySignTimeout
=
time
.
Minute
// ReadySign is the last job of the platform before the signature can occur.
// When a new client is ready, it joins a waitingGroup and waits for a master broadcast announcing that everybody is ready.
//
...
...
@@ -45,6 +50,7 @@ func ReadySign(db *mgdb.MongoManager, rooms *common.WaitingGroupMap, ctx *contex
rooms
.
Broadcast
(
roomID
,
&
readySignal
{
data
:
cn
})
// Wait for ready signal
timeout
:=
time
.
After
(
ReadySignTimeout
)
for
{
select
{
case
signal
,
ok
:=
<-
channel
:
...
...
@@ -67,7 +73,7 @@ func ReadySign(db *mgdb.MongoManager, rooms *common.WaitingGroupMap, ctx *contex
case
<-
(
*
ctx
)
.
Done
()
:
// Client's disconnection
rooms
.
Unjoin
(
roomID
,
channel
)
return
&
api
.
LaunchSignature
{
ErrorCode
:
&
api
.
ErrorCode
{
Code
:
api
.
ErrorCode_INVARG
}}
case
<-
time
.
After
(
time
.
Minute
)
:
// Someone has not confirmed the signature within the delay
case
<-
time
out
:
// Someone has not confirmed the signature within the delay
rooms
.
Unjoin
(
roomID
,
channel
)
return
&
api
.
LaunchSignature
{
ErrorCode
:
&
api
.
ErrorCode
{
Code
:
api
.
ErrorCode_TIMEOUT
,
Message
:
"timeout for ready signal"
}}
}
...
...
@@ -102,6 +108,7 @@ func masterReadyRoutine(db *mgdb.MongoManager, rooms *common.WaitingGroupMap, co
signersReady
:=
make
([]
bool
,
len
(
contract
.
Signers
))
work
:=
true
timeout
:=
time
.
After
(
ReadySignTimeout
)
for
work
{
select
{
case
signal
,
ok
:=
<-
channel
:
...
...
@@ -120,7 +127,7 @@ func masterReadyRoutine(db *mgdb.MongoManager, rooms *common.WaitingGroupMap, co
})
work
=
false
}
case
<-
time
.
After
(
10
*
time
.
Minute
)
:
case
<-
time
out
:
work
=
false
}
}
...
...
tests/starters_test.go
View file @
62211b63
...
...
@@ -58,13 +58,13 @@ func startPlatform(tmpDir string) (platform, ttp, demo *exec.Cmd, stop func(), c
time
.
Sleep
(
time
.
Second
)
// Start platform
platform
=
exec
.
Command
(
path
,
"--db"
,
dbURI
,
"--path"
,
dir
,
"-p"
,
testPort
,
"--ttps"
,
ttpsPath
,
"-d"
,
"localhost:9099"
,
"-v"
,
"start"
)
platform
=
exec
.
Command
(
path
,
"--db"
,
dbURI
,
"--path"
,
dir
,
"-p"
,
testPort
,
"--ttps"
,
ttpsPath
,
"-d"
,
"localhost:9099"
,
"start"
)
platform
.
Stdout
=
os
.
Stdout
platform
.
Stderr
=
os
.
Stderr
err
=
platform
.
Start
()
// Start TTP
ttp
=
exec
.
Command
(
ttpPath
,
"--db"
,
dbURI
,
"--port"
,
"9098"
,
"-d"
,
"localhost:9099"
,
"-v"
,
"start"
)
ttp
=
exec
.
Command
(
ttpPath
,
"--db"
,
dbURI
,
"--port"
,
"9098"
,
"-d"
,
"localhost:9099"
,
"start"
)
ttp
.
Dir
=
filepath
.
Join
(
dir
,
"ttp"
)
ttp
.
Stdout
=
os
.
Stdout
ttp
.
Stderr
=
os
.
Stderr
...
...
@@ -107,7 +107,7 @@ func createClient(tmpDir string, ca []byte, port int) (*exec.Cmd, error) {
// Prepare the client command.
// The last argument is up to you!
cmd
:=
exec
.
Command
(
path
,
"--ca"
,
caPath
,
"--cert"
,
certPath
,
"--host"
,
"127.0.0.1:"
+
testPort
,
"--key"
,
keyPath
,
"--port"
,
strconv
.
Itoa
(
port
),
"--timeout"
,
"3s"
,
"-v"
,
"-d"
,
"localhost:9099"
)
cmd
:=
exec
.
Command
(
path
,
"--ca"
,
caPath
,
"--cert"
,
certPath
,
"--host"
,
"127.0.0.1:"
+
testPort
,
"--key"
,
keyPath
,
"--port"
,
strconv
.
Itoa
(
port
),
"--timeout"
,
"3s"
,
"-d"
,
"localhost:9099"
)
return
cmd
,
nil
}
...
...
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