-
Notifications
You must be signed in to change notification settings - Fork 102
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
tatanka: Add orderbook db. #3164
base: master
Are you sure you want to change the base?
Conversation
ab37ffb
to
423014d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mesh nodes don't maintain any order books. Only clients.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The db is not for clients? I assumed they would also keep track of things like reputation, bond validity using the db.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. The tatanka/db package is for server mesh nodes database needs. We'll need to create a client lexi DB too.
type OrderBook struct { | ||
orderBook *lexi.Table | ||
orderBookOrderIDIdx *lexi.Index | ||
orderBookStampIdx *lexi.Index | ||
orderBookSellRateIdx *lexi.Index | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do orders need to be stored to disk?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there were a lot of orders, would you store them all in memory? I thought every client would do their best effort to keep up with the entire order book for whatever markets they are interested in. There could be many.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An order is roughly 100 bytes
type Order struct {
From PeerID // 32 bytes
BaseID uint32 // 4
QuoteID uint32 // 4
Sell bool // 1
Qty uint64 // 8
Rate uint64 // 8
LotSize uint64 // 8
Stamp time.Time // 24, I think
Expiration time.Time // 24
}
Let's say each market has 1000 orders per side. Then a market's footprint in memory will be 100 * 1000 * 2 bytes = 200 kB
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, no db just a map then. I'll rework this.
423014d
to
4b5615c
Compare
part of #3115