Skip to content

Commit

Permalink
fix(core): send unacked event when sending new one
Browse files Browse the repository at this point in the history
Signed-off-by: Sacha <sfroment42@gmail.com>
  • Loading branch information
sfroment committed Apr 17, 2019
1 parent fda31ee commit 807e6d8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core/node/p2pclient.go
Expand Up @@ -42,6 +42,7 @@ func (n *Node) EnqueueOutgoingEventWithOptions(ctx context.Context, event *entit
tracer := tracing.EnterFunc(ctx, event)
defer tracer.Finish()
ctx = tracer.Context()
db := n.sql(ctx)

if err := event.Err(); err != nil {
return errorcodes.ErrEventData.Wrap(err)
Expand Down Expand Up @@ -69,6 +70,16 @@ func (n *Node) EnqueueOutgoingEventWithOptions(ctx context.Context, event *entit

go func() {
for _, dispatch := range dispatches {
// for each dispatch we need to retrieve the unacked event for this device to requeu it
unacked, err := entity.FindNonAcknowledgedDispatchesForDestination(db, dispatch.DeviceID)
if err == nil {
for _, v := range unacked {
n.outgoingEvents <- v
}
} else {
logger().Error("fail retrieving unacked events", zap.Error(err))
}

n.outgoingEvents <- dispatch
}
}()
Expand Down

0 comments on commit 807e6d8

Please sign in to comment.