mirror of
https://github.com/arnaucube/go-dvote.git
synced 2026-02-28 05:26:46 +01:00
Keep adapting the code to new merkletree implementation
Use different database storages and merkletree for each censusID Signed-off-by: p4u <p4u@dabax.net>
This commit is contained in:
@@ -13,14 +13,14 @@ go build -o censusHttpService github.com/vocdoni/dvote-census/cmd/censushttp
|
||||
|
||||
#### Usage
|
||||
|
||||
`./censusHttpService <port> [publicKey]`
|
||||
`./censusHttpService <port> <namespace>[:pubKey] [<namespace>[:pubKey] ...]`
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
./censusHttpService 1500
|
||||
2018/12/17 09:54:20 Starting process HTTP service on port 1500
|
||||
2018/12/17 09:54:20 Starting server in http mode
|
||||
./censusHttpService 1500 Got_Favorite
|
||||
2019/02/01 20:01:15 Starting process HTTP service on port 1500 for namespace GoT_Favorite
|
||||
2019/02/01 20:01:15 Starting server in http mode
|
||||
```
|
||||
|
||||
#### add claims
|
||||
@@ -35,6 +35,8 @@ If public key authentication enabled, `signature` field is required using Nancl
|
||||
|
||||
The signed message is expected to be a concatenation of the following fields: `censusID, claimData, timeStamp`
|
||||
|
||||
There is a time window of 10 seconds while the signature is considered valid.
|
||||
|
||||
```
|
||||
curl -d '{"censusID":"GoT_Favorite",
|
||||
"claimData":"Jon Snow",
|
||||
|
||||
@@ -4,13 +4,15 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
censusmanager "github.com/vocdoni/dvote-census/service"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if len(os.Args) < 2 {
|
||||
log.Fatal("Usage: " + os.Args[0] + " <port> [pubKey]")
|
||||
log.Fatal("Usage: " + os.Args[0] +
|
||||
" <port> <namespace>[:pubKey] [<namespace>[:pubKey]]...")
|
||||
os.Exit(2)
|
||||
}
|
||||
port, err := strconv.Atoi(os.Args[1])
|
||||
@@ -18,13 +20,18 @@ func main() {
|
||||
log.Fatal(err)
|
||||
os.Exit(2)
|
||||
}
|
||||
pubK := ""
|
||||
if len(os.Args) > 2 {
|
||||
log.Print("Public key authentication enabled")
|
||||
pubK = os.Args[2]
|
||||
for i := 2; i < len(os.Args); i++ {
|
||||
s := strings.Split(os.Args[i], ":")
|
||||
ns := s[0]
|
||||
pubK := ""
|
||||
if len(s) > 1 {
|
||||
pubK = s[1]
|
||||
log.Printf("Public Key authentication enabled on namespace %s\n", ns)
|
||||
}
|
||||
censusmanager.AddNamespace(ns, pubK)
|
||||
log.Printf("Starting process HTTP service on port %d for namespace %s\n",
|
||||
port, ns)
|
||||
}
|
||||
log.Print("Starting process HTTP service on port " + os.Args[1])
|
||||
censusmanager.T.Init()
|
||||
censusmanager.Listen(port, "http", pubK)
|
||||
censusmanager.Listen(port, "http")
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user