forked from dedis/cothority
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schnorr_sign.go
51 lines (45 loc) · 1.15 KB
/
schnorr_sign.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package schnorr_sign
import (
"encoding/json"
log "github.com/Sirupsen/logrus"
"github.com/dedis/cothority/deploy"
"github.com/dedis/cothority/lib/config"
dbg "github.com/dedis/cothority/lib/debug_lvl"
"io/ioutil"
//"os"
)
// Dispatch-function for running either client or server (mode-parameter)
func Run(app *config.AppConfig, depl *deploy.Config) {
// we must know who we are
if app.Hostname == "" {
log.Fatal("Hostname empty : Abort")
}
dbg.Lvl2(app.Hostname, "Starting to run as ", app.Mode)
var err error
hosts, err := ReadHostsJson("tree.json")
if err != nil {
log.Fatal("Error while reading JSON hosts file on", app.Hostname, ". Abort")
}
switch app.Mode {
case "client":
RunClient(depl)
case "server":
RunServer(hosts, app, depl)
}
}
// Read the tree json file and return the configFileold containing every hosts name
func ReadHostsJson(file string) (*config.HostsConfig, error) {
var cf config.ConfigFileOld
bFile, err := ioutil.ReadFile(file)
if err != nil {
return nil, err
}
err = json.Unmarshal(bFile, &cf)
if err != nil {
return nil, err
}
return &config.HostsConfig{
Conn: cf.Conn,
Hosts: cf.Hosts,
}, nil
}