Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

69 add new ip location service using ip2location local dbs #70

Open
wants to merge 3 commits into
base: 69-add-new-ip-location-service-using-ip2location-local-dbs
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env_template
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ CRAWLER_FORK_DIGEST="0x4a26c58b"
CRAWLER_GOSSIP_TOPIC="beacon_block"
CRAWLER_SUBNET="all"
CRAWLER_PERSIST_CONNEVENTS="false"
IP2LOCATION_TOKEN=""
3 changes: 3 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ services:
build:
context: .
dockerfile: Dockerfile
env_file: .env
command: |
eth2
--log-level=${CRAWLER_LOG_LEVEL}
Expand All @@ -72,3 +73,5 @@ services:
ports:
- "${CRAWLER_PORT}:9020"
- "127.0.0.1:${CRAWLER_METRICS_PORT}:9080"
volumes:
- ./pkg/utils/apis/database:/app/database
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ require (
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/holiman/uint256 v1.2.0 // indirect
github.com/huin/goupnp v1.0.2 // indirect
github.com/ip2location/ip2location-go/v9 v9.6.1 // indirect
github.com/ip2location/ip2proxy-go/v4 v4.0.1 // indirect
github.com/ipfs/go-cid v0.0.7 // indirect
github.com/ipfs/go-datastore v0.5.0 // indirect
github.com/ipfs/go-ipfs-util v0.0.2 // indirect
Expand Down Expand Up @@ -159,6 +161,7 @@ require (
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/uint128 v1.2.0 // indirect
)

replace github.com/libp2p/go-libp2p-pubsub v0.5.5 => ./go-libp2p-pubsub
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,8 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y
github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE=
github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0=
github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po=
github.com/ip2location/ip2proxy-go/v4 v4.0.1 h1:n63WK4EYsXqt5hXHvHABknRYZEnVFqF/KX3xx84Zw8I=
github.com/ip2location/ip2proxy-go/v4 v4.0.1/go.mod h1:knSLTGvow2tCTxGuZNACMiqRW7h9u/F7KFrPa8HBJ8U=
github.com/ipfs/go-cid v0.0.1/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM=
github.com/ipfs/go-cid v0.0.2/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM=
github.com/ipfs/go-cid v0.0.3/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM=
Expand Down Expand Up @@ -1813,6 +1815,8 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las=
lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI=
lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
Expand Down
12 changes: 6 additions & 6 deletions pkg/crawler/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ func NewEthereumCrawler(mainCtx *cli.Context, conf config.EthereumCrawlerConfig)
return nil, err
}
dbClient, err := psql.NewDBClient(
ctx,
ethNode.Network(),
conf.PsqlEndpoint,
backupInterval,
psql.InitializeTables(true),
psql.WithConnectionEventsPersist(conf.PersistConnEvents),
ctx,
ethNode.Network(),
conf.PsqlEndpoint,
backupInterval,
psql.InitializeTables(true),
psql.WithConnectionEventsPersist(conf.PersistConnEvents),
)
if err != nil {
cancel()
Expand Down
11 changes: 6 additions & 5 deletions pkg/db/models/ip.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package models

import "time"
import (
"time"
)

const (
IpInfoTTL = 30 * 24 * time.Hour // 30 days
Expand Down Expand Up @@ -35,10 +37,9 @@ func (m *IpApiMsg) IsEmpty() bool {
}

type ApiResp struct {
IpInfo IpInfo
DelayTime time.Duration
AttemptsLeft int
Err error
IpInfo IpInfo
DelayTime time.Duration
Err error
}

type IpInfo struct {
Expand Down
Loading