Commit 6949b26c authored by linj's avatar linj

fix isFinish and status

parent 65ecd8f0
...@@ -173,10 +173,6 @@ func NewOrderTable(kvdb db.KV) *table.Table { ...@@ -173,10 +173,6 @@ func NewOrderTable(kvdb db.KV) *table.Table {
func (t *trade) genSellLimit(tx *types.Transaction, sell *pty.ReceiptSellBase, func (t *trade) genSellLimit(tx *types.Transaction, sell *pty.ReceiptSellBase,
sellorder *pty.SellOrder, txIndex string) *pty.LocalOrder { sellorder *pty.SellOrder, txIndex string) *pty.LocalOrder {
status := sellorder.Status
if status == pty.TradeOrderStatusRevoked || sell.SoldBoardlot > 0 {
status = pty.TradeOrderStatusSellHalfRevoked
}
order := &pty.LocalOrder{ order := &pty.LocalOrder{
AssetSymbol: sellorder.TokenSymbol, AssetSymbol: sellorder.TokenSymbol,
Owner: sellorder.Address, Owner: sellorder.Address,
...@@ -186,7 +182,7 @@ func (t *trade) genSellLimit(tx *types.Transaction, sell *pty.ReceiptSellBase, ...@@ -186,7 +182,7 @@ func (t *trade) genSellLimit(tx *types.Transaction, sell *pty.ReceiptSellBase,
TotalBoardlot: sellorder.TotalBoardlot, TotalBoardlot: sellorder.TotalBoardlot,
TradedBoardlot: sellorder.SoldBoardlot, TradedBoardlot: sellorder.SoldBoardlot,
BuyID: "", BuyID: "",
Status: status, Status: sellorder.Status,
SellID: sell.SellID, SellID: sell.SellID,
TxHash: []string{common.ToHex(tx.Hash())}, TxHash: []string{common.ToHex(tx.Hash())},
Height: sell.Height, Height: sell.Height,
...@@ -195,6 +191,7 @@ func (t *trade) genSellLimit(tx *types.Transaction, sell *pty.ReceiptSellBase, ...@@ -195,6 +191,7 @@ func (t *trade) genSellLimit(tx *types.Transaction, sell *pty.ReceiptSellBase,
IsSellOrder: true, IsSellOrder: true,
AssetExec: sellorder.AssetExec, AssetExec: sellorder.AssetExec,
TxIndex: txIndex, TxIndex: txIndex,
IsFinished: false,
} }
return order return order
} }
...@@ -218,6 +215,7 @@ func (t *trade) updateSellLimit(tx *types.Transaction, sell *pty.ReceiptSellBase ...@@ -218,6 +215,7 @@ func (t *trade) updateSellLimit(tx *types.Transaction, sell *pty.ReceiptSellBase
order.Status = status order.Status = status
order.TxHash = append(order.TxHash, common.ToHex(tx.Hash())) order.TxHash = append(order.TxHash, common.ToHex(tx.Hash()))
order.TradedBoardlot = sellorder.SoldBoardlot order.TradedBoardlot = sellorder.SoldBoardlot
order.IsFinished = (status != pty.TradeOrderStatusOnSale)
ldb.Replace(order) ldb.Replace(order)
...@@ -241,6 +239,7 @@ func (t *trade) rollBackSellLimit(tx *types.Transaction, sell *pty.ReceiptSellBa ...@@ -241,6 +239,7 @@ func (t *trade) rollBackSellLimit(tx *types.Transaction, sell *pty.ReceiptSellBa
order.Status = pty.TradeOrderStatusOnSale order.Status = pty.TradeOrderStatusOnSale
order.TxHash = order.TxHash[:len(order.TxHash)-1] order.TxHash = order.TxHash[:len(order.TxHash)-1]
order.TradedBoardlot = order.TradedBoardlot - tradedBoardlot order.TradedBoardlot = order.TradedBoardlot - tradedBoardlot
order.IsFinished = (order.Status != pty.TradeOrderStatusOnSale)
ldb.Replace(order) ldb.Replace(order)
...@@ -285,6 +284,7 @@ func (t *trade) genSellMarket(tx *types.Transaction, sell *pty.ReceiptSellBase, ...@@ -285,6 +284,7 @@ func (t *trade) genSellMarket(tx *types.Transaction, sell *pty.ReceiptSellBase,
IsSellOrder: true, IsSellOrder: true,
AssetExec: sell.AssetExec, AssetExec: sell.AssetExec,
TxIndex: txIndex, TxIndex: txIndex,
IsFinished: true,
} }
return order return order
} }
...@@ -309,6 +309,7 @@ func (t *trade) genBuyLimit(tx *types.Transaction, buy *pty.ReceiptBuyBase, txIn ...@@ -309,6 +309,7 @@ func (t *trade) genBuyLimit(tx *types.Transaction, buy *pty.ReceiptBuyBase, txIn
IsSellOrder: true, IsSellOrder: true,
AssetExec: buy.AssetExec, AssetExec: buy.AssetExec,
TxIndex: txIndex, TxIndex: txIndex,
IsFinished: false,
} }
return order return order
} }
...@@ -326,12 +327,13 @@ func (t *trade) updateBuyLimit(tx *types.Transaction, buy *pty.ReceiptBuyBase, ...@@ -326,12 +327,13 @@ func (t *trade) updateBuyLimit(tx *types.Transaction, buy *pty.ReceiptBuyBase,
} }
status := buyorder.Status status := buyorder.Status
if status == pty.TradeOrderStatusRevoked && buy.BoughtBoardlot > 0 { if status == pty.TradeOrderStatusBuyRevoked && buy.BoughtBoardlot > 0 {
status = pty.TradeOrderStatusSellHalfRevoked status = pty.TradeOrderStatusBuyHalfRevoked
} }
order.Status = status order.Status = status
order.TxHash = append(order.TxHash, common.ToHex(tx.Hash())) order.TxHash = append(order.TxHash, common.ToHex(tx.Hash()))
order.TradedBoardlot = buyorder.BoughtBoardlot order.TradedBoardlot = buyorder.BoughtBoardlot
order.IsFinished = (status != pty.TradeOrderStatusOnBuy)
ldb.Replace(order) ldb.Replace(order)
...@@ -348,12 +350,12 @@ func (t *trade) rollbackBuyLimit(tx *types.Transaction, buy *pty.ReceiptBuyBase, ...@@ -348,12 +350,12 @@ func (t *trade) rollbackBuyLimit(tx *types.Transaction, buy *pty.ReceiptBuyBase,
order, ok := xs[0].Data.(*pty.LocalOrder) order, ok := xs[0].Data.(*pty.LocalOrder)
if !ok { if !ok {
return nil return nil
} }
order.Status = pty.TradeOrderStatusOnBuy order.Status = pty.TradeOrderStatusOnBuy
order.TxHash = order.TxHash[:len(order.TxHash)-1] order.TxHash = order.TxHash[:len(order.TxHash)-1]
order.TradedBoardlot = order.TradedBoardlot - traded order.TradedBoardlot = order.TradedBoardlot - traded
order.IsFinished = false
ldb.Replace(order) ldb.Replace(order)
...@@ -380,6 +382,7 @@ func (t *trade) genBuyMarket(tx *types.Transaction, buy *pty.ReceiptBuyBase, txI ...@@ -380,6 +382,7 @@ func (t *trade) genBuyMarket(tx *types.Transaction, buy *pty.ReceiptBuyBase, txI
IsSellOrder: true, IsSellOrder: true,
AssetExec: buy.AssetExec, AssetExec: buy.AssetExec,
TxIndex: txIndex, TxIndex: txIndex,
IsFinished: true,
} }
return order return order
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment