Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base json #84

Merged
merged 3 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package node

import (
"encoding/json"
"fmt"
"log"
"os"
Expand All @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions node/putHandle.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package node

import (
"github.com/bytedance/sonic"
"encoding/json"

"fmt"
"io"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]")
}
Expand Down
10 changes: 5 additions & 5 deletions node/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package node

import (
"encoding/json"
"fmt"
"os"
"path/filepath"
Expand All @@ -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"
)
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions pkg/confile/conf_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions pkg/confile/confile.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ 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.bootstrap-kldr.cess.cloud"
# test network
- "_dnsaddr.boot-kldr-testnet.cess.cloud"
# Account mnemonic
Mnemonic: ""
Mnemonic: "xxx ... xxx"
# Service workspace
Workspace: /
# P2P communication port
Expand Down