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

Commit b5c59ca

Browse files
committed
feat: Save dispute close message to database
1 parent de22242 commit b5c59ca

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
@@ -595,10 +595,30 @@ func (n *OpenBazaarNode) SendDisputeClose(peerID string, k *libp2p.PubKey, resol
595595
log.Errorf("failed to marshal the contract: %v", err)
596596
return err
597597
}
598+
599+
// Create the DISPUTE_CLOSE message
598600
m := pb.Message{
599601
MessageType: pb.Message_DISPUTE_CLOSE,
600602
Payload: a,
601603
}
604+
605+
// Save DISPUTE_CLOSE message to the database for this order for resending if necessary
606+
var orderID0 string
607+
if resolutionMessage.VendorOrderConfirmation != nil {
608+
orderID0 = resolutionMessage.VendorOrderConfirmation.OrderID
609+
if orderID0 == "" {
610+
log.Errorf("failed fetching orderID")
611+
} else {
612+
err = n.Datastore.Messages().Put(
613+
fmt.Sprintf("%s-%d", orderID0, int(pb.Message_DISPUTE_CLOSE)),
614+
orderID0, pb.Message_DISPUTE_CLOSE, peerID, repo.Message{Msg: m},
615+
"", 0, []byte{})
616+
if err != nil {
617+
log.Errorf("failed putting message (%s-%d): %v", orderID0, int(pb.Message_DISPUTE_CLOSE), err)
618+
}
619+
}
620+
}
621+
602622
return n.sendMessage(peerID, k, m)
603623
}
604624

0 commit comments

Comments
 (0)