From 893debe7e375c521e3b154d06468899412cf32dd Mon Sep 17 00:00:00 2001 From: Argeric Date: Fri, 8 Mar 2024 14:40:10 +0800 Subject: [PATCH] Rename module. --- .gitignore | 2 +- Dockerfile | 6 +++--- README.md | 2 +- api/api.go | 16 ++++++++-------- api/stat_api.go | 4 ++-- api/tx_api.go | 4 ++-- api/types.go | 2 +- cmd/api.go | 6 +++--- cmd/data_context.go | 12 ++++++------ cmd/root.go | 7 ++++--- cmd/stat.go | 2 +- cmd/sync.go | 9 +++++---- contract/helper.go | 2 +- docker-compose.yml | 20 ++++++++++---------- docs/docs.go | 4 ++-- docs/swagger.json | 4 ++-- docs/swagger.yaml | 4 ++-- go.mod | 4 ++-- go.sum | 6 ++---- main.go | 4 ++-- stat/stat.go | 2 +- stat/stat_submit.go | 2 +- stat/stat_sync_status.go | 24 ++++++++++++------------ store/store_address.go | 12 ++++++------ store/store_submit.go | 2 +- sync/catchup.go | 10 +++++----- sync/storage.go | 4 ++-- sync/sync.go | 4 ++-- 28 files changed, 90 insertions(+), 90 deletions(-) diff --git a/.gitignore b/.gitignore index 8e4235e..5acd8a6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ *.dll *.so *.dylib -zerog-storage-scan +0g-storage-scan # Test binary, built with `go test -c` *.test diff --git a/Dockerfile b/Dockerfile index ce9d7fb..2b50fab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,13 +7,13 @@ COPY go.mod go.sum ./ # RUN GOPROXY=https://goproxy.cn,direct go mod download RUN go mod download COPY . . -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o zg-scan . +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o 0g-scan . # final target image for multi-stage builds FROM alpine:3.18 RUN apk --no-cache add ca-certificates RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 -COPY --from=builder /build/zg-scan . +COPY --from=builder /build/0g-scan . COPY ./config/config.yml ./config.yml -ENTRYPOINT [ "./zg-scan" ] +ENTRYPOINT [ "./0g-scan" ] CMD [ "--help" ] \ No newline at end of file diff --git a/README.md b/README.md index 87fcb4e..ddcd776 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# zerog-storage-scan +# 0g-storage-scan diff --git a/api/api.go b/api/api.go index 9e6d965..a67dfd3 100644 --- a/api/api.go +++ b/api/api.go @@ -1,16 +1,16 @@ package api import ( + nhContract "github.com/0glabs/0g-storage-scan/contract" + "github.com/0glabs/0g-storage-scan/docs" + "github.com/0glabs/0g-storage-scan/store" "github.com/Conflux-Chain/go-conflux-util/api" - viperutil "github.com/Conflux-Chain/go-conflux-util/viper" + viperUtil "github.com/Conflux-Chain/go-conflux-util/viper" "github.com/gin-gonic/gin" "github.com/openweb3/web3go" "github.com/sirupsen/logrus" swaggerFiles "github.com/swaggo/files" ginSwagger "github.com/swaggo/gin-swagger" - nhContract "github.com/zero-gravity-labs/zerog-storage-scan/contract" - "github.com/zero-gravity-labs/zerog-storage-scan/docs" - "github.com/zero-gravity-labs/zerog-storage-scan/store" ) const BasePath = "/api" @@ -28,7 +28,7 @@ func MustInit(client *web3go.Client, store *store.MysqlStore) { var charge struct { Erc20TokenAddress string } - viperutil.MustUnmarshalKey("charge", &charge) + viperUtil.MustUnmarshalKey("charge", &charge) name, symbol, decimals, err := nhContract.TokenInfo(client, charge.Erc20TokenAddress) if err != nil { @@ -46,12 +46,12 @@ func MustInit(client *web3go.Client, store *store.MysqlStore) { Address string SubmitEventSignature string } - viperutil.MustUnmarshalKey("flow", &flow) + viperUtil.MustUnmarshalKey("flow", &flow) } -// @title ZeroGStorage Scan API +// @title 0G Storage Scan API // @version 1.0 -// @description Use any http client to fetch data from the ZeroGStorage Scan. +// @description Use any http client to fetch data from the 0G Storage Scan. func init() { docs.SwaggerInfo.BasePath = BasePath } diff --git a/api/stat_api.go b/api/stat_api.go index f750a48..34895cf 100644 --- a/api/stat_api.go +++ b/api/stat_api.go @@ -3,10 +3,10 @@ package api import ( "encoding/json" + "github.com/0glabs/0g-storage-scan/stat" + "github.com/0glabs/0g-storage-scan/store" commonApi "github.com/Conflux-Chain/go-conflux-util/api" "github.com/gin-gonic/gin" - "github.com/zero-gravity-labs/zerog-storage-scan/stat" - "github.com/zero-gravity-labs/zerog-storage-scan/store" ) type Type int diff --git a/api/tx_api.go b/api/tx_api.go index 00a8d6d..4a09953 100644 --- a/api/tx_api.go +++ b/api/tx_api.go @@ -5,12 +5,12 @@ import ( "encoding/json" "strconv" + "github.com/0glabs/0g-storage-scan/store" commonApi "github.com/Conflux-Chain/go-conflux-util/api" "github.com/ethereum/go-ethereum/common" "github.com/gin-gonic/gin" "github.com/pkg/errors" "github.com/sirupsen/logrus" - "github.com/zero-gravity-labs/zerog-storage-scan/store" ) func listTx(c *gin.Context) (interface{}, error) { @@ -28,7 +28,7 @@ func listTx(c *gin.Context) (interface{}, error) { if !exist { return TxList{}, nil } - addrIDPtr = &addr.Id + addrIDPtr = &addr.ID } total, submits, err := listSubmits(addrIDPtr, param.RootHash, param.isDesc(), param.Skip, param.Limit) diff --git a/api/types.go b/api/types.go index ab13bb1..ef773c3 100644 --- a/api/types.go +++ b/api/types.go @@ -5,8 +5,8 @@ import ( "strings" "time" + "github.com/0glabs/0g-storage-scan/stat" "github.com/shopspring/decimal" - "github.com/zero-gravity-labs/zerog-storage-scan/stat" ) type PageParam struct { diff --git a/cmd/api.go b/cmd/api.go index 7c2d922..c397bd6 100644 --- a/cmd/api.go +++ b/cmd/api.go @@ -1,16 +1,16 @@ package cmd import ( + nhApi "github.com/0glabs/0g-storage-scan/api" "github.com/Conflux-Chain/go-conflux-util/api" "github.com/spf13/cobra" - nhApi "github.com/zero-gravity-labs/zerog-storage-scan/api" ) var ( apiCmd = &cobra.Command{ Use: "api", Short: "run rest api server", - Run: startApiService, + Run: startAPIService, } ) @@ -18,7 +18,7 @@ func init() { rootCmd.AddCommand(apiCmd) } -func startApiService(*cobra.Command, []string) { +func startAPIService(*cobra.Command, []string) { dataCtx := MustInitDataContext() defer dataCtx.Close() diff --git a/cmd/data_context.go b/cmd/data_context.go index bc20ef1..7da309d 100644 --- a/cmd/data_context.go +++ b/cmd/data_context.go @@ -8,13 +8,13 @@ import ( "syscall" "time" + "github.com/0glabs/0g-storage-client/node" + "github.com/0glabs/0g-storage-scan/store" "github.com/Conflux-Chain/go-conflux-util/store/mysql" "github.com/Conflux-Chain/go-conflux-util/viper" providers "github.com/openweb3/go-rpc-provider/provider_wrapper" "github.com/openweb3/web3go" "github.com/sirupsen/logrus" - "github.com/zero-gravity-labs/zerog-storage-client/node" - "github.com/zero-gravity-labs/zerog-storage-scan/store" ) // DataContext context to hold sdk clients for blockchain interoperation. @@ -25,7 +25,7 @@ type DataContext struct { } type SdkConfig struct { - Url string + URL string Retry int RetryInterval time.Duration `default:"1s"` RequestTimeout time.Duration `default:"3s"` @@ -33,7 +33,7 @@ type SdkConfig struct { } type L2SdkConfig struct { - Url string + URL string Retry int RetryInterval time.Duration `default:"1s"` RequestTimeout time.Duration `default:"3s"` @@ -62,7 +62,7 @@ func MustInitDataContext() DataContext { opt.WithRetry(sdkCfg.Retry, sdkCfg.RetryInterval). WithTimout(sdkCfg.RequestTimeout). WithMaxConnectionPerHost(sdkCfg.MaxConnsPerHost) - eth := web3go.MustNewClientWithOption(sdkCfg.Url, opt) + eth := web3go.MustNewClientWithOption(sdkCfg.URL, opt) l2SdkCfg := L2SdkConfig{} viper.MustUnmarshalKey("storage", &l2SdkCfg) @@ -70,7 +70,7 @@ func MustInitDataContext() DataContext { opt2.WithRetry(l2SdkCfg.Retry, l2SdkCfg.RetryInterval). WithTimout(l2SdkCfg.RequestTimeout). WithMaxConnectionPerHost(l2SdkCfg.MaxConnsPerHost) - l2Sdk := node.MustNewClient(l2SdkCfg.Url, opt2) + l2Sdk := node.MustNewClient(l2SdkCfg.URL, opt2) return DataContext{ DB: store.MustNewStore(db), diff --git a/cmd/root.go b/cmd/root.go index 45465e8..18ddd82 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -2,13 +2,14 @@ package cmd import ( "fmt" - "github.com/spf13/cobra" "os" + + "github.com/spf13/cobra" ) var rootCmd = &cobra.Command{ - Use: "zerog_storage", - Short: "Web3 storage scan on ZeroGStorage.", + Use: "0g_storage", + Short: "Web3 storage scan on 0G Storage.", } func Execute() { diff --git a/cmd/stat.go b/cmd/stat.go index 496629d..bb32c4d 100644 --- a/cmd/stat.go +++ b/cmd/stat.go @@ -4,10 +4,10 @@ import ( "context" "sync" + "github.com/0glabs/0g-storage-scan/stat" "github.com/Conflux-Chain/go-conflux-util/viper" "github.com/sirupsen/logrus" "github.com/spf13/cobra" - "github.com/zero-gravity-labs/zerog-storage-scan/stat" ) var ( diff --git a/cmd/sync.go b/cmd/sync.go index 6eae565..4607e21 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -2,11 +2,12 @@ package cmd import ( "context" - viperutil "github.com/Conflux-Chain/go-conflux-util/viper" + "sync" + + nhSync "github.com/0glabs/0g-storage-scan/sync" + viperUtil "github.com/Conflux-Chain/go-conflux-util/viper" "github.com/sirupsen/logrus" "github.com/spf13/cobra" - nhSync "github.com/zero-gravity-labs/zerog-storage-scan/sync" - "sync" ) var ( @@ -27,7 +28,7 @@ func startSyncService(*cobra.Command, []string) { defer dataCtx.Close() var conf nhSync.SyncConfig - viperutil.MustUnmarshalKey("sync", &conf) + viperUtil.MustUnmarshalKey("sync", &conf) cs := nhSync.MustNewCatchupSyncer(dataCtx.Eth, dataCtx.DB, conf) ss := nhSync.MustNewStorageSyncer(dataCtx.L2Sdk, dataCtx.DB) diff --git a/contract/helper.go b/contract/helper.go index 1ad539b..0de6869 100644 --- a/contract/helper.go +++ b/contract/helper.go @@ -1,9 +1,9 @@ package contract import ( + "github.com/0glabs/0g-storage-client/contract" "github.com/ethereum/go-ethereum/common" "github.com/openweb3/web3go" - "github.com/zero-gravity-labs/zerog-storage-client/contract" ) var ( diff --git a/docker-compose.yml b/docker-compose.yml index 83c7375..a31e3c2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,29 +3,29 @@ version: '3.3' services: sync: build: . - image: zg-scan:latest + image: 0g-scan:latest command: sync restart: unless-stopped environment: - - ZEROG_STORAGE_LOG_LEVEL=info + - 0G_SCAN_LOG_LEVEL=info network_mode: host - container_name: zerog-storage-sync + container_name: 0g-scan-sync stat: - image: zg-scan:latest + image: 0g-scan:latest command: stat restart: unless-stopped environment: - - ZEROG_STORAGE_LOG_LEVEL=info + - 0G_SCAN_LOG_LEVEL=info network_mode: host - container_name: zerog-storage-stat + container_name: 0g-scan-stat api: - image: zg-scan:latest + image: 0g-scan:latest command: api restart: unless-stopped environment: - - ZEROG_STORAGE_LOG_LEVEL=info - - ZEROG_STORAGE_API_ENDPOINT=:16451 + - 0G_SCAN_LOG_LEVEL=info + - 0G_SCAN_API_ENDPOINT=:16451 network_mode: host - container_name: zerog-storage-api + container_name: 0g-scan-api diff --git a/docs/docs.go b/docs/docs.go index 2a72f10..80785bb 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -826,8 +826,8 @@ var SwaggerInfo = &swag.Spec{ Host: "", BasePath: "", Schemes: []string{}, - Title: "ZeroGStorage Scan API", - Description: "Use any http client to fetch data from the ZeroGStorage Scan.", + Title: "0G Storage Scan API", + Description: "Use any http client to fetch data from the 0G Storage Scan.", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, LeftDelim: "{{", diff --git a/docs/swagger.json b/docs/swagger.json index fe7804f..a800f89 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -1,8 +1,8 @@ { "swagger": "2.0", "info": { - "description": "Use any http client to fetch data from the ZeroGStorage Scan.", - "title": "ZeroGStorage Scan API", + "description": "Use any http client to fetch data from the 0G Storage Scan.", + "title": "0G Storage Scan API", "contact": {}, "version": "1.0" }, diff --git a/docs/swagger.yaml b/docs/swagger.yaml index afd1b4e..ff6d795 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -201,8 +201,8 @@ definitions: type: object info: contact: {} - description: Use any http client to fetch data from the ZeroGStorage Scan. - title: ZeroGStorage Scan API + description: Use any http client to fetch data from the 0G Storage Scan. + title: 0G Storage Scan API version: "1.0" paths: /statistic/dashboard: diff --git a/go.mod b/go.mod index 2aa1e2d..b424ec3 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/zero-gravity-labs/zerog-storage-scan +module github.com/0glabs/0g-storage-scan go 1.21.0 @@ -16,11 +16,11 @@ require ( github.com/swaggo/files v1.0.1 github.com/swaggo/gin-swagger v1.6.0 github.com/swaggo/swag v1.16.2 - github.com/zero-gravity-labs/zerog-storage-client v0.1.14-0.20240229065452-bbb5632981ab gorm.io/gorm v1.25.4 ) require ( + github.com/0glabs/0g-storage-client v0.1.14-0.20240310090450-1d09ec4f0b9c // indirect github.com/DataDog/zstd v1.5.2 // indirect github.com/KyleBanks/depth v1.2.1 // indirect github.com/VictoriaMetrics/fastcache v1.6.0 // indirect diff --git a/go.sum b/go.sum index bb252eb..0a836d9 100644 --- a/go.sum +++ b/go.sum @@ -51,6 +51,8 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/0glabs/0g-storage-client v0.1.14-0.20240310090450-1d09ec4f0b9c h1:mo2hT+XRtAsCgHC0ZeZYLGJym1e+p1hIZnYF0BbiQEA= +github.com/0glabs/0g-storage-client v0.1.14-0.20240310090450-1d09ec4f0b9c/go.mod h1:2kfJKoBvt0Oz1akx0cEX/itYkyNgehHM/UjIPZW6InA= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4= github.com/Azure/azure-pipeline-go v0.2.2/go.mod h1:4rQ/NZncSvGqNkkOsNpOU1tgoNuIlp9AfUH5G1tvCHc= @@ -935,10 +937,6 @@ github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1 github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= -github.com/zero-gravity-labs/zerog-storage-client v0.1.12 h1:jIHUfhAw3KREyqMuksJ/2K9pLl/9uN9c317mJuHadKY= -github.com/zero-gravity-labs/zerog-storage-client v0.1.12/go.mod h1:X0u50IkiCmB9hchf8mEiIWyk6bLlo0d2xAxrPPK8IZ4= -github.com/zero-gravity-labs/zerog-storage-client v0.1.14-0.20240229065452-bbb5632981ab h1:/F2e3PaQNSdonkM4gfvKmnGnfNfl1nQZQJyeisB5lTM= -github.com/zero-gravity-labs/zerog-storage-client v0.1.14-0.20240229065452-bbb5632981ab/go.mod h1:X0u50IkiCmB9hchf8mEiIWyk6bLlo0d2xAxrPPK8IZ4= go.etcd.io/etcd/api/v3 v3.5.1/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= go.etcd.io/etcd/client/pkg/v3 v3.5.1/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= go.etcd.io/etcd/client/v2 v2.305.1/go.mod h1:pMEacxZW7o8pg4CrFE7pquyCJJzZvkvdD2RibOCCCGs= diff --git a/main.go b/main.go index 029f426..dfc0f1f 100644 --- a/main.go +++ b/main.go @@ -1,11 +1,11 @@ package main import ( + "github.com/0glabs/0g-storage-scan/cmd" "github.com/Conflux-Chain/go-conflux-util/config" - "github.com/zero-gravity-labs/zerog-storage-scan/cmd" ) func main() { - config.MustInit("zerog_storage") + config.MustInit("0g_scan") cmd.Execute() } diff --git a/stat/stat.go b/stat/stat.go index 24635fb..b2e8b4f 100644 --- a/stat/stat.go +++ b/stat/stat.go @@ -5,12 +5,12 @@ import ( "sync" "time" + "github.com/0glabs/0g-storage-scan/store" "github.com/Conflux-Chain/go-conflux-util/viper" "github.com/openweb3/web3go" "github.com/openweb3/web3go/types" "github.com/pkg/errors" "github.com/sirupsen/logrus" - "github.com/zero-gravity-labs/zerog-storage-scan/store" ) var ( diff --git a/stat/stat_submit.go b/stat/stat_submit.go index 1245491..beebd0b 100644 --- a/stat/stat_submit.go +++ b/stat/stat_submit.go @@ -3,9 +3,9 @@ package stat import ( "time" + "github.com/0glabs/0g-storage-scan/store" "github.com/openweb3/web3go" "github.com/pkg/errors" - "github.com/zero-gravity-labs/zerog-storage-scan/store" "gorm.io/gorm" ) diff --git a/stat/stat_sync_status.go b/stat/stat_sync_status.go index 9d3d2ba..752d0de 100644 --- a/stat/stat_sync_status.go +++ b/stat/stat_sync_status.go @@ -6,11 +6,11 @@ import ( "sync" "time" - viperutil "github.com/Conflux-Chain/go-conflux-util/viper" + "github.com/0glabs/0g-storage-client/node" + "github.com/0glabs/0g-storage-scan/store" + viperUtil "github.com/Conflux-Chain/go-conflux-util/viper" "github.com/pkg/errors" "github.com/sirupsen/logrus" - "github.com/zero-gravity-labs/zerog-storage-client/node" - "github.com/zero-gravity-labs/zerog-storage-scan/store" "gorm.io/gorm" ) @@ -24,7 +24,7 @@ func MustNewSyncStatusStat(db *store.MysqlStore, l2Sdk *node.Client) *LogSyncInf var stat struct { StatIntervalSyncStatus time.Duration `default:"1s"` } - viperutil.MustUnmarshalKey("stat", &stat) + viperUtil.MustUnmarshalKey("stat", &stat) return &LogSyncInfoStat{ db: db, @@ -45,29 +45,29 @@ func (s *LogSyncInfoStat) DoStat(ctx context.Context, wg *sync.WaitGroup) { default: } - var submit store.Submit - err := s.db.Store.DB.Last(&submit).Error + var block store.Block + err := s.db.Store.DB.Last(&block).Error if errors.Is(err, gorm.ErrRecordNotFound) { - logrus.WithError(err).Info("No submit record to update log sync info") + logrus.WithError(err).Info("No block record to update log sync info") time.Sleep(10 * time.Second) continue } if err != nil { - logrus.WithError(err).Error("Failed to get submit record to update log sync info") + logrus.WithError(err).Error("Failed to get block record to update log sync info") time.Sleep(10 * time.Second) continue } - zgStatus, err := s.l2Sdk.ZeroGStorage().GetStatus() + nodeStatus, err := s.l2Sdk.ZeroGStorage().GetStatus() if err != nil { - logrus.WithError(err).Error("Failed to get zg status to update log sync info") + logrus.WithError(err).Error("Failed to get storage node status to update log sync info") time.Sleep(10 * time.Second) continue } status := LogSyncInfo{ - LogSyncHeight: submit.BlockNumber, - L2LogSyncHeight: zgStatus.LogSyncHeight, + LogSyncHeight: block.BlockNumber, + L2LogSyncHeight: nodeStatus.LogSyncHeight, } statusBytes, err := json.Marshal(status) if err != nil { diff --git a/store/store_address.go b/store/store_address.go index f5e1de0..54eccb8 100644 --- a/store/store_address.go +++ b/store/store_address.go @@ -8,7 +8,7 @@ import ( ) type Address struct { - Id uint64 + ID uint64 Address string `gorm:"size:64;unique"` BlockTime time.Time `gorm:"not null"` } @@ -34,7 +34,7 @@ func (as *AddressStore) Add(address string, blockTime time.Time) (uint64, error) return 0, err } if existed { - return addr.Id, nil + return addr.ID, nil } addr = Address{ @@ -46,20 +46,20 @@ func (as *AddressStore) Add(address string, blockTime time.Time) (uint64, error) return 0, err } - return addr.Id, nil + return addr.ID, nil } // BatchGetAddresses TODO LRU cache -func (as *AddressStore) BatchGetAddresses(addrIds []uint64) (map[uint64]Address, error) { +func (as *AddressStore) BatchGetAddresses(addrIDs []uint64) (map[uint64]Address, error) { addresses := new([]Address) - err := as.DB.Raw("select * from addresses where id in ?", addrIds).Scan(addresses).Error + err := as.DB.Raw("select * from addresses where id in ?", addrIDs).Scan(addresses).Error if err != nil { return nil, err } m := make(map[uint64]Address) for _, addr := range *addresses { - m[addr.Id] = addr + m[addr.ID] = addr } return m, nil diff --git a/store/store_submit.go b/store/store_submit.go index 49209a4..4adbdcd 100644 --- a/store/store_submit.go +++ b/store/store_submit.go @@ -5,11 +5,11 @@ import ( "math/big" "time" + "github.com/0glabs/0g-storage-client/contract" "github.com/Conflux-Chain/go-conflux-util/store/mysql" "github.com/ethereum/go-ethereum/common" "github.com/openweb3/web3go/types" "github.com/shopspring/decimal" - "github.com/zero-gravity-labs/zerog-storage-client/contract" "gorm.io/gorm" ) diff --git a/sync/catchup.go b/sync/catchup.go index 3f89c3b..871b2ca 100644 --- a/sync/catchup.go +++ b/sync/catchup.go @@ -6,14 +6,14 @@ import ( "strings" "time" - viperutil "github.com/Conflux-Chain/go-conflux-util/viper" + nhContract "github.com/0glabs/0g-storage-scan/contract" + "github.com/0glabs/0g-storage-scan/store" + viperUtil "github.com/Conflux-Chain/go-conflux-util/viper" "github.com/ethereum/go-ethereum/common" "github.com/openweb3/web3go" "github.com/openweb3/web3go/types" "github.com/pkg/errors" "github.com/sirupsen/logrus" - nhContract "github.com/zero-gravity-labs/zerog-storage-scan/contract" - "github.com/zero-gravity-labs/zerog-storage-scan/store" ) type CatchupSyncer struct { @@ -31,13 +31,13 @@ func MustNewCatchupSyncer(sdk *web3go.Client, db *store.MysqlStore, conf SyncCon Address string SubmitEventSignature string } - viperutil.MustUnmarshalKey("flow", &flow) + viperUtil.MustUnmarshalKey("flow", &flow) var charge struct { Erc20TokenAddress string Erc20TransferEventSignature string } - viperutil.MustUnmarshalKey("charge", &charge) + viperUtil.MustUnmarshalKey("charge", &charge) return &CatchupSyncer{ conf: &conf, diff --git a/sync/storage.go b/sync/storage.go index 2a59927..480116c 100644 --- a/sync/storage.go +++ b/sync/storage.go @@ -4,10 +4,10 @@ import ( "context" "time" + "github.com/0glabs/0g-storage-client/node" + "github.com/0glabs/0g-storage-scan/store" "github.com/pkg/errors" "github.com/sirupsen/logrus" - "github.com/zero-gravity-labs/zerog-storage-client/node" - "github.com/zero-gravity-labs/zerog-storage-scan/store" ) var ( diff --git a/sync/sync.go b/sync/sync.go index be4ed78..32dc9ef 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -6,14 +6,14 @@ import ( "sync" "time" + nhContract "github.com/0glabs/0g-storage-scan/contract" + "github.com/0glabs/0g-storage-scan/store" viperUtil "github.com/Conflux-Chain/go-conflux-util/viper" "github.com/ethereum/go-ethereum/common" "github.com/openweb3/web3go" "github.com/openweb3/web3go/types" "github.com/pkg/errors" "github.com/sirupsen/logrus" - nhContract "github.com/zero-gravity-labs/zerog-storage-scan/contract" - "github.com/zero-gravity-labs/zerog-storage-scan/store" ) type SyncConfig struct {