From 83b8f43e5d7d27c4ea73ed2fc7f69512c81b39ae Mon Sep 17 00:00:00 2001 From: AstaFrode Date: Mon, 10 Jul 2023 21:37:14 +0800 Subject: [PATCH 1/3] update sonic to json --- go.mod | 2 +- node/node.go | 4 ++-- node/putHandle.go | 6 +++--- node/tracker.go | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 9794e14..58cb8d5 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,6 @@ require ( github.com/CESSProject/go-keyring v0.0.0-20220614131247-ee3a8da30fde github.com/CESSProject/p2p-go v0.1.3 github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce - github.com/bytedance/sonic v1.8.0 github.com/cbergoon/merkletree v0.2.0 github.com/centrifuge/go-substrate-rpc-client/v4 v4.0.13 github.com/dgrijalva/jwt-go v3.2.0+incompatible @@ -36,6 +35,7 @@ require ( github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect github.com/benbjohnson/clock v1.3.0 // indirect github.com/beorn7/perks v1.0.1 // indirect + github.com/bytedance/sonic v1.8.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect github.com/containerd/cgroups v1.0.4 // indirect diff --git a/node/node.go b/node/node.go index f23abee..478d866 100644 --- a/node/node.go +++ b/node/node.go @@ -8,6 +8,7 @@ package node import ( + "encoding/json" "fmt" "log" "os" @@ -21,7 +22,6 @@ import ( "github.com/CESSProject/cess-go-sdk/core/pattern" "github.com/CESSProject/cess-go-sdk/core/sdk" "github.com/CESSProject/p2p-go/out" - "github.com/bytedance/sonic" "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" "github.com/google/uuid" @@ -158,7 +158,7 @@ func (n *Node) ParseTrackFromFile(filehash string) (RecordInfo, error) { if err != nil { return result, err } - err = sonic.Unmarshal(b, &result) + err = json.Unmarshal(b, &result) return result, err } diff --git a/node/putHandle.go b/node/putHandle.go index 4894cfd..bf6da77 100644 --- a/node/putHandle.go +++ b/node/putHandle.go @@ -8,7 +8,7 @@ package node import ( - "github.com/bytedance/sonic" + "encoding/json" "fmt" "io" @@ -293,7 +293,7 @@ func (n *Node) putHandle(c *gin.Context) { Duplicate: false, } - b, err := sonic.Marshal(recordInfo) + b, err := json.Marshal(recordInfo) if err != nil { n.Upfile("err", fmt.Sprintf("[%v] %v", clientIp, err)) c.JSON(http.StatusInternalServerError, ERR_InternalServer) @@ -355,7 +355,7 @@ func (n *Node) deduplication(pkey []byte, segmentInfo []pattern.SegmentDataInfo, } defer f.Close() - b, err := sonic.Marshal(&record) + b, err := json.Marshal(&record) if err != nil { return false, errors.Wrapf(err, "[marshal data]") } diff --git a/node/tracker.go b/node/tracker.go index 4ca8247..3b4cc35 100644 --- a/node/tracker.go +++ b/node/tracker.go @@ -8,6 +8,7 @@ package node import ( + "encoding/json" "fmt" "os" "path/filepath" @@ -16,7 +17,6 @@ import ( "github.com/CESSProject/DeOSS/pkg/utils" "github.com/CESSProject/cess-go-sdk/core/pattern" sutils "github.com/CESSProject/cess-go-sdk/core/utils" - "github.com/bytedance/sonic" "github.com/mr-tron/base58" "github.com/pkg/errors" ) @@ -167,9 +167,9 @@ func (n *Node) trackFile(trackfile string) error { n.Track("info", fmt.Sprintf("[%s] Duplicate file become primary file", roothash)) recordFile.Duplicate = false recordFile.Putflag = false - b, err = sonic.Marshal(&recordFile) + b, err = json.Marshal(&recordFile) if err != nil { - return errors.Wrapf(err, "[%s] [sonic.Marshal]", roothash) + return errors.Wrapf(err, "[%s] [json.Marshal]", roothash) } err = n.WriteTrackFile(roothash, b) if err != nil { @@ -188,9 +188,9 @@ func (n *Node) trackFile(trackfile string) error { recordFile.Putflag = true recordFile.Count = count - b, err = sonic.Marshal(&recordFile) + b, err = json.Marshal(&recordFile) if err != nil { - return errors.Wrapf(err, "[%s] [sonic.Marshal]", roothash) + return errors.Wrapf(err, "[%s] [json.Marshal]", roothash) } err = n.WriteTrackFile(roothash, b) From 77142f78a73ff2f0915efef9831112da90a116f3 Mon Sep 17 00:00:00 2001 From: AstaFrode Date: Mon, 10 Jul 2023 21:40:37 +0800 Subject: [PATCH 2/3] update default config file --- pkg/confile/conf_test.yaml | 5 +++-- pkg/confile/confile.go | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/confile/conf_test.yaml b/pkg/confile/conf_test.yaml index dc9106e..5cd65de 100644 --- a/pkg/confile/conf_test.yaml +++ b/pkg/confile/conf_test.yaml @@ -2,11 +2,12 @@ Rpc: - "wss://testnet-rpc0.cess.cloud/ws/" - "wss://testnet-rpc1.cess.cloud/ws/" + - "wss://testnet-rpc2.cess.cloud/ws/" # Bootstrap Nodes Boot: - - "_dnsaddr.bootstrap-kldr.cess.cloud" + - "_dnsaddr.boot-kldr-testnet.cess.cloud" # Account mnemonic -Mnemonic: "swear theme bounce soccer hungry gesture hurdle asset typical call balcony wrist" +Mnemonic: "bottom drive obey lake curtain smoke basket hold race lonely fit walk" # Service workspace Workspace: / # P2P communication port diff --git a/pkg/confile/confile.go b/pkg/confile/confile.go index e02c1ef..7d41cbc 100644 --- a/pkg/confile/confile.go +++ b/pkg/confile/confile.go @@ -25,11 +25,12 @@ const ( Rpc: - "wss://testnet-rpc0.cess.cloud/ws/" - "wss://testnet-rpc1.cess.cloud/ws/" + - "wss://testnet-rpc2.cess.cloud/ws/" # Bootstrap Nodes Boot: - - "_dnsaddr.bootstrap-kldr.cess.cloud" + - "_dnsaddr.boot-kldr-testnet.cess.cloud" # Account mnemonic -Mnemonic: "" +Mnemonic: "xxx ... xxx" # Service workspace Workspace: / # P2P communication port From 08dbbdd60c7f150eafab01fd6026166cc9c49efc Mon Sep 17 00:00:00 2001 From: AstaFrode Date: Tue, 11 Jul 2023 16:41:49 +0800 Subject: [PATCH 3/3] update default config file --- pkg/confile/confile.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/confile/confile.go b/pkg/confile/confile.go index 7d41cbc..d683f0e 100644 --- a/pkg/confile/confile.go +++ b/pkg/confile/confile.go @@ -23,12 +23,14 @@ const ( ProfileDefault = "conf.yaml" 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/" # Bootstrap Nodes Boot: - - "_dnsaddr.boot-kldr-testnet.cess.cloud" + # test network + - "_dnsaddr.boot-kldr-testnet.cess.cloud" # Account mnemonic Mnemonic: "xxx ... xxx" # Service workspace