Skip to content

Commit

Permalink
update sdk and config tmpl (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
AstaFrode authored Aug 5, 2024
1 parent 1d13054 commit 7dca0fc
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 32 deletions.
2 changes: 1 addition & 1 deletion cmd/cmd/exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func cmd_exit_func(cmd *cobra.Command, args []string) {
}
defer n.ChainClient.Close()

err = n.InitExtrinsicsName()
err = n.InitExtrinsicsNameForOSS()
if err != nil {
log.Println("The rpc address does not match the software version, please check the rpc address.")
os.Exit(1)
Expand Down
4 changes: 3 additions & 1 deletion cmd/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func cmd_run_func(cmd *cobra.Command, args []string) {
}
defer n.ChainClient.Close()

err = n.InitExtrinsicsName()
err = n.InitExtrinsicsNameForOSS()
if err != nil {
log.Println("The rpc address does not match the software version, please check the rpc address.")
os.Exit(1)
Expand Down Expand Up @@ -227,6 +227,8 @@ func buildConfigFile(cmd *cobra.Command) (confile.Confile, error) {
return cfg, nil
}

return cfg, err

rpc, err := cmd.Flags().GetStringSlice("rpc")
if err != nil {
return cfg, errors.Wrapf(err, "[cmd.Flags().GetStringSlice(\"rpc\")]")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21
toolchain go1.22.4

require (
github.com/CESSProject/cess-go-sdk v0.6.1
github.com/CESSProject/cess-go-sdk v0.6.2-0.20240805070224-ca5be6963b49
github.com/CESSProject/cess-go-tools v0.2.12
github.com/CESSProject/go-keyring v0.0.0-20220614131247-ee3a8da30fde
github.com/CESSProject/p2p-go v0.4.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D
git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/CESSProject/cess-go-sdk v0.6.1 h1:ZjrpoSjBbLv+Eqpsq03qEQkehL3hG/AQuVPEk7cUah0=
github.com/CESSProject/cess-go-sdk v0.6.1/go.mod h1:L5IDeS2ydsdgtdybzhWk9fIdBsDkU2XrQyo5mrWHkdQ=
github.com/CESSProject/cess-go-sdk v0.6.2-0.20240805070224-ca5be6963b49 h1:6a58IgBudMSK0YsRvdxDsNgAPqyowfrrgKCXfQ5IP6I=
github.com/CESSProject/cess-go-sdk v0.6.2-0.20240805070224-ca5be6963b49/go.mod h1:L5IDeS2ydsdgtdybzhWk9fIdBsDkU2XrQyo5mrWHkdQ=
github.com/CESSProject/cess-go-tools v0.2.12 h1:VqghaGaWgL+JelKXCXaABj4rCDFFRdbhiXifyMpkjqo=
github.com/CESSProject/cess-go-tools v0.2.12/go.mod h1:ov1vSPbTlBSRWl3XqsibrKrK9smIq2hWeGs0TEhactc=
github.com/CESSProject/go-keyring v0.0.0-20220614131247-ee3a8da30fde h1:5MDRjjtg6PEhqyVjupwaapN96cOZiddOGAYwKQeaTu0=
Expand Down
3 changes: 1 addition & 2 deletions node/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,14 @@ func (n *Node) TaskMgt() {
if err != nil {
n.Log("err", err.Error())
}
go n.BackupPeer(filepath.Join(n.Workspace(), "peer_record"))

case <-task_Hour.C:
if len(ch_refreshMiner) > 0 {
<-ch_refreshMiner
go n.RefreshMiner(ch_refreshMiner)
}

//go n.BackupPeer(filepath.Join(n.Workspace(), "peer_record"))
go n.BackupPeer(filepath.Join(n.Workspace(), "peer_record"))
}
}
}
Expand Down
40 changes: 31 additions & 9 deletions pkg/confile/conf_test.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# The rpc endpoint of the chain node
Rpc:
- "wss://testnet-rpc0.cess.cloud/ws/"
- "wss://testnet-rpc1.cess.cloud/ws/"
- "wss://testnet-rpc2.cess.cloud/ws/"
# test network
- "wss://testnet-rpc.cess.network/ws/"
# Bootstrap Nodes
Boot:
- "_dnsaddr.boot-kldr-testnet.cess.cloud"
# test network
- "_dnsaddr.boot-miner-testnet.cess.network"
# Account mnemonic
# Substrate well-known mnemonic:
# - https://github.com/substrate-developer-hub/substrate-developer-hub.github.io/issues/613
Mnemonic: "bottom drive obey lake curtain smoke basket hold race lonely fit walk"
# Service workspace
Workspace: "/"
Expand All @@ -15,12 +17,32 @@ P2P_Port: 4001
# Service listening port
HTTP_Port: 8080
# Access mode: public / private
# In public mode, only users in accounts can't access it.
# In private mode, only users in accounts can access it.
# In public mode, only users in Accounts can't access it.
# In private mode, only users in Accounts can access it.
Access: public
# Account black/white list
Accounts:
- cXjeCHQW3totBGhQXdAUAqjCNqk1NhiR3UK37czSeUak2pqGV
- cXgaee2N8E77JJv9gdsGAckv1Qsf3hqWYf7NL4q6ZuQzuAUtB
# If you want to expose your oss service, please configure its domain name
Domain: "http://deoss-pub-gateway.cess.cloud"
Domain: ""

# User Files Cacher config
# File cache size, default 512G, (unit is byte)
CacheSize:
# File cache expiration time, default 3 hour (unit is minutes)
Expiration:
# Directory to store file cache, default path: Workspace/filecache/
CacheDir:

# Storage Node Selector config
# Used to find better storage node partners for DeOSS to upload or download files
# Two strategies for using your specified storage nodes, "priority" or "fixed", default is "priority"
SelectStrategy:
# JSON file used to specify the storage node. If it does not exist, it will be automatically created.
# You can configure which storage nodes to use or not use in this file.
NodeFilePath:
# Maximum number of storage nodes allowed for long-term cooperation, default 120
MaxNodeNum:
# Maximum tolerable TTL for communication with storage nodes, default 500 ms (unit is milliseconds)
MaxTTL:
# Available storage node list refresh time, default 4 hours (unit is hours)
RefreshTime:
24 changes: 8 additions & 16 deletions pkg/confile/confile.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ const (
ProfileTemplete = `# The rpc endpoint of the chain node
Rpc:
# test network
- "wss://testnet-rpc0.cess.cloud/ws/"
- "wss://testnet-rpc1.cess.cloud/ws/"
- "wss://testnet-rpc2.cess.cloud/ws/"
- "wss://testnet-rpc.cess.network/ws/"
# Bootstrap Nodes
Boot:
# test network
- "_dnsaddr.boot-bucket-testnet.cess.cloud"
- "_dnsaddr.boot-miner-testnet.cess.network"
# Account mnemonic
Mnemonic: "xxx ... xxx"
Mnemonic: ""
# Service workspace
Workspace: "/"
# P2P communication port
Expand All @@ -46,8 +44,6 @@ HTTP_Port: 8080
Access: public
# Account black/white list
Accounts:
- cX...
- cX...
# If you want to expose your oss service, please configure its domain name
Domain: ""
Expand Down Expand Up @@ -184,18 +180,14 @@ func (c *confile) Parse(fpath string) error {
}
c.Accounts = accountList

err = sutils.CheckDomain(c.Domain)
if err != nil {
return errors.New("Invalid domain name")
}
// err = sutils.CheckDomain(c.Domain)
// if err != nil {
// return errors.New("Invalid domain name")
// }

fstat, err = os.Stat(c.Workspace)
if err != nil {
err = os.MkdirAll(c.Workspace, 0755)
if err != nil {
return err
}
return nil
return os.MkdirAll(c.Workspace, 0755)
}

if !fstat.IsDir() {
Expand Down

0 comments on commit 7dca0fc

Please sign in to comment.