Skip to content

Commit

Permalink
feat(monitor): automatically clear data outside the coverage period (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
polebug authored Sep 9, 2024
1 parent 12a4e19 commit b1efd72
Show file tree
Hide file tree
Showing 19 changed files with 411 additions and 44 deletions.
11 changes: 8 additions & 3 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,17 @@ var command = cobra.Command{
return fmt.Errorf("init vsl client: %w", err)
}

networkParamsCaller, err = vsl.NewNetworkParamsCaller(vsl.AddressNetworkParams, vslClient)
chainID, err := vslClient.ChainID(context.Background())
if err != nil {
return fmt.Errorf("get chain id: %w", err)
}

networkParamsCaller, err = vsl.NewNetworkParamsCaller(vsl.AddressNetworkParams[chainID.Int64()], vslClient)
if err != nil {
return fmt.Errorf("new network params caller: %w", err)
}

settlementCaller, err = vsl.NewSettlementCaller(vsl.AddressSettlement, vslClient)
settlementCaller, err = vsl.NewSettlementCaller(vsl.AddressSettlement[chainID.Int64()], vslClient)
if err != nil {
return fmt.Errorf("new settlement caller: %w", err)
}
Expand All @@ -140,7 +145,7 @@ var command = cobra.Command{
}

// Convert big.Int to int64; safe as long as the value fits in int64.
blockStartInt64 := blockStart.Int64()
blockStartInt64 := blockStart.Block.Int64()

// Update the current block start for the network in Redis.
err := parameter.UpdateBlockStart(cmd.Context(), redisClient, network.String(), blockStartInt64)
Expand Down
7 changes: 4 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,10 @@ func (e Endpoint) BuildEthereumOptions() []ethereum.Option {
}

type Database struct {
Driver database.Driver `mapstructure:"driver" validate:"required" default:"postgres"`
Partition *bool `mapstructure:"partition" validate:"required" default:"true"`
URI string `mapstructure:"uri" validate:"required" default:"postgres://postgres@localhost:5432/postgres"`
CoveragePeriod int `mapstructure:"coverage_period" validate:"min=3,max=12" default:"3"`
Driver database.Driver `mapstructure:"driver" validate:"required" default:"postgres"`
Partition *bool `mapstructure:"partition" validate:"required" default:"true"`
URI string `mapstructure:"uri" validate:"required" default:"postgres://postgres@localhost:5432/postgres"`
}

type Stream struct {
Expand Down
9 changes: 6 additions & 3 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ component:
}
},
"database": {
"coverage_period": 3,
"driver": "postgres",
"partition": true,
"uri": "postgres://postgres@localhost:5432/postgres"
Expand Down Expand Up @@ -189,6 +190,7 @@ global_indexer_endpoint = "https://gi.rss3.dev/"
access_token = "test"
[database]
coverage_period = 3
driver = "postgres"
partition = true
uri = "postgres://postgres@localhost:5432/postgres"
Expand Down Expand Up @@ -316,9 +318,10 @@ var configFileExpected = &File{
},
},
Database: &Database{
Driver: "postgres",
Partition: lo.ToPtr(true),
URI: "postgres://postgres@localhost:5432/postgres",
CoveragePeriod: 3,
Driver: "postgres",
Partition: lo.ToPtr(true),
URI: "postgres://postgres@localhost:5432/postgres",
},
Stream: &Stream{
Enable: lo.ToPtr(false),
Expand Down
8 changes: 7 additions & 1 deletion config/parameter/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ import (
// NumberOfMonthsToCover the number of months that a Node should cover data for
const NumberOfMonthsToCover = 4

type StartBlock struct {
Block *big.Int `json:"block"`
Timestamp int64 `json:"timestamp"`
}

type NetworkTolerance map[network.Network]uint64
type NetworkStartBlock map[network.Network]*big.Int
type NetworkStartBlock map[network.Network]*StartBlock

type NetworkCoreWorkerDiskSpacePerMonth map[network.Network]uint

// CurrentNetworkTolerance should be updated each epoch from vsl
Expand Down
18 changes: 6 additions & 12 deletions config/parameter/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
"math/big"
"strconv"
"strings"

Expand All @@ -27,17 +26,17 @@ type NetworkParamsData struct {
// UnmarshalJSON defines a custom UnmarshalJSON method for NetworkParamsData
func (npd *NetworkParamsData) UnmarshalJSON(data []byte) error {
networkParam := struct {
NetworkTolerance map[string]uint64 `json:"network_tolerance"`
NetworkStartBlock map[string]*big.Int `json:"network_start_block"`
NetworkCoreWorkerDiskSpacePerMonth map[string]uint `json:"network_core_worker_disk_space_per_month"`
NetworkTolerance map[string]uint64 `json:"network_tolerance"`
NetworkStartBlock map[string]*StartBlock `json:"network_start_block"`
NetworkCoreWorkerDiskSpacePerMonth map[string]uint `json:"network_core_worker_disk_space_per_month"`
}{}

if err := json.Unmarshal(data, &networkParam); err != nil {
return err
}

npd.NetworkTolerance = make(map[network.Network]uint64)
npd.NetworkStartBlock = make(map[network.Network]*big.Int)
npd.NetworkStartBlock = make(map[network.Network]*StartBlock)
npd.NetworkCoreWorkerDiskSpacePerMonth = make(map[network.Network]uint)

for key, value := range networkParam.NetworkTolerance {
Expand Down Expand Up @@ -227,10 +226,8 @@ func buildNetworkBlockStartCacheKey(network string) string {

// InitVSLClient initializes the VSL client
func InitVSLClient() (ethereum.Client, error) {
vslEndpoint := endpoint.MustGet(network.VSL)

// Initialize vsl ethereum client.
vslClient, err := ethereum.Dial(context.Background(), vslEndpoint)
vslClient, err := ethereum.Dial(context.Background(), endpoint.MustGet(network.VSL))
if err != nil {
return nil, err
}
Expand All @@ -254,11 +251,8 @@ func CheckParamsTask(ctx context.Context, redisClient rueidis.Client, networkPar
continue // Skip if the start block is not defined.
}

// Convert big.Int to int64; safe as long as the value fits in int64.
blockStartInt64 := blockStart.Int64()

// Update the current block start for the network in Redis.
err := UpdateBlockStart(ctx, redisClient, n.String(), blockStartInt64)
err := UpdateBlockStart(ctx, redisClient, n.String(), blockStart.Block.Int64())
if err != nil {
return fmt.Errorf("update current block start: %w", err)
}
Expand Down
5 changes: 5 additions & 0 deletions deploy/config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ discovery:

# Database configuration
database:
# `coverage_period` is the number of months that the database will store the data, which cannot be less than three months.
coverage_period: 3
# `driver` is the database driver used by the Node, currently only `postgres` is supported
driver: postgres
# `partition` is used to enable the partition feature of the database.
partition: true
# `uri` is the connection string of the database.
uri: postgres://postgres:password@localhost:5432/postgres

# Deploying a redis will significantly improve the indexing performance of some workers.
Expand Down
1 change: 1 addition & 0 deletions deploy/min/config.min.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ discovery:
access_token: your_access_token

database:
coverage_period: 3
driver: postgres
partition: true
uri: postgres://postgres:password@rss3_node_database:5432/postgres
Expand Down
8 changes: 7 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/rss3-network/node

go 1.21.4
go 1.22

toolchain go1.22.1

require (
github.com/JohannesKaufmann/html-to-markdown v1.6.0
Expand Down Expand Up @@ -55,9 +57,11 @@ require (
github.com/adrianbrad/psqldocker v1.2.1
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0
github.com/emirpasic/gods v1.18.1
github.com/go-redsync/redsync/v4 v4.13.0
github.com/grafana/pyroscope-go v1.1.2
github.com/mitchellh/mapstructure v1.5.0
github.com/redis/rueidis v1.0.45
github.com/redis/rueidis/rueidiscompat v1.0.45
github.com/rss3-network/protocol-go v0.5.3
github.com/spf13/afero v1.11.0
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
Expand Down Expand Up @@ -109,6 +113,8 @@ require (
github.com/gorilla/websocket v1.5.0 // indirect
github.com/grafana/pyroscope-go/godeltaprof v0.1.8 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand Down
33 changes: 33 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5il
github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
github.com/docker/cli v26.1.1+incompatible h1:bE1/uE2tCa08fMv+7ikLR/RDPoCqytwrLtkIkSzxLvw=
Expand Down Expand Up @@ -136,14 +138,22 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.22.1 h1:40JcKH+bBNGFczGuoBYgX4I6m/i27HYW8P9FDk5PbgA=
github.com/go-playground/validator/v10 v10.22.1/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/go-redis/redis v6.15.9+incompatible h1:K0pv1D7EQUjfyoMql+r/jZqCLizCGKFlFgcHWWmHQjg=
github.com/go-redis/redis v6.15.9+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
github.com/go-redis/redis/v7 v7.4.1 h1:PASvf36gyUpr2zdOUS/9Zqc80GbM+9BDyiJSJDDOrTI=
github.com/go-redis/redis/v7 v7.4.1/go.mod h1:JDNMw23GTyLNC4GZu9njt15ctBQVn7xjRfnwdHj/Dcg=
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
github.com/go-redsync/redsync/v4 v4.13.0 h1:49X6GJfnbLGaIpBBREM/zA4uIMDXKAh1NDkvQ1EkZKA=
github.com/go-redsync/redsync/v4 v4.13.0/go.mod h1:HMW4Q224GZQz6x1Xc7040Yfgacukdzu7ifTDAKiyErQ=
github.com/go-shiori/dom v0.0.0-20210627111528-4e4722cd0d65 h1:zx4B0AiwqKDQq+AgqxWeHwbbLJQeidq20hgfP+aMNWI=
github.com/go-shiori/dom v0.0.0-20210627111528-4e4722cd0d65/go.mod h1:NPO1+buE6TYOWhUI98/hXLHHJhunIpXRuvDN4xjkCoE=
github.com/go-shiori/go-readability v0.0.0-20231029095239-6b97d5aba789 h1:G6wSuUyCoLB9jrUokipsmFuRi8aJozt3phw/g9Sl4Xs=
github.com/go-shiori/go-readability v0.0.0-20231029095239-6b97d5aba789/go.mod h1:2DpZlTJO/ycxp/vsc/C11oUyveStOgIXB88SYV1lncI=
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw=
github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
Expand All @@ -166,6 +176,8 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk=
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/gomodule/redigo v1.8.9 h1:Sl3u+2BI/kk+VEatbj0scLdrFhjPmbxOc1myhDP41ws=
github.com/gomodule/redigo v1.8.9/go.mod h1:7ArFNvsTjH8GMMzB4uy1snslv2BwmginuMs06a1uzZE=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
Expand All @@ -174,6 +186,8 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 h1:FKHo8hFI3A+7w0aUQuYXQ+6EN5stWmeY/AZqtM8xk9k=
github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
Expand All @@ -189,8 +203,13 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjw
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I=
github.com/hamba/avro v1.8.0 h1:eCVrLX7UYThA3R3yBZ+rpmafA5qTc3ZjpTz6gYJoVGU=
github.com/hamba/avro v1.8.0/go.mod h1:NiGUcrLLT+CKfGu5REWQtD9OVPPYUGMVFiC+DE0lQfY=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE=
github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0=
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
Expand Down Expand Up @@ -313,6 +332,8 @@ github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108
github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc=
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
github.com/onsi/ginkgo/v2 v2.20.1 h1:YlVIbqct+ZmnEph770q9Q7NVAz4wwIiVNahee6JyUzo=
github.com/onsi/ginkgo/v2 v2.20.1/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI=
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
Expand Down Expand Up @@ -348,8 +369,14 @@ github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G
github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8=
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/redis/go-redis/v9 v9.5.1 h1:H1X4D3yHPaYrkL5X06Wh6xNVM/pX0Ft4RV0vMGvLBh8=
github.com/redis/go-redis/v9 v9.5.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
github.com/redis/rueidis v1.0.45 h1:j7hfcqfLLIqgTK3IkxBhXdeJcP34t3XLXvorDLqXfgM=
github.com/redis/rueidis v1.0.45/go.mod h1:by+34b0cFXndxtYmPAHpoTHO5NkosDlBvhexoTURIxM=
github.com/redis/rueidis/mock v1.0.45 h1:r2LRiwOtFib8+NAuVxNmcdxL7IMUk3as9IGPzx2v5tA=
github.com/redis/rueidis/mock v1.0.45/go.mod h1:bjpk7ox5jwue03L8NpjgPBE91tLkm9Amla+XFYhaezc=
github.com/redis/rueidis/rueidiscompat v1.0.45 h1:G+3HIaETgtwr6aL6BOTFCa2DfpPDhxqcoiDn8cvd5Ps=
github.com/redis/rueidis/rueidiscompat v1.0.45/go.mod h1:JMw3cktmwNqsSl2npjcxrOfLa1L3rmj1Ox5aPHiDjOU=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
Expand Down Expand Up @@ -413,6 +440,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stvp/tempredis v0.0.0-20181119212430-b82af8480203 h1:QVqDTf3h2WHt08YuiTGPZLls0Wq99X9bWd0Q5ZSBesM=
github.com/stvp/tempredis v0.0.0-20181119212430-b82af8480203/go.mod h1:oqN97ltKNihBbwlX8dLpwxCl3+HnXKV/R0e+sRLd9C8=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4=
Expand Down Expand Up @@ -502,6 +531,8 @@ go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
Expand Down Expand Up @@ -620,6 +651,8 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24=
golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
2 changes: 2 additions & 0 deletions internal/database/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package database
import (
"context"
"database/sql"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/pressly/goose/v3"
Expand All @@ -28,6 +29,7 @@ type Client interface {
SaveActivities(ctx context.Context, activities []*activityx.Activity) error
FindActivity(ctx context.Context, query model.ActivityQuery) (*activityx.Activity, *int, error)
FindActivities(ctx context.Context, query model.ActivitiesQuery) ([]*activityx.Activity, error)
DeleteExpiredActivities(ctx context.Context, network network.Network, timestamp time.Time) error
}

type Session interface {
Expand Down
9 changes: 9 additions & 0 deletions internal/database/dialer/postgres/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,15 @@ func (c *client) FindActivities(ctx context.Context, query model.ActivitiesQuery
return nil, fmt.Errorf("not implemented")
}

// DeleteExpiredActivities deletes expired activities.
func (c *client) DeleteExpiredActivities(ctx context.Context, network networkx.Network, timestamp time.Time) error {
if c.partition {
return c.deleteExpiredActivitiesPartitioned(ctx, network, timestamp)
}

return fmt.Errorf("not implemented")
}

// LoadDatasetFarcasterProfile loads a profile.
func (c *client) LoadDatasetFarcasterProfile(ctx context.Context, fid int64) (*model.Profile, error) {
var value table.DatasetFarcasterProfile
Expand Down
Loading

0 comments on commit b1efd72

Please sign in to comment.