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
af6a6448
Commit
af6a6448
authored
May 20, 2016
by
Loïck Bonniot
Browse files
Merge branch '458_stopafter_flag' into 'master'
[c] Add stopbefore flag See merge request
!79
parents
01570f85
2028516d
Pipeline
#1872
passed with stages
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
dfssc/cmd/root.go
View file @
af6a6448
...
...
@@ -39,7 +39,8 @@ func init() {
RootCmd
.
PersistentFlags
()
.
String
(
"host"
,
"localhost:9000"
,
"host of the dfss platform"
)
RootCmd
.
PersistentFlags
()
.
IntP
(
"port"
,
"p"
,
9005
,
"port to use for P2P communication between clients"
)
signCmd
.
Flags
()
.
Duration
(
"slowdown"
,
0
,
"Delay between each promises round"
)
signCmd
.
Flags
()
.
Duration
(
"slowdown"
,
0
,
"delay between each promises round (test only)"
)
signCmd
.
Flags
()
.
Int
(
"stopbefore"
,
0
,
"stop signature just before the promises round n, -1 to stop right before signature round (test only)"
)
// Store flag values into viper
_
=
viper
.
BindPFlag
(
"verbose"
,
RootCmd
.
PersistentFlags
()
.
Lookup
(
"verbose"
))
...
...
dfssc/cmd/sign.go
View file @
af6a6448
...
...
@@ -19,6 +19,7 @@ var signCmd = &cobra.Command{
}
_
=
viper
.
BindPFlag
(
"slowdown"
,
cmd
.
Flags
()
.
Lookup
(
"slowdown"
))
_
=
viper
.
BindPFlag
(
"stopbefore"
,
cmd
.
Flags
()
.
Lookup
(
"stopbefore"
))
filename
:=
args
[
0
]
fmt
.
Println
(
"You are going to sign the following contract:"
)
...
...
dfssc/sign/protocol.go
View file @
af6a6448
...
...
@@ -3,6 +3,7 @@ package sign
import
(
"fmt"
"os"
"time"
cAPI
"dfss/dfssc/api"
...
...
@@ -42,6 +43,7 @@ func (m *SignatureManager) Sign() error {
// Promess rounds
// Follow the sequence until there is no next occurence of me
for
m
.
currentIndex
>=
0
{
stopIfNeeded
(
m
.
currentIndex
)
m
.
OnProgressUpdate
(
m
.
currentIndex
,
seqLen
+
1
)
time
.
Sleep
(
viper
.
GetDuration
(
"slowdown"
))
dAPI
.
DLog
(
"starting round at index ["
+
fmt
.
Sprintf
(
"%d"
,
m
.
currentIndex
)
+
"] with nextIndex="
+
fmt
.
Sprintf
(
"%d"
,
nextIndex
))
...
...
@@ -70,16 +72,17 @@ func (m *SignatureManager) Sign() error {
}
}
// Signature round
stopIfNeeded
(
-
1
)
m
.
OnProgressUpdate
(
seqLen
,
seqLen
+
1
)
dAPI
.
DLog
(
"entering signature round"
)
// Signature round
err
=
m
.
ExchangeAllSignatures
()
if
err
!=
nil
{
return
err
}
dAPI
.
DLog
(
"exiting signature round"
)
m
.
OnProgressUpdate
(
seqLen
+
1
,
seqLen
+
1
)
return
nil
}
...
...
@@ -151,3 +154,14 @@ func (m *SignatureManager) closeConnections() {
}
m
.
cServer
.
Stop
()
}
func
stopIfNeeded
(
index
int
)
{
s
:=
viper
.
GetInt
(
"stopbefore"
)
if
s
==
0
{
return
}
if
index
==
-
1
&&
s
==
-
1
||
index
+
1
==
s
{
os
.
Exit
(
0
)
}
}
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