Remove getLogs entrypoint
This commit is contained in:
parent
6583ce72b8
commit
0ae25aff95
@ -42,20 +42,6 @@ func tasks(p *do.Project) {
|
|||||||
do.M{"environment": environment, "startingNumber": startingNumber, "$in": "cmd/populate_blocks"})
|
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) {
|
p.Task("watchContract", nil, func(context *do.Context) {
|
||||||
environment := parseEnvironment(context)
|
environment := parseEnvironment(context)
|
||||||
contractHash := context.Args.MayString("", "contract-hash", "c")
|
contractHash := context.Args.MayString("", "contract-hash", "c")
|
||||||
|
@ -91,12 +91,6 @@ The name of the JSON file should correspond the contract's address.
|
|||||||
2. Start watching the contract `godo watchContract -- --environment=<some-environment> --contract-hash=<contract-address>`
|
2. Start watching the contract `godo watchContract -- --environment=<some-environment> --contract-hash=<contract-address>`
|
||||||
3. Request summary data `godo showContractSummary -- --environment=<some-environment> --contract-hash=<contract-address>`
|
3. Request summary data `godo showContractSummary -- --environment=<some-environment> --contract-hash=<contract-address>`
|
||||||
|
|
||||||
|
|
||||||
## Retrieving Contract Logs
|
|
||||||
|
|
||||||
1. Get the logs for a specific contract
|
|
||||||
- `godo getLogs -- --environment=<some-environment> --contract-hash=<contract-address>`
|
|
||||||
|
|
||||||
### Configuring Additional Environments
|
### Configuring Additional Environments
|
||||||
|
|
||||||
You can create configuration files for additional environments.
|
You can create configuration files for additional environments.
|
||||||
|
@ -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:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user