Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByteRange ¶
ByteRange attempts to take the range and serialize it, returns error if either fails
func KeyToBytes ¶
KeyToBytes returns the Key as a byte array for use in go-merkle Returns an error if some required fields are not set
func ModelToBytes ¶
ModelToBytes converts the model into bytes to store in the db If there are invalid values in the model you can return an error
func RegisterModels ¶
func RegisterModels(models ...Model)
RegisterModels takes a list of Models and registers them with go-wire for Serialization The control byte is based on the order, so if you want to maintain compatibility with an existing data store, do not change the position of any items. You can use nil as a placeholder to not use that byte anymore.
This also registers the serailzers for the model keys with the same prefix ¶
eg. RegisterModels(Account{}, nil, Status{}) gives account Byte 1, Status Byte 3
Types ¶
type Key ¶
type Key interface { // Range assumes the key has one or more elements at the zero (nil) value // It should return two keys, the first is with those zero elements set the the minimum possible value // The second return value should be with the zero elements set to their maximum possible value Range() (min Key, max Key) }
Key is designed to let you easily build compound indexes using the one database key
func KeyFromBytes ¶ added in v0.1.1
KeyFromBytes recovers a Key object from arbitrary byte data (eg. from API)
type Model ¶
type Model interface { // Key returns the db key for this model. // This key may have zero values (and designed for range queries), depending on the state of the model // The Key should not change with any allowed transformation of the model Key() Key }
Model is an abstraction over an object to be stored in MerkleDB
func Load ¶
Load attempts to find the data matching the given key If the key or store data cannot be parsed, returns error If there is no data, Model is nil
func ModelFromBytes ¶
ModelFromBytes sets the model contents to the passed in data Returns error if the data doesn't match this model