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: switch to lexi db package and clean up message handling #3153

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

buck54321
Copy link
Member

No description provided.

@dev-warrior777
Copy link
Contributor

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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
Copy link
Member

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) {
Copy link
Member

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Comment on lines +623 to +630
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)
Copy link
Contributor

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
Copy link
Contributor

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?

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.

4 participants