Skip to content

Commit

Permalink
update sdk to v0.2.9 (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
AstaFrode authored Jul 4, 2023
1 parent d519bcb commit ed14e1a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 36 deletions.
58 changes: 28 additions & 30 deletions cmd/console/runCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
}
}

Expand All @@ -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))
Expand Down Expand Up @@ -158,6 +154,8 @@ func runCmd(cmd *cobra.Command, args []string) {
configs.Tip("Start node discovery service")
}

configs.Tip(n.GetProtocolPrefix())

// run
n.Run()
}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit ed14e1a

Please sign in to comment.