diff --git a/libs/iavl/node.go b/libs/iavl/node.go index 0e82bf7482..c71a5202f5 100644 --- a/libs/iavl/node.go +++ b/libs/iavl/node.go @@ -7,6 +7,7 @@ import ( "bytes" "fmt" "io" + "unsafe" "github.com/pkg/errors" @@ -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 diff --git a/libs/iavl/tree_delta.go b/libs/iavl/tree_delta.go index 02001fd29b..19da4b6f1f 100644 --- a/libs/iavl/tree_delta.go +++ b/libs/iavl/tree_delta.go @@ -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.