Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dfss
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
7
Issues
7
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mpcs
dfss
Commits
2028516d
Commit
2028516d
authored
May 20, 2016
by
Loïck Bonniot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[c] Add stopbefore flag
parent
01570f85
Pipeline
#1870
passed with stage
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
3 deletions
+19
-3
dfssc/cmd/root.go
dfssc/cmd/root.go
+2
-1
dfssc/cmd/sign.go
dfssc/cmd/sign.go
+1
-0
dfssc/sign/protocol.go
dfssc/sign/protocol.go
+16
-2
No files found.
dfssc/cmd/root.go
View file @
2028516d
...
...
@@ -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 @
2028516d
...
...
@@ -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 @
2028516d
...
...
@@ -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
Markdown
is supported
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