turbofish-org / orga

State machine engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Query trait

mappum opened this issue · comments

Stores should be able to implement a Query trait so that clients can ask for N keys or ranges of keys and receive their values. It will look something like this:

trait Query {
  fn query(key: &[u8]) -> Result<Vec<u8>>;
}

In MerkStore the query implementation will return a Merkle proof, in WriteCache/MapStore the implementation will basically just be a simple get.

For now, we don't need to support ranges of keys since that isn't available in the Read trait yet. Also, for now, the query can just be a single key but could later be an array of keys. It's also possible that we'll just always keep the "key" argument as a single byte slice which can be deserialized differently by different stores.

We'll also want to require this for the store used in the ABCI state machine, so that it can respond to ABCI query messages with the store's query implementation.