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

Rename module. #14

Merged
merged 1 commit into from
Mar 11, 2024
Merged
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*.dll
*.so
*.dylib
zerog-storage-scan
0g-storage-scan

# Test binary, built with `go test -c`
*.test
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# zerog-storage-scan
# 0g-storage-scan
16 changes: 8 additions & 8 deletions api/api.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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 {
Expand All @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions api/stat_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions api/tx_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions cmd/api.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
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,
}
)

func init() {
rootCmd.AddCommand(apiCmd)
}

func startApiService(*cobra.Command, []string) {
func startAPIService(*cobra.Command, []string) {
dataCtx := MustInitDataContext()
defer dataCtx.Close()

Expand Down
12 changes: 6 additions & 6 deletions cmd/data_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -25,15 +25,15 @@ type DataContext struct {
}

type SdkConfig struct {
Url string
URL string
Retry int
RetryInterval time.Duration `default:"1s"`
RequestTimeout time.Duration `default:"3s"`
MaxConnsPerHost int `default:"1024"`
}

type L2SdkConfig struct {
Url string
URL string
Retry int
RetryInterval time.Duration `default:"1s"`
RequestTimeout time.Duration `default:"3s"`
Expand Down Expand Up @@ -62,15 +62,15 @@ 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)
opt2 := providers.Option{}
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),
Expand Down
7 changes: 4 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
9 changes: 5 additions & 4 deletions cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion contract/helper.go
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down
20 changes: 10 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: "{{",
Expand Down
4 changes: 2 additions & 2 deletions docs/swagger.json
Original file line number Diff line number Diff line change
@@ -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"
},
Expand Down
4 changes: 2 additions & 2 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/zero-gravity-labs/zerog-storage-scan
module github.com/0glabs/0g-storage-scan

go 1.21.0

Expand All @@ -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
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -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()
}
Loading
Loading