mangrovedao/mangrove.js

Semibook caches should be reused for multiple markets

lnist opened this issue · 0 comments

lnist commented

Is your feature request related to a problem? Please describe.
Currently each market (A,B) has a semibook cache for the offer list (A,B) and (B,A). We often create new markets, and this means that caches for each market will take up individual memory and read missing offers from the chain without that being beneficial to other markets.

Describe the solution you'd like
Split out the cache from semibook and make it offerList caches (as in non-bid-ask aware) so that Market(A,B) will use same cache as Market(B,A), and introduce a "getOrCreate" function for getting an offer list cache when creating a market.

Be aware: book options may influence the shareability of caches, that should be investigated. Disconnecting a market should not disconnect a cache used by others.

Describe alternatives you've considered
It could be done without extracting the offerList part of a semibook and cache directly on the bid/ask aware semibook, but that would reduce shareability possibly complicate the cache.