Commit c9d8c942 authored by 贾浩@五瓣科技's avatar 贾浩@五瓣科技

init

parents
.idea
*.iml
out
gen
*.sol
*.txt
.DS_Store
*.exe
build
\ No newline at end of file
.PHONY: default all clean dev
GOBIN = $(shell pwd)/build
GOVERSION=$(shell go version | awk '{print $$3}')
GITHASH=$(shell git show -s --format=%H)
GITBRANCH=$(shell git symbolic-ref --short -q HEAD)
BUILDTIME=$(shell git show -s --format=%cd)
default: all
all: clean witness
BUILD_FLAGS=-ldflags "\
-X 'witness/version.GOVersion=$(GOVERSION)' \
-X 'witness/version.GitHash=$(GITHASH)' \
-X 'witness/version.BuildTime=$(BUILDTIME)' \
-X 'witness/version.GitBranch=$(GITBRANCH)'"
witness:
# go build -o MetaNet
go build $(BUILD_FLAGS) -o=${GOBIN}/$@ ./cmd
dev:
go build $(BUILD_FLAGS) -o=${GOBIN}/$@ -gcflags "all=-N -l" ./cmd
clean:
rm -fr build
package api
package api
package api
import (
"github.com/prometheus/client_golang/prometheus"
)
var (
_ = prometheus.AlreadyRegisteredError{}
)
package api
package main
import (
"fmt"
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v2/altsrc"
)
var (
configFileFlag = &cli.StringFlag{
Name: "config",
Aliases: []string{"c"},
Usage: "The path to the config file",
}
grpcListenAddrFlag = &cli.StringFlag{
Name: "grpc-listen",
Usage: "The listen address of the grpc server",
Value: "0.0.0.0:9430",
}
rpcListenAddrFlag = &cli.StringFlag{
Name: "rpc-listen",
Usage: "The listen address of the jsonrpc server",
Value: "0.0.0.0:9431",
}
rpcHostFlag = &cli.StringFlag{
Name: "chain-rpc",
Usage: "The host of the chain json rpc server",
}
storeContractFlag = &cli.StringFlag{
Name: "store-contract",
Usage: "The address of the store contract",
}
rewardContractFlag = &cli.StringFlag{
Name: "reward-contract",
Usage: "The address of the reward contract",
}
)
func loadFlagsFromConfig(cliCtx *cli.Context, flags []cli.Flag) error {
if cliCtx.IsSet(configFileFlag.Name) {
return altsrc.InitInputSourceWithContext(
flags,
altsrc.NewTomlSourceFromFlagFunc(configFileFlag.Name),
)(cliCtx)
}
return nil
}
// WrapFlags so that they can be loaded from alternative sources.
func wrapFlags(flags []cli.Flag) []cli.Flag {
wrapped := make([]cli.Flag, 0, len(flags))
for _, f := range flags {
switch t := f.(type) {
case *cli.BoolFlag:
f = altsrc.NewBoolFlag(t)
case *cli.DurationFlag:
f = altsrc.NewDurationFlag(t)
case *cli.GenericFlag:
f = altsrc.NewGenericFlag(t)
case *cli.Float64Flag:
f = altsrc.NewFloat64Flag(t)
case *cli.IntFlag:
f = altsrc.NewIntFlag(t)
case *cli.StringFlag:
f = altsrc.NewStringFlag(t)
case *cli.StringSliceFlag:
f = altsrc.NewStringSliceFlag(t)
case *cli.Uint64Flag:
f = altsrc.NewUint64Flag(t)
case *cli.UintFlag:
f = altsrc.NewUintFlag(t)
case *cli.PathFlag:
f = altsrc.NewPathFlag(t)
case *cli.Int64Flag:
// Int64Flag does not work. See https://github.com/prysmaticlabs/prysm/issues/6478
panic(fmt.Sprintf("unsupported flag type type %T", f))
case *cli.IntSliceFlag:
f = altsrc.NewIntSliceFlag(t)
default:
panic(fmt.Sprintf("cannot convert type %T", f))
}
wrapped = append(wrapped, f)
}
return wrapped
}
package main
import (
"fmt"
"os"
"witness/version"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)
var (
appFlags = []cli.Flag{
configFileFlag,
grpcListenAddrFlag,
rpcListenAddrFlag,
rpcHostFlag,
storeContractFlag,
rewardContractFlag,
}
)
func main() {
// run()
fmt.Println(version.GOVersion)
}
func run() {
app := cli.App{}
app.Name = "witness"
app.Usage = "this is witness"
app.Version = version.Version
app.Before = func(c *cli.Context) error {
return loadFlagsFromConfig(c, appFlags)
}
if err := app.Run(os.Args); err != nil {
log.Error(err)
}
}
grpc-listen = "0.0.0.0:9430"
rpc-listen = "0.0.0.0:9431"
chain-rpc = "https://1rpc.io/eth"
store-contract = "0x0000000000000000000000000000000000000000"
reward-contract = "0x0000000000000000000000000000000000000000"
\ No newline at end of file
package core
module witness
go 1.19
require (
github.com/prometheus/client_golang v1.18.0
github.com/sirupsen/logrus v1.9.3
github.com/urfave/cli/v2 v2.27.1
)
require (
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e // indirect
golang.org/x/sys v0.16.0 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg=
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk=
github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA=
github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw=
github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI=
github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM=
github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY=
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho=
github.com/urfave/cli/v2 v2.27.1/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e h1:+SOyEddqYF09QP7vr7CgJ1eti3pY9Fn3LHO1M1r/0sI=
github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
# aigic witness
\ No newline at end of file
package version
var (
GitHash, GitBranch, BuildTime, GOVersion, Version string
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment