forked from taarushv/helios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helios.go
39 lines (35 loc) · 1.18 KB
/
helios.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
package main
import (
"flag"
"fmt"
"github.com/joho/godotenv"
"github.com/taarushv/helios/services"
"github.com/taarushv/helios/tools"
)
func main() {
// Load the env variable (contains ipc path/infura ws api url)
godotenv.Load(".env")
// 'Quick' mode displays mempool data on the console
// 'Full' initiates a elastic search client and stores data
var modeType = flag.String("mode", "quick", "Quick mode vs with 'full' inserts to elastic search")
// Flush helper flag to delete all
var flush = flag.String("flush", "", "Index you want to delete")
flag.Parse()
// `go run helios.go -mode=full -flush=transactions` will delete all txs stored in ES
if *flush != "" {
fmt.Println("Flushing the index:", *flush)
// This is irreversable, be careful!
tools.FlushIndexData(*flush)
} else {
// Initiate client, flags: -client=infura or -client=local
rpcClient := services.InitRPCClient()
if *modeType == "full" {
// Stream news txs, store them depending on mode
services.StreamNewTxs(rpcClient, true)
//TODO: validate queries before updating a block after being mined
//services.StreamNewBlocks(rpcClient)
} else {
services.StreamNewTxs(rpcClient, false)
}
}
}