You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
967 B

package main
import (
"fmt"
"time"
"github.com/vocdoni/dvote-relay/batch"
"github.com/vocdoni/dvote-relay/net"
)
var dbPath = "$HOME/.dvote/relay.db"
var bdbPath = "$HOME/.dvote/batch.db"
var batchSeconds = 30 //seconds
var batchSize = 3 //packets
var err error
var batchTimer *time.Ticker
var batchSignal chan bool
var signal bool
func setup() {
batchTimer = time.NewTicker(time.Second * time.Duration(batchSeconds))
batchSignal = make(chan bool)
batch.DBPath = dbPath
batch.BDBPath = bdbPath
batch.BatchSignal = batchSignal
batch.BatchSize = batchSize
}
func main() {
setup()
// batch.Setup()
fmt.Println("Entering main loop")
go net.Listen("8080")
for {
select {
case <- batchTimer.C:
fmt.Println("Timer triggered")
fmt.Println(batch.Create())
//replace with chain link
case signal := <-batchSignal:
if signal == true {
fmt.Println("Signal triggered")
fmt.Println(batch.Create())
}
default:
continue
}
}
}