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
7e697f8d
Commit
7e697f8d
authored
May 22, 2016
by
Richer Maximilien
Committed by
Loïck Bonniot
May 24, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[c] Add timeout flag support
parent
dd9b187b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
6 deletions
+10
-6
dfssc/cmd/root.go
dfssc/cmd/root.go
+3
-0
dfssc/cmd/sign.go
dfssc/cmd/sign.go
+1
-0
dfssc/sign/promises.go
dfssc/sign/promises.go
+2
-2
dfssc/sign/signatures.go
dfssc/sign/signatures.go
+2
-1
dfssc/sign/starter.go
dfssc/sign/starter.go
+2
-3
No files found.
dfssc/cmd/root.go
View file @
7e697f8d
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
package
cmd
package
cmd
import
(
import
(
"time"
"dfss"
"dfss"
dapi
"dfss/dfssd/api"
dapi
"dfss/dfssd/api"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
...
@@ -39,6 +41,7 @@ func init() {
...
@@ -39,6 +41,7 @@ func init() {
RootCmd
.
PersistentFlags
()
.
String
(
"host"
,
"localhost:9000"
,
"host of the dfss platform"
)
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"
)
RootCmd
.
PersistentFlags
()
.
IntP
(
"port"
,
"p"
,
9005
,
"port to use for P2P communication between clients"
)
signCmd
.
Flags
()
.
Duration
(
"timeout"
,
time
.
Minute
,
"time to wait before fallback"
)
signCmd
.
Flags
()
.
Duration
(
"slowdown"
,
0
,
"delay between each promises round (test only)"
)
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)"
)
signCmd
.
Flags
()
.
Int
(
"stopbefore"
,
0
,
"stop signature just before the promises round n, -1 to stop right before signature round (test only)"
)
...
...
dfssc/cmd/sign.go
View file @
7e697f8d
...
@@ -18,6 +18,7 @@ var signCmd = &cobra.Command{
...
@@ -18,6 +18,7 @@ var signCmd = &cobra.Command{
os
.
Exit
(
1
)
os
.
Exit
(
1
)
}
}
_
=
viper
.
BindPFlag
(
"timeout"
,
cmd
.
Flags
()
.
Lookup
(
"timeout"
))
_
=
viper
.
BindPFlag
(
"slowdown"
,
cmd
.
Flags
()
.
Lookup
(
"slowdown"
))
_
=
viper
.
BindPFlag
(
"slowdown"
,
cmd
.
Flags
()
.
Lookup
(
"slowdown"
))
_
=
viper
.
BindPFlag
(
"stopbefore"
,
cmd
.
Flags
()
.
Lookup
(
"stopbefore"
))
_
=
viper
.
BindPFlag
(
"stopbefore"
,
cmd
.
Flags
()
.
Lookup
(
"stopbefore"
))
...
...
dfssc/sign/promises.go
View file @
7e697f8d
...
@@ -3,11 +3,11 @@ package sign
...
@@ -3,11 +3,11 @@ package sign
import
(
import
(
"encoding/hex"
"encoding/hex"
"errors"
"errors"
"time"
cAPI
"dfss/dfssc/api"
cAPI
"dfss/dfssc/api"
dAPI
"dfss/dfssd/api"
dAPI
"dfss/dfssd/api"
pAPI
"dfss/dfssp/api"
pAPI
"dfss/dfssp/api"
"github.com/spf13/viper"
"golang.org/x/net/context"
"golang.org/x/net/context"
)
)
...
@@ -59,7 +59,7 @@ func (m *SignatureManager) SendEvidence(promise *cAPI.Promise, signature *cAPI.S
...
@@ -59,7 +59,7 @@ func (m *SignatureManager) SendEvidence(promise *cAPI.Promise, signature *cAPI.S
return
return
}
}
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
time
.
Minute
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
viper
.
GetDuration
(
"timeout"
)
)
defer
cancel
()
defer
cancel
()
var
result
*
pAPI
.
ErrorCode
var
result
*
pAPI
.
ErrorCode
...
...
dfssc/sign/signatures.go
View file @
7e697f8d
...
@@ -6,6 +6,7 @@ import (
...
@@ -6,6 +6,7 @@ import (
cAPI
"dfss/dfssc/api"
cAPI
"dfss/dfssc/api"
"dfss/dfssc/common"
"dfss/dfssc/common"
"github.com/spf13/viper"
)
)
// ExchangeAllSignatures creates and sends signatures to all the signers of the contract
// ExchangeAllSignatures creates and sends signatures to all the signers of the contract
...
@@ -83,7 +84,7 @@ func (m *SignatureManager) ReceiveAllSignatures(out chan error) {
...
@@ -83,7 +84,7 @@ func (m *SignatureManager) ReceiveAllSignatures(out chan error) {
m
.
archives
.
receivedSignatures
=
append
(
m
.
archives
.
receivedSignatures
,
signature
)
m
.
archives
.
receivedSignatures
=
append
(
m
.
archives
.
receivedSignatures
,
signature
)
}
}
case
<-
time
.
After
(
time
.
Minute
)
:
case
<-
time
.
After
(
viper
.
GetDuration
(
"timeout"
)
)
:
out
<-
fmt
.
Errorf
(
"Signature reception timeout!"
)
out
<-
fmt
.
Errorf
(
"Signature reception timeout!"
)
return
return
}
}
...
...
dfssc/sign/starter.go
View file @
7e697f8d
...
@@ -5,7 +5,6 @@ import (
...
@@ -5,7 +5,6 @@ import (
"fmt"
"fmt"
"strconv"
"strconv"
"sync"
"sync"
"time"
"dfss"
"dfss"
cAPI
"dfss/dfssc/api"
cAPI
"dfss/dfssc/api"
...
@@ -210,7 +209,7 @@ func (m *SignatureManager) addPeer(user *pAPI.User) (ready bool, err error) {
...
@@ -210,7 +209,7 @@ func (m *SignatureManager) addPeer(user *pAPI.User) (ready bool, err error) {
// need to create another way to access it
// need to create another way to access it
m
.
peersConn
[
user
.
Email
]
=
conn
m
.
peersConn
[
user
.
Email
]
=
conn
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
time
.
Minute
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
viper
.
GetDuration
(
"timeout"
)
)
defer
cancel
()
defer
cancel
()
msg
,
err
:=
client
.
Discover
(
ctx
,
&
cAPI
.
Hello
{
Version
:
dfss
.
Version
})
msg
,
err
:=
client
.
Discover
(
ctx
,
&
cAPI
.
Hello
{
Version
:
dfss
.
Version
})
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -235,7 +234,7 @@ func (m *SignatureManager) addPeer(user *pAPI.User) (ready bool, err error) {
...
@@ -235,7 +234,7 @@ func (m *SignatureManager) addPeer(user *pAPI.User) (ready bool, err error) {
// SendReadySign sends the READY signal to the platform, and wait (potentially a long time) for START signal.
// SendReadySign sends the READY signal to the platform, and wait (potentially a long time) for START signal.
func
(
m
*
SignatureManager
)
SendReadySign
()
(
signatureUUID
string
,
err
error
)
{
func
(
m
*
SignatureManager
)
SendReadySign
()
(
signatureUUID
string
,
err
error
)
{
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
10
*
time
.
Minute
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
10
*
viper
.
GetDuration
(
"timeout"
)
)
defer
cancel
()
defer
cancel
()
c
:=
make
(
chan
*
pAPI
.
LaunchSignature
)
c
:=
make
(
chan
*
pAPI
.
LaunchSignature
)
...
...
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