Browse Source

removed remnant of http listener

pubsub_testing
imw 5 years ago
parent
commit
b88d88e931
1 changed files with 0 additions and 56 deletions
  1. +0
    -56
      net/net.go

+ 0
- 56
net/net.go

@ -3,56 +3,12 @@ package net
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/http"
"io"
"github.com/vocdoni/dvote-relay/batch" "github.com/vocdoni/dvote-relay/batch"
"github.com/vocdoni/dvote-relay/types" "github.com/vocdoni/dvote-relay/types"
"github.com/vocdoni/dvote-relay/data" "github.com/vocdoni/dvote-relay/data"
) )
func parse(rw http.ResponseWriter, request *http.Request) {
decoder := json.NewDecoder(request.Body)
var e types.Envelope
var b types.Ballot
err := decoder.Decode(&e)
if err != nil {
panic(err)
}
err = json.Unmarshal(e.Ballot, &b)
if err != nil {
panic(err)
}
//check PoW
//check key
//decrypt
//check franchise
//construct packet
//this should should be randomized, or actually taken from input
//b.PID = "1"
//b.Nullifier = []byte{1,2,3}
//b.Vote = []byte{4,5,6}
//b.Franchise = []byte{7,8,9}
err = batch.Add(b)
if err != nil {
panic(err)
}
j, err := json.Marshal(e)
if err != nil {
panic(err)
}
io.WriteString(rw, string(j))
}
func Sub(topic string) error { func Sub(topic string) error {
subscription := data.PsSubscribe(topic) subscription := data.PsSubscribe(topic)
fmt.Println("Subscribed > " + topic) fmt.Println("Subscribed > " + topic)
@ -85,15 +41,3 @@ func Sub(topic string) error {
fmt.Println("Got > " + string(payload)) fmt.Println("Got > " + string(payload))
} }
} }
func Listen(port string) {
http.HandleFunc("/submit", parse)
//add waitgroup
func() {
fmt.Println("serving on " + port)
err := http.ListenAndServe(":" + port, nil)
if err != nil {
panic("ListenAndServe: " + err.Error())
}
}()
}

Loading…
Cancel
Save