Conversation
baa713d to
50c2850
Compare
tac0turtle
left a comment
There was a problem hiding this comment.
Lgtm. Could we get changelog entries for things
| Using the root and the nodeDB, the ImmutableTree can retrieve any node that is a part of the IAVL tree at this version. | ||
|
|
||
| Users can get information about the IAVL tree by calling getter functions such as `Size()` and `Height()` which will return the tree's size and height by querying the root node's size and height. | ||
| Users can get information about the IAVL tree by calling getter functions such as `Size()` and `Height()` which will return the tree's size and depth by querying the root node's size and depth. |
There was a problem hiding this comment.
| Users can get information about the IAVL tree by calling getter functions such as `Size()` and `Height()` which will return the tree's size and depth by querying the root node's size and depth. | |
| Users can get information about the IAVL tree by calling getter functions such as `Size()` and `Depth()` which will return the tree's size and depth by querying the root node's size and depth. |
There was a problem hiding this comment.
Would it actually be depth though? It seems to be returning "subtree height"
| @@ -29,13 +30,13 @@ func NewFastNode(key []byte, value []byte, version int64) *FastNode { | |||
|
|
|||
| // DeserializeFastNode constructs an *FastNode from an encoded byte slice. | |||
| func DeserializeFastNode(key []byte, buf []byte) (*FastNode, error) { | |||
There was a problem hiding this comment.
Should we move the regular Node to this package as well?
There was a problem hiding this comment.
It really feels like they belong together / grouped into the same package
There was a problem hiding this comment.
I think they should, just takes more refactors to get there
| import dbm "github.com/tendermint/tm-db" | ||
|
|
||
| // Traverse all keys with a certain prefix. Return error if any, nil otherwise | ||
| func IterateThroughAllSubtreeKeys(db dbm.DB, prefix []byte, fn func(k, v []byte) error) error { |
| return nil | ||
| } | ||
|
|
||
| func GatherSubtreeKVPairs(db dbm.DB, prefix []byte) (keys [][]byte, values [][]byte, err error) { |
|
|
||
| // encodeBytesSlice length-prefixes the byte slice and returns it. | ||
| func encodeBytesSlice(bz []byte) ([]byte, error) { | ||
| // utils.EncodeBytesSlice length-prefixes the byte slice and returns it. |
There was a problem hiding this comment.
| // utils.EncodeBytesSlice length-prefixes the byte slice and returns it. | |
| // EncodeBytesSlice length-prefixes the byte slice and returns it. |
|
|
||
| // encodeVarint writes a varint-encoded integer to an io.Writer. | ||
| func encodeVarint(w io.Writer, i int64) error { | ||
| // utils.EncodeVarint writes a varint-encoded integer to an io.Writer. |
There was a problem hiding this comment.
| // utils.EncodeVarint writes a varint-encoded integer to an io.Writer. | |
| // EncodeVarint writes a varint-encoded integer to an io.Writer. |
|
|
||
| // encodeVarintSize returns the byte size of the given integer as a varint. | ||
| func encodeVarintSize(i int64) int { | ||
| // utils.EncodeVarintSize returns the byte size of the given integer as a varint. |
There was a problem hiding this comment.
| // utils.EncodeVarintSize returns the byte size of the given integer as a varint. | |
| // EncodeVarintSize returns the byte size of the given integer as a varint. |
| // TODO: Make better static guarantee in tree, | ||
| // for what nodes exist in deserialized memory, and just not getting extra nodes | ||
| // and a clear decision criteria between "no branch node", "new branch with as of yet unknown hash" | ||
| func (tree *MutableTree) saveBranch(node *Node) []byte { |
There was a problem hiding this comment.
Seems this was moved but would be great to eventually cover this with a test
| if node.version <= genesisVersion { | ||
| tree.ndb.resetBatch() | ||
| } | ||
| // TODO: This should be deletable? Is it just here for garbage collection purposes? |
There was a problem hiding this comment.
I think you are right. We should probably run benchmarks before removing them. Wdyt?
| tree.ndb.SaveNode(node) | ||
|
|
||
| // resetBatch only working on generate a genesis block | ||
| // TODO: What is this? It should almost certainly be deleted / moved elsewhere. |
| } | ||
|
|
||
| // Height returns the height of the tree. | ||
| // Height returns the depth of the tree. |
There was a problem hiding this comment.
Can we rename this to SubtreeHeight() and update the docs? The docs seem to say that this returns depth
This commit does some repository cleanup, at the moment it does:
ndb.roots()method, that is only used in a test to avoid checking an error lmaoIf you want to review this, it should be reviewed commit by commit