Skip to content
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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

JoeGruffins
Copy link
Member

part of #3115

@JoeGruffins JoeGruffins force-pushed the tatankaorderbooker branch 2 times, most recently from ab37ffb to 423014d Compare January 28, 2025 09:12
Copy link
Member

@buck54321 buck54321 Jan 28, 2025

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.

Copy link
Member Author

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.

Copy link
Member

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.

Comment on lines +96 to +101
type OrderBook struct {
orderBook *lexi.Table
orderBookOrderIDIdx *lexi.Index
orderBookStampIdx *lexi.Index
orderBookSellRateIdx *lexi.Index
}
Copy link
Member

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?

Copy link
Member Author

@JoeGruffins JoeGruffins Jan 29, 2025

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.

Copy link
Member

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.

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants