@@ -56,7 +56,7 @@ func (l *TransactionListener) getOrderDetails(orderID string, address btc.Addres
56
56
}
57
57
58
58
// cleanupOrderState - scan each order to ensure the state in the db matches the state of the contract stored
59
- func (l * TransactionListener ) cleanupOrderState (isSale bool , txid string , output wallet.TransactionOutput , contract * pb.RicardianContract , state pb.OrderState , funded bool , records []* wallet.TransactionRecord ) {
59
+ func (l * TransactionListener ) cleanupOrderState (isSale bool , output wallet.TransactionOutput , contract * pb.RicardianContract , state pb.OrderState , funded bool , records []* wallet.TransactionRecord ) {
60
60
61
61
orderId , err := calcOrderId (contract .BuyerOrder )
62
62
if err != nil {
@@ -67,11 +67,13 @@ func (l *TransactionListener) cleanupOrderState(isSale bool, txid string, output
67
67
if contract .DisputeResolution != nil && state != pb .OrderState_DECIDED && state != pb .OrderState_RESOLVED {
68
68
log .Infof ("Out of sync order. Found %s and should either DECIDED be %s\n " , state , pb .OrderState_RESOLVED )
69
69
if isSale {
70
- l .db .Sales ().Put (orderId , * contract , pb .OrderState_RESOLVED , false )
70
+ err = l .db .Sales ().Put (orderId , * contract , pb .OrderState_RESOLVED , false )
71
71
} else {
72
- l .db .Purchases ().Put (orderId , * contract , pb .OrderState_RESOLVED , false )
72
+ err = l .db .Purchases ().Put (orderId , * contract , pb .OrderState_RESOLVED , false )
73
+ }
74
+ if err != nil {
75
+ log .Errorf ("Error saving new order state: %s" , err )
73
76
}
74
-
75
77
}
76
78
}
77
79
@@ -95,13 +97,13 @@ func (l *TransactionListener) OnTransactionReceived(cb wallet.TransactionCallbac
95
97
//contract, state, funded, records, err := l.db.Sales().GetByPaymentAddress(output.Address)
96
98
if err == nil && state != pb .OrderState_PROCESSING_ERROR {
97
99
l .processSalePayment (cb .Txid , output , contract , state , funded , records )
98
- l .cleanupOrderState (true , cb . Txid , output , contract , state , funded , records )
100
+ l .cleanupOrderState (true , output , contract , state , funded , records )
99
101
continue
100
102
}
101
103
contract , state , funded , records , err = l .getOrderDetails (output .OrderID , output .Address , false )
102
104
if err == nil {
103
105
l .processPurchasePayment (cb .Txid , output , contract , state , funded , records )
104
- l .cleanupOrderState (false , cb . Txid , output , contract , state , funded , records )
106
+ l .cleanupOrderState (false , output , contract , state , funded , records )
105
107
continue
106
108
}
107
109
}
0 commit comments