From 7dca0fcfc0ba994065939f46fce9dcb13e290a6a Mon Sep 17 00:00:00 2001 From: AstaFrode Date: Mon, 5 Aug 2024 17:36:37 +0800 Subject: [PATCH] update sdk and config tmpl (#166) --- cmd/cmd/exit.go | 2 +- cmd/cmd/run.go | 4 +++- go.mod | 2 +- go.sum | 4 ++-- node/tasks.go | 3 +-- pkg/confile/conf_test.yaml | 40 +++++++++++++++++++++++++++++--------- pkg/confile/confile.go | 24 ++++++++--------------- 7 files changed, 47 insertions(+), 32 deletions(-) diff --git a/cmd/cmd/exit.go b/cmd/cmd/exit.go index 056c7c0..655e4f6 100644 --- a/cmd/cmd/exit.go +++ b/cmd/cmd/exit.go @@ -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) diff --git a/cmd/cmd/run.go b/cmd/cmd/run.go index 054fc5a..3e3df4a 100644 --- a/cmd/cmd/run.go +++ b/cmd/cmd/run.go @@ -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) @@ -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\")]") diff --git a/go.mod b/go.mod index 05113ce..1805392 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 1fb30fa..b6bbf39 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/node/tasks.go b/node/tasks.go index e27231b..064cb0f 100644 --- a/node/tasks.go +++ b/node/tasks.go @@ -69,7 +69,6 @@ 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 { @@ -77,7 +76,7 @@ func (n *Node) TaskMgt() { go n.RefreshMiner(ch_refreshMiner) } - //go n.BackupPeer(filepath.Join(n.Workspace(), "peer_record")) + go n.BackupPeer(filepath.Join(n.Workspace(), "peer_record")) } } } diff --git a/pkg/confile/conf_test.yaml b/pkg/confile/conf_test.yaml index 900fc45..8aae8cc 100644 --- a/pkg/confile/conf_test.yaml +++ b/pkg/confile/conf_test.yaml @@ -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: "/" @@ -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" \ No newline at end of file +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: \ No newline at end of file diff --git a/pkg/confile/confile.go b/pkg/confile/confile.go index 87a9964..70ad49e 100644 --- a/pkg/confile/confile.go +++ b/pkg/confile/confile.go @@ -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 @@ -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: "" @@ -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() {