From 0ae25aff95cd46a58a3e1b17c1707e2278f4a5c7 Mon Sep 17 00:00:00 2001 From: Matt Krump Date: Tue, 16 Jan 2018 09:48:42 -0600 Subject: [PATCH] Remove getLogs entrypoint --- Gododir/main.go | 14 --------- README.md | 6 ---- cmd/get_logs/main.go | 74 -------------------------------------------- 3 files changed, 94 deletions(-) delete mode 100644 cmd/get_logs/main.go diff --git a/Gododir/main.go b/Gododir/main.go index 454e46e0..6243f67f 100644 --- a/Gododir/main.go +++ b/Gododir/main.go @@ -42,20 +42,6 @@ func tasks(p *do.Project) { do.M{"environment": environment, "startingNumber": startingNumber, "$in": "cmd/populate_blocks"}) }) - p.Task("getLogs", nil, func(context *do.Context) { - environment := parseEnvironment(context) - contractHash := context.Args.MayString("", "contract-hash", "c") - if contractHash == "" { - log.Fatalln("--contract-hash required") - } - context.Start(`go run main.go --environment={{.environment}} --contract-hash={{.contractHash}}`, - do.M{ - "environment": environment, - "contractHash": contractHash, - "$in": "cmd/get_logs", - }) - }) - p.Task("watchContract", nil, func(context *do.Context) { environment := parseEnvironment(context) contractHash := context.Args.MayString("", "contract-hash", "c") diff --git a/README.md b/README.md index 832c00ab..e05adda6 100644 --- a/README.md +++ b/README.md @@ -91,12 +91,6 @@ The name of the JSON file should correspond the contract's address. 2. Start watching the contract `godo watchContract -- --environment= --contract-hash=` 3. Request summary data `godo showContractSummary -- --environment= --contract-hash=` - -## Retrieving Contract Logs - -1. Get the logs for a specific contract - - `godo getLogs -- --environment= --contract-hash=` - ### Configuring Additional Environments You can create configuration files for additional environments. diff --git a/cmd/get_logs/main.go b/cmd/get_logs/main.go deleted file mode 100644 index 3e013882..00000000 --- a/cmd/get_logs/main.go +++ /dev/null @@ -1,74 +0,0 @@ -package main - -import ( - "log" - - "flag" - - "math/big" - - "time" - - "strings" - - "github.com/8thlight/vulcanizedb/cmd" - "github.com/8thlight/vulcanizedb/pkg/core" - "github.com/8thlight/vulcanizedb/pkg/geth" -) - -func min(a, b int64) int64 { - if a < b { - return a - } - return b -} - -const ( - windowSize = 24 - pollingInterval = 10 * time.Second -) - -func main() { - environment := flag.String("environment", "", "Environment name") - contractHash := flag.String("contract-hash", "", "Contract hash to show summary") - flag.Parse() - - ticker := time.NewTicker(pollingInterval) - defer ticker.Stop() - - contractHashLowered := strings.ToLower(*contractHash) - config := cmd.LoadConfig(*environment) - blockchain := geth.NewBlockchain(config.Client.IPCPath) - repository := cmd.LoadPostgres(config.Database, blockchain.Node()) - - lastBlockNumber := blockchain.LastBlock().Int64() - stepSize := int64(1000) - - go func() { - for i := int64(0); i < lastBlockNumber; i = min(i+stepSize, lastBlockNumber) { - logs, err := blockchain.GetLogs(core.Contract{Hash: contractHashLowered}, big.NewInt(i), big.NewInt(i+stepSize)) - log.Println("Backfilling Logs:", i) - if err != nil { - log.Println(err) - } - repository.CreateLogs(logs) - } - }() - - done := make(chan struct{}) - go func() { done <- struct{}{} }() - for range ticker.C { - select { - case <-done: - go func() { - z := &big.Int{} - z.Sub(blockchain.LastBlock(), big.NewInt(25)) - log.Printf("Logs Window: %d - %d", z.Int64(), blockchain.LastBlock().Int64()) - logs, _ := blockchain.GetLogs(core.Contract{Hash: contractHashLowered}, z, blockchain.LastBlock()) - repository.CreateLogs(logs) - done <- struct{}{} - }() - default: - } - } -}