impl trade local rollback
@@ -133,8 +133,9 @@ func (t *trade) saveBuy(receiptTradeBuy *pty.ReceiptBuyBase, tx *types.Transacti
return saveBuyMarketOrderKeyValue(kv, receiptTradeBuy, pty.TradeOrderStatusBoughtOut, t.GetHeight())
}
-func (t *trade) deleteBuy(receiptTradeBuy *pty.ReceiptBuyBase) []*types.KeyValue {
+func (t *trade) deleteBuy(receiptTradeBuy *pty.ReceiptBuyBase, txIndex string, ldb *table.Table) []*types.KeyValue {
var kv []*types.KeyValue
+ ldb.Del([]byte(txIndex))
return deleteBuyMarketOrderKeyValue(kv, receiptTradeBuy, pty.TradeOrderStatusBoughtOut, t.GetHeight())
}
@@ -192,8 +193,13 @@ func genDeleteBuyLimitKv(buyOrder *pty.BuyLimitOrder) []*types.KeyValue {
return kv
}
-func (t *trade) deleteBuyLimit(buyID []byte, ty int32) []*types.KeyValue {
- buyOrder := t.getBuyOrderFromDb(buyID)
+func (t *trade) deleteBuyLimit(buy *pty.ReceiptBuyBase, ty int32, tx *types.Transaction, txIndex string, ldb *table.Table, traded int64) []*types.KeyValue {
+ buyOrder := t.getBuyOrderFromDb([]byte(buy.BuyID))
+ if ty == pty.TradeOrderStatusOnBuy && buy.BoughtBoardlot == 0 {
+ ldb.Del([]byte(txIndex))
+ } else {
+ t.rollbackBuyLimit(tx, buy, buyOrder, txIndex, ldb, traded)
+ }
return genDeleteBuyLimitKv(buyOrder)
}
@@ -204,8 +210,9 @@ func (t *trade) saveSellMarket(receiptTradeBuy *pty.ReceiptSellBase, tx *types.T
return saveSellMarketOrderKeyValue(kv, receiptTradeBuy, pty.TradeOrderStatusSoldOut, t.GetHeight())
}
-func (t *trade) deleteSellMarket(receiptTradeBuy *pty.ReceiptSellBase) []*types.KeyValue {
+func (t *trade) deleteSellMarket(receiptTradeBuy *pty.ReceiptSellBase, txIndex string, ldb *table.Table) []*types.KeyValue {
var kv []*types.KeyValue
+ ldb.Del([]byte(txIndex))
return deleteSellMarketOrderKeyValue(kv, receiptTradeBuy, pty.TradeOrderStatusSoldOut, t.GetHeight())
}
