Skip to content

Commit

Permalink
Merge PR: dds unsafe (#1551)
Browse files Browse the repository at this point in the history
* add log

* add preRun

* del unusable code

* add Elapesd

* nodeToNodeJsonUnsafe

Co-authored-by: chengzhinei <chengxue5yuan@163.com>
  • Loading branch information
cwbhhjl and chengzhinei authored Feb 21, 2022
1 parent 7be0208 commit b5c21eb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
18 changes: 6 additions & 12 deletions libs/iavl/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"bytes"
"fmt"
"io"
"unsafe"

"github.com/pkg/errors"

Expand Down Expand Up @@ -35,18 +36,11 @@ func NodeToNodeJson(node *Node) *NodeJson {
if node == nil {
return &NodeJson{}
}
return &NodeJson{
Key: node.key,
Value: node.value,
Hash: node.hash,
LeftHash: node.leftHash,
RightHash: node.rightHash,
Version: node.version,
Size: node.size,
Height: node.height,
Persisted: node.persisted,
PrePersisted: node.prePersisted,
}
return nodeToNodeJsonUnsafe(node)
}

func nodeToNodeJsonUnsafe(node *Node) *NodeJson {
return (*NodeJson)(unsafe.Pointer(node))
}

// NodeJsonToNode get Node from NodeJson
Expand Down
8 changes: 5 additions & 3 deletions libs/iavl/tree_delta.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,11 @@ type NodeJson struct {
RightHash []byte `json:"right_hash"`
Version int64 `json:"version"`
Size int64 `json:"size"`
Height int8 `json:"height"`
Persisted bool `json:"persisted"`
PrePersisted bool `json:"pre_persisted"`
leftNode *Node
rightNode *Node
Height int8 `json:"height"`
Persisted bool `json:"persisted"`
PrePersisted bool `json:"pre_persisted"`
}

// MarshalToAmino marshal data to amino bytes.
Expand Down

0 comments on commit b5c21eb

Please sign in to comment.