-
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: switch to lexi db package and clean up message handling #3153
base: master
Are you sure you want to change the base?
Conversation
This is wrapping bbolt with badger? |
type clientRequestHandler = func(c *client, msg *msgjson.Message) *msgjson.Error | ||
type clientNotificationHandler = func(c *client, msg *msgjson.Message) | ||
|
||
// handleClientMessage handles incoming message from locally-connected 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.
// handleClientMessage handles incoming message from locally-connected clients. | |
// handleClientMessage handles incoming messages from locally-connected clients. |
}, nil | ||
} | ||
|
||
func (db *DB) Connect(ctx context.Context) (*sync.WaitGroup, error) { | ||
var wg sync.WaitGroup |
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.
Could add 1 to wg and do wg.Done()
after ctx is done so we are sure pruneOldBonds()
is finished when shutting down.
scoredIdx *lexi.Index | ||
bonds *lexi.Table | ||
bonderIdx *lexi.Index | ||
bondStampIdx *lexi.Index | ||
} | ||
|
||
func New(dir string, log dex.Logger) (*DB, error) { |
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.
I think we should start with a db version, 0, and check that already. We will need to do that at the beginning of New
I guess and do upgrades there. Currently it should error if not version 0.
Maybe it is somewhere I'm missing.
} | ||
|
||
if len(allBonds) > 0 { // Probably no way to get here with empty allBonds, but checking anyway. | ||
if len(liveBonds) > 0 { // Probably no way to get here with empty allBonds, but checking anyway. |
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 len(liveBonds) > 0 { // Probably no way to get here with empty allBonds, but checking anyway. | |
if len(liveBonds) > 0 { // Probably no way to get here with empty liveBonds, but checking anyway. |
if _, found := t.clientHandlers[msg.Route]; found { | ||
return t.handleClientMessage(cl, msg) | ||
} | ||
if _, found := t.tatankaHandlers[msg.Route]; found { | ||
return t.handleTatankaMessage(cl, msg) | ||
} | ||
if handle, found := t.specialHandlers[msg.Route]; found { | ||
return handle(cl, msg) |
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.
Name collisions would mess things up.
copy(k[tanka.PeerIDLength+6:], penaltyID[:]) | ||
func (d *DB) Reputation(scored tanka.PeerID) (*tanka.Reputation, error) { | ||
agg := new(tanka.Reputation) | ||
var s dbScore |
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.
What's reason for s
?
No description provided.