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

feat: keep internal state for Connor #1545

Merged
merged 3 commits into from Sep 25, 2018
Merged

feat: keep internal state for Connor #1545

merged 3 commits into from Sep 25, 2018

Conversation

nikonov1101
Copy link
Member

No description provided.

connor/engine.go Outdated
@@ -66,13 +67,25 @@ var (
Name: "sonm_orders_replaced",
Help: "Number of orders that were re-created on marker because of price deviation",
})

restoredOrdersCounter = prometheus.NewCounter(prometheus.CounterOpts{
Copy link
Collaborator

Choose a reason for hiding this comment

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

inconsistent naming

connor/state.go Outdated
s.mu.Lock()
defer s.mu.Unlock()

id := order.GetId().Unwrap().String()
Copy link
Collaborator

Choose a reason for hiding this comment

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

before mu

connor/state.go Outdated
return ok
}

func (s *state) hasDeal(id string) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

incostistent with hasOrder

connor/state.go Outdated
defer s.mu.Unlock()

s.activeOrders[ord.GetId().Unwrap().String()] = ord
s.log.Debug("adding active order",
Copy link
Collaborator

Choose a reason for hiding this comment

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

either 'added' or move before lock

connor/state.go Outdated
s.mu.Lock()
defer s.mu.Unlock()

s.activeOrders[ord.GetId().Unwrap().String()] = ord
Copy link
Collaborator

Choose a reason for hiding this comment

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

create string id before lock and use it here and in log

connor/state.go Outdated
s.mu.Lock()
defer s.mu.Unlock()

s.deals[deal.GetId().Unwrap().String()] = &dealQuality{
Copy link
Collaborator

Choose a reason for hiding this comment

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

same

connor/state.go Outdated
s.mu.Lock()
defer s.mu.Unlock()

s.log.Debug("deleting deal", zap.String("deal_id", id), zap.Int("total", len(s.deals)))
Copy link
Collaborator

Choose a reason for hiding this comment

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

'deleted' and move after delete call

connor/state.go Outdated
return
}

s.log.Info("dumpling state to the disk")
Copy link
Collaborator

Choose a reason for hiding this comment

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

split in two methods, write can possibly block for a long time

connor/state.go Outdated
zap.Int("queued", len(s.queuedOrders)))
}

func (s *state) deleteCreatingOrder(ord *types.Corder) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

queued?

@@ -252,6 +276,7 @@ func (e *engine) getOrderByID(ctx context.Context, id string) (*sonm.Order, erro

func (e *engine) processOrderResult(ctx context.Context) {
for order := range e.ordersResultsChan {
Copy link
Collaborator

Choose a reason for hiding this comment

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

looks like this should not be async

@antmat antmat merged commit 1f6aa05 into master Sep 25, 2018
@antmat antmat deleted the feat/connor/store-state branch September 25, 2018 14:09
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.

None yet

2 participants