From ed14e1a0c18368552f1ecc401d24123846d7be8a Mon Sep 17 00:00:00 2001 From: AstaFrode Date: Tue, 4 Jul 2023 18:55:45 +0800 Subject: [PATCH] update sdk to v0.2.9 (#127) --- cmd/console/runCmd.go | 58 +++++++++++++++++++++---------------------- go.mod | 4 +-- go.sum | 8 +++--- 3 files changed, 34 insertions(+), 36 deletions(-) diff --git a/cmd/console/runCmd.go b/cmd/console/runCmd.go index 80adb616..ac712ca5 100644 --- a/cmd/console/runCmd.go +++ b/cmd/console/runCmd.go @@ -25,25 +25,22 @@ import ( cess "github.com/CESSProject/cess-go-sdk" "github.com/CESSProject/cess-go-sdk/config" "github.com/CESSProject/cess-go-sdk/core/pattern" - sutils "github.com/CESSProject/cess-go-sdk/core/utils" "github.com/howeyc/gopass" - "github.com/libp2p/go-libp2p/core/peer" - ma "github.com/multiformats/go-multiaddr" "github.com/spf13/cobra" ) // runCmd is used to start the service func runCmd(cmd *cobra.Command, args []string) { var ( - firstReg bool - err error - logDir string - cacheDir string - earnings string - token uint64 - syncSt pattern.SysSyncState - bootstrap = make([]string, 0) - n = node.New() + firstReg bool + err error + logDir string + cacheDir string + earnings string + token uint64 + syncSt pattern.SysSyncState + protocolPrefix string + n = node.New() ) // Build profile instances @@ -54,23 +51,21 @@ func runCmd(cmd *cobra.Command, args []string) { } boots := n.GetBootNodes() - for _, b := range boots { - bootnodes, err := sutils.ParseMultiaddrs(b) - if err != nil { - continue - } - bootstrap = append(bootstrap, bootnodes...) - for _, v := range bootnodes { - configs.Tip(fmt.Sprintf("bootstrap node: %v", v)) - addr, err := ma.NewMultiaddr(v) - if err != nil { - continue - } - addrInfo, err := peer.AddrInfoFromP2pAddr(addr) - if err != nil { - continue - } - n.SavePeer(addrInfo.ID.Pretty(), *addrInfo) + for _, v := range boots { + if strings.Contains(v, "testnet") { + configs.Tip("Test network") + protocolPrefix = config.TestnetProtocolPrefix + break + } else if strings.Contains(v, "mainnet") { + configs.Tip("Main network") + protocolPrefix = config.MainnetProtocolPrefix + break + } else if strings.Contains(v, "devnet") { + configs.Tip("Dev network") + protocolPrefix = config.DevnetProtocolPrefix + break + } else { + configs.Tip("Unknown network") } } @@ -82,7 +77,8 @@ func runCmd(cmd *cobra.Command, args []string) { cess.TransactionTimeout(configs.TimeToWaitEvent), cess.Workspace(n.GetWorkspace()), cess.P2pPort(n.GetServicePort()), - cess.Bootnodes(bootstrap), + cess.Bootnodes(n.GetBootNodes()), + cess.ProtocolPrefix(protocolPrefix), ) if err != nil { configs.Err(fmt.Sprintf("[cess.New] %v", err)) @@ -158,6 +154,8 @@ func runCmd(cmd *cobra.Command, args []string) { configs.Tip("Start node discovery service") } + configs.Tip(n.GetProtocolPrefix()) + // run n.Run() } diff --git a/go.mod b/go.mod index 688bab24..48e4fb7b 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,8 @@ module github.com/CESSProject/cess-bucket go 1.19 require ( - github.com/CESSProject/cess-go-sdk v0.2.8 - github.com/CESSProject/p2p-go v0.0.36 + github.com/CESSProject/cess-go-sdk v0.2.9 + github.com/CESSProject/p2p-go v0.0.37 github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce github.com/bytedance/sonic v1.9.2 github.com/centrifuge/go-substrate-rpc-client/v4 v4.0.13 diff --git a/go.sum b/go.sum index 5b71c479..617cd87e 100644 --- a/go.sum +++ b/go.sum @@ -46,10 +46,10 @@ git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGy github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/CESSProject/cess-go-sdk v0.2.8 h1:Uw60WYYWEbPW54VA9qNbm2w0zevqew+gHxvAcbY5JXM= -github.com/CESSProject/cess-go-sdk v0.2.8/go.mod h1:Mh6/k9aT4r58WHpmsY2Nw1QEzYLAhgC9XN2eptiTi+E= -github.com/CESSProject/p2p-go v0.0.36 h1:FyXwuE6nrfgsb32BdTgQdZeSUqLjI/KHchOTIFiLn8c= -github.com/CESSProject/p2p-go v0.0.36/go.mod h1:MmuZ2UfXnEJMZMhOCC4Ec5QQUJCT7j2yg3Xk/oZ16yw= +github.com/CESSProject/cess-go-sdk v0.2.9 h1:rbcJl1c80bb75718GBTND0vP7Sc+hlm4DIhe8etBOfY= +github.com/CESSProject/cess-go-sdk v0.2.9/go.mod h1:ueHJuYJUNB8RrQUz5uWisCYO7jrQF/StI1TRXdZlMyM= +github.com/CESSProject/p2p-go v0.0.37 h1:FYlTPWAKMmRW/HxzXH1FD1ueGIT8kkvGCJQK0YRlBms= +github.com/CESSProject/p2p-go v0.0.37/go.mod h1:MmuZ2UfXnEJMZMhOCC4Ec5QQUJCT7j2yg3Xk/oZ16yw= github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM= github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=