Skip to content

Commit

Permalink
Add lock in GetPaymentLocal
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickxb committed Sep 9, 2019
1 parent 2efe0a2 commit b5f8897
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion go/stellar/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ func DefaultLoader(g *libkb.GlobalContext) *Loader {
}

func (p *Loader) GetPaymentLocal(ctx context.Context, paymentID stellar1.PaymentID) (*stellar1.PaymentLocal, bool) {
p.Lock()
defer p.Unlock()
return p.getPaymentLocalLocked(ctx, paymentID)
}

func (p *Loader) getPaymentLocalLocked(ctx context.Context, paymentID stellar1.PaymentID) (*stellar1.PaymentLocal, bool) {
pmt, ok := p.payments[paymentID]
return pmt, ok
}
Expand Down Expand Up @@ -125,7 +131,7 @@ func (p *Loader) LoadPayment(ctx context.Context, convID chat1.ConversationID, m
m.Warning("existing payment message info does not match load info: (%v, %v) != (%v, %v)", msg.convID, msg.msgID, convID, msgID)
}

payment, ok := p.GetPaymentLocal(ctx, paymentID)
payment, ok := p.getPaymentLocalLocked(ctx, paymentID)
if ok {
info := p.uiPaymentInfo(m, payment, msg)
p.G().NotifyRouter.HandleChatPaymentInfo(m.Ctx(), p.G().ActiveDevice.UID(), convID, msgID, *info)
Expand Down

0 comments on commit b5f8897

Please sign in to comment.