Wrapper for the market place state
A class that wraps a number of useful lambda expressions that can be used for the lambdafilter function on MarketPlaceState collections.
Predicate: match objects that have the given field and the value for the field matches the given value
Predicte: match objects that have the given field and the value for the field references one of the objects in the list
Predicate: match objects with the given type
Predicate: match objects with either ExchangeOffer or SellOffer type
Predicate: match objects with either Holding or Liability type
MarketPlaceState(baseurl, creator=None, creator_name=None)¶
A class to wrap the current ledger state for a market place. Retrieves the state from a validator and builds maps for names and ids. Exports methods for querying state.
- baseurl (url) – the base URL for a Sawtooth Lake validator that supports an HTTP interface
- creator (id) – the identifier for the participant generating transactions
State (dict) – The key/value store associated with the head of the ledger, for the MarketPlace store, keys are object identifiers and the values are the current state of each object.
Convert a name into an identifier. The name can take one of these forms: @ – resolves to the identifier for creator ///<IDENTIFIER> – resolves to the identifier //<CREATOR>/<PATH> – fully qualified name /<PATH> – resolve relative to the current creator if specified
Parameters: name (str) – object name Returns: object identifier Return type: id
Construct the fully qualified name for an object
If the object does not have a name the format will be ///<IDENTIFIER> If the object is a participant the format will be //<NAME> Otherwise the format will be //<CREATOR NAME>/<NAME>
Parameters: objectid (id) – identifier for the object Returns: the fully qualified name for the object Return type: str
Retrieve the current state from the validator. Rebuild the name, type, and id maps for the resulting objects.
Parameters: store (str) – optional, the name of the marketplace store to retrieve
Function to retrieve the value of a property of an object in the saved state
Parameters: -- '.' separate expression for extracting a value from state (path) –
Apply a series of predicates to state objects. Predicates are lambda expressions on the data of an object. See the Filters class for tools for creating lambda expressions.
Parameters: predicates (list of lambda functions) – a list of predicates used to filter the set of objects Returns: a list of object identifiers Return type: list of identifiers
list(objtype=None, creator=None, name=None, fields=None)¶
Simple filter for common query operations on the current state