Skip to content

Modify the key format of node in DB to a sequential integer ID instead of the hash value. #592

@cool-develope

Description

@cool-develope

Context

As we discussed in #571, I am introducing the nonce mechanism here.

  • add nodeKey field to replace the key of a node in DB
  • replace a key in DB from node.hash to nodeKey
  • investigate the possibility of removing version in the node structure

Design Decision

  • immutable tree structure
type ImmutableTree struct {
	root                   *Node
	ndb                    *nodeDB
	version                int64
	nonce                  int64             // new field to track the current ID
	skipFastStorageUpgrade bool
}
  • node structure
type Node struct {
	key           []byte
	value         []byte
	hash          []byte

	leftHash      []byte        
	rightHash     []byte    

	nodeKey       int64         // new field which reflects the current node key
	leftNodeKey   int64       // new field
	rightNodeKey  int64      // new field

	version       int64           // possible to remove ???

	size          int64
	leftNode      *Node
	rightNode     *Node
	subtreeHeight int8
	persisted     bool
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions