Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:

steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Lowercase Repository Name
id: repository
Expand All @@ -47,6 +47,7 @@ jobs:
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64,linux/arm64/v8
context: .
file: ./Dockerfile
push: true
Expand All @@ -58,6 +59,7 @@ jobs:
if: startsWith(github.ref, 'refs/heads/main')
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64,linux/arm64/v8
context: .
file: ./Dockerfile
push: true
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:

steps:
- name: Set Up Go
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version: '1.24'

- name: Check Out
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Code Style Check
uses: golangci/golangci-lint-action@v7
uses: golangci/golangci-lint-action@v8
with:
version: v2.0.1
version: v2.5.0
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ jobs:

steps:
- name: Set Up Go
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version: '1.24'

- name: Check Out
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Run Tests
run: go test -v ./...
13 changes: 10 additions & 3 deletions cmd/watcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func main() { //nolint:funlen
blockChan := make(chan entities.Block, chainConfig.Workers.BlockTransactionsWorkerCount)
txIDChan := make(chan entities.TxID, chainConfig.Workers.TxIDWorkerCount)

blocksState := state.NewPersister[entities.BlockHash](chainConfig.Persist, dbRepository)
blocksState := state.NewMemoryState[entities.BlockHash](chainConfig.Persist)
blocksPublisher := redis.NewPublisher[entities.Block](redisClient)
transactionsPublisher := redis.NewPublisher[entities.Transaction](redisClient)

Expand Down Expand Up @@ -111,9 +111,15 @@ func main() { //nolint:funlen
oldMempool,
usecase.MempoolJobMetrics{RequestToNodeCounter: requestsToNodeMetric},
)
statePersisterJob := usecase.NewBlocksPersisterJob(
chainConfig,
dbRepository,
blocksState,
)

blockTicker := runner.NewTicker(chainConfig.Key("blocks"), chainConfig.Scan.Interval, blocksJob)
mempoolTicker := runner.NewTicker(chainConfig.Key("mempool"), chainConfig.Scan.Interval, mempoolJob)
statePersisterTicker := runner.NewTicker(chainConfig.Key("persister"), chainConfig.Scan.Interval, statePersisterJob)

txIDHandler := usecase.NewTxIDHandler(
chainConfig,
Expand All @@ -128,13 +134,13 @@ func main() { //nolint:funlen
usecase.BlockTransactionsHandlerMetrics{RequestToNodeCounter: requestsToNodeMetric},
)

txIDWorker := runner.NewWorker(
txIDWorker := runner.NewWorker[entities.TxID](
chainConfig.Key("txid"),
chainConfig.Workers.TxIDWorkerCount,
txIDChan,
txIDHandler,
)
blockTransactionWorker := runner.NewWorker(
blockTransactionWorker := runner.NewWorker[entities.Block](
chainConfig.Key("block_transactions"),
chainConfig.Workers.BlockTransactionsWorkerCount,
blockChan,
Expand All @@ -146,6 +152,7 @@ func main() { //nolint:funlen
//
blockTicker.Run,
mempoolTicker.Run,
statePersisterTicker.Run,
//
txIDWorker.Run,
blockTransactionWorker.Run,
Expand Down
2 changes: 1 addition & 1 deletion configs/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type ScanConfig struct {

type PersistConfig struct {
Capacity int `yaml:"capacity"`
Duration time.Duration `yaml:"duration"`
Interval time.Duration `yaml:"interval"`
}

type WorkersConfig struct {
Expand Down
6 changes: 1 addition & 5 deletions configs/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package configs

import (
"fmt"

"github.com/LiquidCats/watcher/v2/pkg/docker"
)

type DB struct {
Expand All @@ -16,13 +14,11 @@ type DB struct {
}

func (d *DB) ToDSN() string {
pwd, _ := docker.GetSecret(d.Password)

return fmt.Sprintf(
"%s://%s:%s@%s:%s/%s?sslmode=disable",
d.Driver,
d.User,
pwd,
d.Password,
d.Host,
d.Port,
d.Database,
Expand Down
14 changes: 9 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ services:
<<: *app-env
volumes:
- .:/app
- godeps:/go
depends_on:
- postgres
- redis
- btc
- eth

postgres:
image: postgres:alpine
image: postgres:17-alpine
environment:
POSTGRES_USER: watcher_db_user
POSTGRES_PASSWORD: watcher_db_secret
Expand All @@ -39,12 +39,14 @@ services:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"

redis:
image: redis:alpine
image: redis:8-alpine
ports:
- "6379:6379"
volumes:
- redis_data:/data

btc:
user: 1000:1000
image: lncm/bitcoind:v28.0
Expand Down Expand Up @@ -78,4 +80,6 @@ volumes:
btc:
eth:
postgres_data:
redis_data:
redis_data:
godeps:
external: true
65 changes: 34 additions & 31 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,73 +3,76 @@ module github.com/LiquidCats/watcher/v2
go 1.24.2

require (
github.com/LiquidCats/graceful v0.0.4
github.com/LiquidCats/jsonrpc v0.0.1
github.com/bytedance/sonic v1.13.3
github.com/bytedance/sonic v1.14.1
github.com/gin-contrib/logger v1.2.6
github.com/gin-gonic/gin v1.10.1
github.com/golang-migrate/migrate/v4 v4.18.3
github.com/jackc/pgx/v5 v5.7.5
github.com/gin-gonic/gin v1.11.0
github.com/golang-migrate/migrate/v4 v4.19.0
github.com/jackc/pgx/v5 v5.7.6
github.com/kelseyhightower/envconfig v1.4.0
github.com/lib/pq v1.10.9
github.com/prometheus/client_golang v1.22.0
github.com/redis/go-redis/v9 v9.11.0
github.com/prometheus/client_golang v1.23.2
github.com/redis/go-redis/v9 v9.14.0
github.com/rotisserie/eris v0.5.4
github.com/rs/zerolog v1.34.0
github.com/shopspring/decimal v1.4.0
github.com/stretchr/testify v1.10.0
github.com/stretchr/testify v1.11.1
go.uber.org/automaxprocs v1.6.0
golang.org/x/sync v0.15.0
golang.org/x/sync v0.17.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
)

require (
github.com/LiquidCats/graceful v0.0.3
github.com/beorn7/perks v1.0.1 // indirect
github.com/bytedance/gopkg v0.1.3 // indirect
github.com/bytedance/sonic/loader v0.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cloudwego/base64x v0.1.5 // indirect
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cloudwego/base64x v0.1.6 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/gabriel-vasile/mimetype v1.4.9 // indirect
github.com/gabriel-vasile/mimetype v1.4.10 // indirect
github.com/gin-contrib/sse v1.1.0 // indirect
github.com/go-faster/errors v0.7.1 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.27.0 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/goccy/go-yaml v1.18.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/jackc/pgerrcode v0.0.0-20240316143900-6e2875d9b438 // indirect
github.com/jackc/pgerrcode v0.0.0-20250907135507-afb5586c32a6 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.11 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.65.0 // indirect
github.com/prometheus/common v0.67.1 // indirect
github.com/prometheus/procfs v0.17.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/quic-go/qpack v0.5.1 // indirect
github.com/quic-go/quic-go v0.55.0 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/stretchr/objx v0.5.3 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.3.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
golang.org/x/arch v0.18.0 // indirect
golang.org/x/crypto v0.39.0 // indirect
golang.org/x/net v0.41.0 // indirect
golang.org/x/sys v0.33.0 // indirect
golang.org/x/text v0.26.0 // indirect
google.golang.org/protobuf v1.36.6 // indirect
go.uber.org/mock v0.6.0 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
golang.org/x/arch v0.22.0 // indirect
golang.org/x/crypto v0.43.0 // indirect
golang.org/x/mod v0.28.0 // indirect
golang.org/x/net v0.45.0 // indirect
golang.org/x/sys v0.37.0 // indirect
golang.org/x/text v0.30.0 // indirect
golang.org/x/tools v0.37.0 // indirect
google.golang.org/protobuf v1.36.10 // indirect
)
Loading
Loading