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
Conversation
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{ |
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.
inconsistent naming
connor/state.go
Outdated
s.mu.Lock() | ||
defer s.mu.Unlock() | ||
|
||
id := order.GetId().Unwrap().String() |
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.
before mu
connor/state.go
Outdated
return ok | ||
} | ||
|
||
func (s *state) hasDeal(id string) bool { |
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.
incostistent with hasOrder
connor/state.go
Outdated
defer s.mu.Unlock() | ||
|
||
s.activeOrders[ord.GetId().Unwrap().String()] = ord | ||
s.log.Debug("adding active order", |
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.
either 'added' or move before lock
connor/state.go
Outdated
s.mu.Lock() | ||
defer s.mu.Unlock() | ||
|
||
s.activeOrders[ord.GetId().Unwrap().String()] = ord |
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.
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{ |
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.
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))) |
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.
'deleted' and move after delete call
connor/state.go
Outdated
return | ||
} | ||
|
||
s.log.Info("dumpling state to the 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.
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) { |
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.
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 { |
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.
looks like this should not be async
No description provided.