-
Notifications
You must be signed in to change notification settings - Fork 263
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
Allow Index Keys #76
Comments
I think of the IAVL tree basically as a |
Sometimes we want to take advantage of the IAVL sorting to gain the subset of records - for instance in staking we want to hold all the delegations, (key = {delegationAddr, validatorAddr}) and want to be able to access both all the delegations from one delegator, and all the delegations to one validator, we've been doing this by holding an index record with the key {validatorAddr, delegationAddr} in order to sort by validator - this second key however doesn't need to store the record, because once you know of it's existence you can go lookup the first key-value pair. Thus we don't need it to actually have a value, only the key - does this make sense? |
Essentially, it's kind of acting like a set right? I don't see anything wrong with storing nil values or an empty byte slice. Just gotta be careful it doesn't break any existing internal API's (e.g. operating a nil value). |
Yeah, I was worried that we'd need to be very careful with handling this case. From looking into how nodes are persisted, this doesn't seem to hold. Hence it should be fine. |
Thinking about this a bit more, there is one kind of weird situation: When you use currently to store an index I'm using an empty byte array ( |
Hmm, I knew there must be sth weird about how to implement this :-D
I think that is not really optimal, too.
This, or somehow else encoding / saying "nope, no value", without introducing another var or function, would be better. |
What if we made your workaround the default behaviour? If you set(key, nil) you will get(key)= |
Yeah I agree @liamsi. I'm seeming to be more inclined to not store
|
If anything we'd wouldn't want an
|
Ok, so a client will never get |
correct |
Additionally we could use |
Perhaps this is out-of-date, but you can |
The current behavior seems to be in line with this discussion: |
right now iavl panics if there is a no value provided:
https://github.com/tendermint/iavl/blob/master/tree.go#L90
we do however want to be able to store indexes which should be holding no value, right now we can store a single 0 byte, but I think it would be useful to allow either storing nil, or building in some explicit index function
The text was updated successfully, but these errors were encountered: