Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit a57b7d0

Browse files
committed
feat: Save outbound order payment messages
Saves order payment message (21) to the database so it can be resent by the buyer (if a payment is failed to be detected by the seller).
1 parent 35d2694 commit a57b7d0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

core/net.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,20 @@ func (n *OpenBazaarNode) SendOrderPayment(spend *SpendResponse) error {
813813
if err != nil {
814814
return err
815815
}
816+
817+
orderID0 := msg.OrderID
818+
if orderID0 == "" {
819+
log.Errorf("failed fetching orderID")
820+
} else {
821+
err = n.Datastore.Messages().Put(
822+
fmt.Sprintf("%s-%d", orderID0, int(pb.Message_ORDER_PAYMENT)),
823+
orderID0, pb.Message_ORDER_PAYMENT, spend.PeerID, repo.Message{Msg: m},
824+
"", 0, []byte{})
825+
if err != nil {
826+
log.Errorf("failed putting message (%s-%d): %v", orderID0, int(pb.Message_ORDER_COMPLETION), err)
827+
}
828+
}
829+
816830
ctx, cancel := context.WithTimeout(context.Background(), n.OfflineMessageFailoverTimeout)
817831
err = n.Service.SendMessage(ctx, p, &m)
818832
cancel()

0 commit comments

Comments
 (0)