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

Commit 3e0150c

Browse files
committed
feat: Save dispute open message to database
1 parent d675eae commit 3e0150c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

core/net.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,10 +530,30 @@ func (n *OpenBazaarNode) SendDisputeOpen(peerID string, k *libp2p.PubKey, disput
530530
log.Errorf("failed to marshal the contract: %v", err)
531531
return err
532532
}
533+
534+
// Create the DISPUTE_OPEN message
533535
m := pb.Message{
534536
MessageType: pb.Message_DISPUTE_OPEN,
535537
Payload: a,
536538
}
539+
540+
// Save DISPUTE_OPEN message to the database for this order for resending if necessary
541+
var orderID0 string
542+
if disputeMessage.VendorOrderConfirmation != nil {
543+
orderID0 = disputeMessage.VendorOrderConfirmation.OrderID
544+
if orderID0 == "" {
545+
log.Errorf("failed fetching orderID")
546+
} else {
547+
err = n.Datastore.Messages().Put(
548+
fmt.Sprintf("%s-%d", orderID0, int(pb.Message_DISPUTE_OPEN)),
549+
orderID0, pb.Message_DISPUTE_OPEN, peerID, repo.Message{Msg: m},
550+
"", 0, []byte{})
551+
if err != nil {
552+
log.Errorf("failed putting message (%s-%d): %v", orderID0, int(pb.Message_DISPUTE_OPEN), err)
553+
}
554+
}
555+
}
556+
537557
return n.sendMessage(peerID, k, m)
538558
}
539559

0 commit comments

Comments
 (0)