2017-11-06 17:40:52 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
|
2018-01-05 17:55:00 +00:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"os"
|
|
|
|
|
2017-11-09 19:34:58 +00:00
|
|
|
"github.com/8thlight/vulcanizedb/cmd"
|
2017-11-06 18:53:43 +00:00
|
|
|
"github.com/8thlight/vulcanizedb/pkg/geth"
|
2018-01-05 17:55:00 +00:00
|
|
|
"github.com/8thlight/vulcanizedb/pkg/history"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
pollingInterval = 7 * time.Second
|
2017-11-06 17:40:52 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2018-01-05 17:55:00 +00:00
|
|
|
ticker := time.NewTicker(pollingInterval)
|
|
|
|
defer ticker.Stop()
|
|
|
|
|
2017-11-06 17:40:52 +00:00
|
|
|
environment := flag.String("environment", "", "Environment name")
|
|
|
|
flag.Parse()
|
2017-11-09 19:34:58 +00:00
|
|
|
config := cmd.LoadConfig(*environment)
|
2018-01-05 17:55:00 +00:00
|
|
|
blockchain := geth.NewBlockchain(config.Client.IPCPath)
|
2017-12-07 19:32:16 +00:00
|
|
|
repository := cmd.LoadPostgres(config.Database, blockchain.Node())
|
2018-01-05 17:55:00 +00:00
|
|
|
validator := history.NewBlockValidator(blockchain, repository, 15)
|
|
|
|
|
|
|
|
for range ticker.C {
|
|
|
|
window := validator.ValidateBlocks()
|
|
|
|
validator.Log(os.Stdout, window)
|
|
|
|
}
|
2017-11-06 17:40:52 +00:00
|
|
|
}
|