Commit 2baff87a authored by harrylee's avatar harrylee Committed by vipwzw

ajust code for table

parent 2dfb0996
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
查询方法名称|功能 查询方法名称|功能
-----|---- -----|----
QueryMarketDepth|获取指定交易资产的市场深度 QueryMarketDepth|获取指定交易资产的市场深度
QueryCompletedOrderList|实时获取指定交易对最新的成交信息 QueryHistoryOrderList|实时获取指定交易对已经成交的订单信息
QueryOrder|根据orderID订单号查询具体的订单信息 QueryOrder|根据orderID订单号查询具体的订单信息
QueryOrderList|根据用户地址和订单状态(ordered,completed,revoked),实时地获取相应相应的订单详情 QueryOrderList|根据用户地址和订单状态(ordered,completed,revoked),实时地获取相应相应的订单详情
......
...@@ -240,8 +240,8 @@ func TestExchange(t *testing.T) { ...@@ -240,8 +240,8 @@ func TestExchange(t *testing.T) {
//市场深度应该改变 //市场深度应该改变
assert.Equal(t, 5*types.Coin, reply1.List[0].GetAmount()) assert.Equal(t, 5*types.Coin, reply1.List[0].GetAmount())
//QueryCompletedOrderList //QueryHistoryOrderList
msg, err = exec.Query(et.FuncNameQueryCompletedOrderList, types.Encode(&et.QueryCompletedOrderList{LeftAsset: &et.Asset{Symbol: "bty", Execer: "coins"}, msg, err = exec.Query(et.FuncNameQueryHistoryOrderList, types.Encode(&et.QueryHistoryOrderList{LeftAsset: &et.Asset{Symbol: "bty", Execer: "coins"},
RightAsset: &et.Asset{Execer: "token", Symbol: "CCNY"}})) RightAsset: &et.Asset{Execer: "token", Symbol: "CCNY"}}))
if err != nil { if err != nil {
t.Error(err) t.Error(err)
...@@ -831,14 +831,12 @@ func TestCheckPrice(t *testing.T) { ...@@ -831,14 +831,12 @@ func TestCheckPrice(t *testing.T) {
} }
func TestRawMeta(t *testing.T) { func TestRawMeta(t *testing.T) {
CompletedOrderRow := NewCompletedOrderRow() HistoryOrderRow := NewHistoryOrderRow()
t.Log(CompletedOrderRow.Get("index")) t.Log(HistoryOrderRow.Get("index"))
MarketDepthRow := NewMarketDepthRow() MarketDepthRow := NewMarketDepthRow()
t.Log(MarketDepthRow.Get("price")) t.Log(MarketDepthRow.Get("price"))
marketOrderRow := NewOrderRow() marketOrderRow := NewOrderRow()
t.Log(marketOrderRow.Get("orderID")) t.Log(marketOrderRow.Get("orderID"))
UserOrderRow := NewUserOrderRow()
t.Log(UserOrderRow.Get("index"))
} }
func TestKV(t *testing.T) { func TestKV(t *testing.T) {
......
...@@ -585,19 +585,20 @@ func QueryMarketDepth(localdb dbm.KV, left, right *et.Asset, op int32, primaryKe ...@@ -585,19 +585,20 @@ func QueryMarketDepth(localdb dbm.KV, left, right *et.Asset, op int32, primaryKe
return &list, nil return &list, nil
} }
//QueryCompletedOrderList //QueryHistoryOrderList
func QueryCompletedOrderList(localdb dbm.KV, left, right *et.Asset, primaryKey string, count, direction int32) (types.Message, error) { func QueryHistoryOrderList(localdb dbm.KV, left, right *et.Asset, primaryKey string, count, direction int32) (types.Message, error) {
table := NewCompletedOrderTable(localdb) table := NewHistoryOrderTable(localdb)
prefix := []byte(fmt.Sprintf("%s:%s", left.Symbol, right.Symbol)) prefix := []byte(fmt.Sprintf("%s:%s", left.Symbol, right.Symbol))
indexName := "name"
if count == 0 { if count == 0 {
count = et.Count count = et.Count
} }
var rows []*tab.Row var rows []*tab.Row
var err error var err error
if primaryKey == "" { //第一次查询,默认展示最新得成交记录 if primaryKey == "" { //第一次查询,默认展示最新得成交记录
rows, err = table.ListIndex("index", prefix, nil, count, direction) rows, err = table.ListIndex(indexName, prefix, nil, count, direction)
} else { } else {
rows, err = table.ListIndex("index", prefix, []byte(primaryKey), count, direction) rows, err = table.ListIndex(indexName, prefix, []byte(primaryKey), count, direction)
} }
if err != nil { if err != nil {
elog.Error("QueryCompletedOrderList.", "left", left, "right", right, "err", err.Error()) elog.Error("QueryCompletedOrderList.", "left", left, "right", right, "err", err.Error())
...@@ -607,6 +608,10 @@ func QueryCompletedOrderList(localdb dbm.KV, left, right *et.Asset, primaryKey s ...@@ -607,6 +608,10 @@ func QueryCompletedOrderList(localdb dbm.KV, left, right *et.Asset, primaryKey s
var orderList et.OrderList var orderList et.OrderList
for _, row := range rows { for _, row := range rows {
order := row.Data.(*et.Order) order := row.Data.(*et.Order)
//因为这张表里面记录了 completed,revoked 两种状态的订单,所以需要过滤
if order.Status == et.Revoked {
continue
}
//替换已经成交得量 //替换已经成交得量
order.Executed = order.GetLimitOrder().Amount - order.Balance order.Executed = order.GetLimitOrder().Amount - order.Balance
orderList.List = append(orderList.List, order) orderList.List = append(orderList.List, order)
...@@ -620,17 +625,23 @@ func QueryCompletedOrderList(localdb dbm.KV, left, right *et.Asset, primaryKey s ...@@ -620,17 +625,23 @@ func QueryCompletedOrderList(localdb dbm.KV, left, right *et.Asset, primaryKey s
//QueryOrderList,默认展示最新的 //QueryOrderList,默认展示最新的
func QueryOrderList(localdb dbm.KV, statedb dbm.KV, addr string, status, count, direction int32, primaryKey string) (types.Message, error) { func QueryOrderList(localdb dbm.KV, statedb dbm.KV, addr string, status, count, direction int32, primaryKey string) (types.Message, error) {
table := NewUserOrderTable(localdb) var table *tab.Table
if status == et.Completed || status == et.Revoked {
table = NewHistoryOrderTable(localdb)
} else {
table = NewMarketOrderTable(localdb)
}
prefix := []byte(fmt.Sprintf("%s:%d", addr, status)) prefix := []byte(fmt.Sprintf("%s:%d", addr, status))
indexName := "addr_status"
if count == 0 { if count == 0 {
count = et.Count count = et.Count
} }
var rows []*tab.Row var rows []*tab.Row
var err error var err error
if primaryKey == "" { //第一次查询,默认展示最新得成交记录 if primaryKey == "" { //第一次查询,默认展示最新得成交记录
rows, err = table.ListIndex("index", prefix, nil, count, direction) rows, err = table.ListIndex(indexName, prefix, nil, count, direction)
} else { } else {
rows, err = table.ListIndex("index", prefix, []byte(primaryKey), count, direction) rows, err = table.ListIndex(indexName, prefix, []byte(primaryKey), count, direction)
} }
if err != nil { if err != nil {
elog.Error("QueryOrderList.", "addr", addr, "err", err.Error()) elog.Error("QueryOrderList.", "addr", addr, "err", err.Error())
......
...@@ -66,16 +66,14 @@ func (e *exchange) ExecLocal_RevokeOrder(payload *ety.RevokeOrder, tx *types.Tra ...@@ -66,16 +66,14 @@ func (e *exchange) ExecLocal_RevokeOrder(payload *ety.RevokeOrder, tx *types.Tra
//设置自动回滚 //设置自动回滚
func (e *exchange) addAutoRollBack(tx *types.Transaction, kv []*types.KeyValue) *types.LocalDBSet { func (e *exchange) addAutoRollBack(tx *types.Transaction, kv []*types.KeyValue) *types.LocalDBSet {
dbSet := &types.LocalDBSet{} dbSet := &types.LocalDBSet{}
dbSet.KV = e.AddRollbackKV(tx, tx.Execer, kv) dbSet.KV = e.AddRollbackKV(tx, tx.Execer, kv)
return dbSet return dbSet
} }
func (e *exchange) updateIndex(receipt *ety.ReceiptExchange) (kvs []*types.KeyValue) { func (e *exchange) updateIndex(receipt *ety.ReceiptExchange) (kvs []*types.KeyValue) {
completedTable := NewCompletedOrderTable(e.GetLocalDB()) historyTable := NewHistoryOrderTable(e.GetLocalDB())
marketTable := NewMarketDepthTable(e.GetLocalDB()) marketTable := NewMarketDepthTable(e.GetLocalDB())
userTable := NewUserOrderTable(e.GetLocalDB())
orderTable := NewMarketOrderTable(e.GetLocalDB()) orderTable := NewMarketOrderTable(e.GetLocalDB())
switch receipt.Order.Status { switch receipt.Order.Status {
case ety.Ordered: case ety.Ordered:
...@@ -111,30 +109,26 @@ func (e *exchange) updateIndex(receipt *ety.ReceiptExchange) (kvs []*types.KeyVa ...@@ -111,30 +109,26 @@ func (e *exchange) updateIndex(receipt *ety.ReceiptExchange) (kvs []*types.KeyVa
elog.Error("updateIndex", "orderTable.Replace", err.Error()) elog.Error("updateIndex", "orderTable.Replace", err.Error())
return nil return nil
} }
err = userTable.Replace(order)
if err != nil {
return nil
}
if len(receipt.MatchOrders) > 0 { if len(receipt.MatchOrders) > 0 {
//撮合交易更新 //撮合交易更新
cache := make(map[float64]int64) cache := make(map[float64]int64)
for i, matchOrder := range receipt.MatchOrders { for i, matchOrder := range receipt.MatchOrders {
if matchOrder.Status == ety.Completed { if matchOrder.Status == ety.Completed {
// 删除原有状态orderID // 删除原有状态orderID
matchOrder.Status = ety.Ordered
err = orderTable.DelRow(matchOrder) err = orderTable.DelRow(matchOrder)
if err != nil { if err != nil {
elog.Error("updateIndex", "orderTable.DelRow", err.Error()) elog.Error("updateIndex", "orderTable.DelRow", err.Error())
return nil return nil
} }
//删除原有状态orderID //索引index,改为当前的index
matchOrder.Status = ety.Ordered
userTable.DelRow(matchOrder)
//更新状态为已完成,索引index,改为当前的index
matchOrder.Status = ety.Completed matchOrder.Status = ety.Completed
matchOrder.Index = index + int64(i+1) matchOrder.Index = index + int64(i+1)
userTable.Replace(matchOrder) err = historyTable.Replace(matchOrder)
//calcCompletedOrderKey if err != nil {
completedTable.Replace(matchOrder) elog.Error("updateIndex", "historyTable.Replace", err.Error())
return nil
}
} }
if matchOrder.Status == ety.Ordered { if matchOrder.Status == ety.Ordered {
//更新数据 //更新数据
...@@ -183,14 +177,9 @@ func (e *exchange) updateIndex(receipt *ety.ReceiptExchange) (kvs []*types.KeyVa ...@@ -183,14 +177,9 @@ func (e *exchange) updateIndex(receipt *ety.ReceiptExchange) (kvs []*types.KeyVa
right := receipt.GetOrder().GetLimitOrder().GetRightAsset() right := receipt.GetOrder().GetLimitOrder().GetRightAsset()
op := receipt.GetOrder().GetLimitOrder().GetOp() op := receipt.GetOrder().GetLimitOrder().GetOp()
index := receipt.GetIndex() index := receipt.GetIndex()
err := userTable.Replace(receipt.GetOrder()) err := historyTable.Replace(receipt.GetOrder())
if err != nil {
elog.Error("updateIndex", "userTable.Replace", err.Error())
return nil
}
err = completedTable.Replace(receipt.Order)
if err != nil { if err != nil {
elog.Error("updateIndex", "completedTable.Replace", err.Error()) elog.Error("updateIndex", "historyTable.Replace", err.Error())
return nil return nil
} }
cache := make(map[float64]int64) cache := make(map[float64]int64)
...@@ -199,30 +188,18 @@ func (e *exchange) updateIndex(receipt *ety.ReceiptExchange) (kvs []*types.KeyVa ...@@ -199,30 +188,18 @@ func (e *exchange) updateIndex(receipt *ety.ReceiptExchange) (kvs []*types.KeyVa
for i, matchOrder := range receipt.MatchOrders { for i, matchOrder := range receipt.MatchOrders {
if matchOrder.Status == ety.Completed { if matchOrder.Status == ety.Completed {
// 删除原有状态orderID // 删除原有状态orderID
matchOrder.Status = ety.Ordered
err = orderTable.DelRow(matchOrder) err = orderTable.DelRow(matchOrder)
if err != nil { if err != nil {
elog.Error("updateIndex", "orderTable.DelRow", err.Error()) elog.Error("updateIndex", "orderTable.DelRow", err.Error())
return nil return nil
} }
//删除原有状态orderID //索引index,改为当前的index
matchOrder.Status = ety.Ordered
err = userTable.DelRow(matchOrder)
if err != nil {
elog.Error("updateIndex", "userTable.DelRow", err.Error())
return nil
}
//更新状态为已完成,更新索引
matchOrder.Status = ety.Completed matchOrder.Status = ety.Completed
matchOrder.Index = index + int64(i+1) matchOrder.Index = index + int64(i+1)
err = userTable.Replace(matchOrder) err = historyTable.Replace(matchOrder)
if err != nil {
elog.Error("updateIndex", "userTable.Replace", err.Error())
return nil
}
//calcCompletedOrderKey
err = completedTable.Replace(matchOrder)
if err != nil { if err != nil {
elog.Error("updateIndex", "completedTable.Replace", err.Error()) elog.Error("updateIndex", "historyTable.Replace", err.Error())
return nil return nil
} }
} }
...@@ -299,25 +276,19 @@ func (e *exchange) updateIndex(receipt *ety.ReceiptExchange) (kvs []*types.KeyVa ...@@ -299,25 +276,19 @@ func (e *exchange) updateIndex(receipt *ety.ReceiptExchange) (kvs []*types.KeyVa
return nil return nil
} }
} }
// 删除原有状态orderID
err = orderTable.DelRow(order)
if err != nil {
elog.Error("updateIndex", "orderTable.DelRow", err.Error())
return nil
}
//删除原有状态orderID //删除原有状态orderID
order.Status = ety.Ordered order.Status = ety.Ordered
err = userTable.DelRow(order) err = orderTable.DelRow(order)
if err != nil { if err != nil {
elog.Error("updateIndex", "userTable.DelRow", err.Error()) elog.Error("updateIndex", "orderTable.DelRow", err.Error())
return nil return nil
} }
order.Status = ety.Revoked order.Status = ety.Revoked
order.Index = index order.Index = index
//添加撤销的订单 //添加撤销的订单
err = userTable.Replace(order) err = historyTable.Replace(order)
if err != nil { if err != nil {
elog.Error("updateIndex", "userTable.Replace", err.Error()) elog.Error("updateIndex", "historyTable.Replace", err.Error())
return nil return nil
} }
} }
...@@ -328,21 +299,15 @@ func (e *exchange) updateIndex(receipt *ety.ReceiptExchange) (kvs []*types.KeyVa ...@@ -328,21 +299,15 @@ func (e *exchange) updateIndex(receipt *ety.ReceiptExchange) (kvs []*types.KeyVa
return nil return nil
} }
kvs = append(kvs, kv...) kvs = append(kvs, kv...)
kv, err = userTable.Save()
if err != nil {
elog.Error("updateIndex", "userTable.Save", err.Error())
return nil
}
kvs = append(kvs, kv...)
kv, err = orderTable.Save() kv, err = orderTable.Save()
if err != nil { if err != nil {
elog.Error("updateIndex", "orderTable.Save", err.Error()) elog.Error("updateIndex", "orderTable.Save", err.Error())
return nil return nil
} }
kvs = append(kvs, kv...) kvs = append(kvs, kv...)
kv, err = completedTable.Save() kv, err = historyTable.Save()
if err != nil { if err != nil {
elog.Error("updateIndex", "completedTable.Save", err.Error()) elog.Error("updateIndex", "historyTable.Save", err.Error())
return nil return nil
} }
kvs = append(kvs, kv...) kvs = append(kvs, kv...)
......
...@@ -24,7 +24,7 @@ func (s *exchange) Query_QueryMarketDepth(in *et.QueryMarketDepth) (types.Messag ...@@ -24,7 +24,7 @@ func (s *exchange) Query_QueryMarketDepth(in *et.QueryMarketDepth) (types.Messag
} }
//查询已经完成得订单 //查询已经完成得订单
func (s *exchange) Query_QueryCompletedOrderList(in *et.QueryCompletedOrderList) (types.Message, error) { func (s *exchange) Query_QueryHistoryOrderList(in *et.QueryHistoryOrderList) (types.Message, error) {
if !CheckExchangeAsset(in.LeftAsset, in.RightAsset) { if !CheckExchangeAsset(in.LeftAsset, in.RightAsset) {
return nil, et.ErrAsset return nil, et.ErrAsset
} }
...@@ -35,7 +35,7 @@ func (s *exchange) Query_QueryCompletedOrderList(in *et.QueryCompletedOrderList) ...@@ -35,7 +35,7 @@ func (s *exchange) Query_QueryCompletedOrderList(in *et.QueryCompletedOrderList)
if !CheckDirection(in.Direction) { if !CheckDirection(in.Direction) {
return nil, et.ErrDirection return nil, et.ErrDirection
} }
return QueryCompletedOrderList(s.GetLocalDB(), in.LeftAsset, in.RightAsset, in.PrimaryKey, in.Count, in.Direction) return QueryHistoryOrderList(s.GetLocalDB(), in.LeftAsset, in.RightAsset, in.PrimaryKey, in.Count, in.Direction)
} }
//根据orderID查询订单信息 //根据orderID查询订单信息
......
...@@ -40,22 +40,14 @@ var opt_exchange_order = &table.Option{ ...@@ -40,22 +40,14 @@ var opt_exchange_order = &table.Option{
Prefix: KeyPrefixLocalDB, Prefix: KeyPrefixLocalDB,
Name: "order", Name: "order",
Primary: "orderID", Primary: "orderID",
Index: []string{"market_order"}, Index: []string{"market_order","addr_status"},
} }
//根据地址和状态,index是实时在变化,要有先后顺序 var opt_exchange_history = &table.Option{
var opt_exchange_user_order = &table.Option{
Prefix: KeyPrefixLocalDB, Prefix: KeyPrefixLocalDB,
Name: "UserOrder", Name: "history",
Primary: "index", Primary: "index",
Index: nil, Index: []string{"name","addr_status"},
}
var opt_exchange_completed = &table.Option{
Prefix: KeyPrefixLocalDB,
Name: "completed",
Primary: "index",
Index: nil,
} }
//NewTable 新建表 //NewTable 新建表
...@@ -77,17 +69,10 @@ func NewMarketOrderTable(kvdb db.KV) *table.Table { ...@@ -77,17 +69,10 @@ func NewMarketOrderTable(kvdb db.KV) *table.Table {
return table return table
} }
func NewUserOrderTable(kvdb db.KV) *table.Table {
rowmeta := NewUserOrderRow() func NewHistoryOrderTable(kvdb db.KV) *table.Table {
table, err := table.NewTable(rowmeta, kvdb, opt_exchange_user_order) rowmeta := NewHistoryOrderRow()
if err != nil { table, err := table.NewTable(rowmeta, kvdb, opt_exchange_history)
panic(err)
}
return table
}
func NewCompletedOrderTable(kvdb db.KV) *table.Table {
rowmeta := NewCompletedOrderRow()
table, err := table.NewTable(rowmeta, kvdb, opt_exchange_completed)
if err != nil { if err != nil {
panic(err) panic(err)
} }
...@@ -124,57 +109,27 @@ func (r *OrderRow) Get(key string) ([]byte, error) { ...@@ -124,57 +109,27 @@ func (r *OrderRow) Get(key string) ([]byte, error) {
return []byte(fmt.Sprintf("%022d", r.OrderID)), nil return []byte(fmt.Sprintf("%022d", r.OrderID)), nil
} else if key == "market_order" { } else if key == "market_order" {
return []byte(fmt.Sprintf("%s:%s:%d:%016d", r.GetLimitOrder().LeftAsset.GetSymbol(), r.GetLimitOrder().RightAsset.GetSymbol(), r.GetLimitOrder().Op, int64(Truncate(r.GetLimitOrder().Price*float64(1e8))))), nil return []byte(fmt.Sprintf("%s:%s:%d:%016d", r.GetLimitOrder().LeftAsset.GetSymbol(), r.GetLimitOrder().RightAsset.GetSymbol(), r.GetLimitOrder().Op, int64(Truncate(r.GetLimitOrder().Price*float64(1e8))))), nil
} else if key == "addr_status"{
return []byte(fmt.Sprintf("%s:%d", r.Addr, r.Status)), nil
} }
return nil, types.ErrNotFound return nil, types.ErrNotFound
} }
//UserOrderRow table meta 结构 //HistoryOrderRow table meta 结构
type UserOrderRow struct { type HistoryOrderRow struct {
*ety.Order
}
//NewOrderRow 新建一个meta 结构
func NewUserOrderRow() *UserOrderRow {
return &UserOrderRow{Order: &ety.Order{Value: &ety.Order_LimitOrder{LimitOrder: &ety.LimitOrder{}}}}
}
//CreateRow
func (r *UserOrderRow) CreateRow() *table.Row {
return &table.Row{Data: &ety.Order{}}
}
//SetPayload 设置数据
func (r *UserOrderRow) SetPayload(data types.Message) error {
if txdata, ok := data.(*ety.Order); ok {
r.Order = txdata
return nil
}
return types.ErrTypeAsset
}
//Get 按照indexName 查询 indexValue
func (r *UserOrderRow) Get(key string) ([]byte, error) {
if key == "index" {
return []byte(fmt.Sprintf("%s:%d:%022d", r.Addr, r.Status, r.Index)), nil
}
return nil, types.ErrNotFound
}
//CompletedOrderRow table meta 结构
type CompletedOrderRow struct {
*ety.Order *ety.Order
} }
func NewCompletedOrderRow() *CompletedOrderRow { func NewHistoryOrderRow() *HistoryOrderRow {
return &CompletedOrderRow{Order: &ety.Order{Value: &ety.Order_LimitOrder{LimitOrder: &ety.LimitOrder{}}}} return &HistoryOrderRow{Order: &ety.Order{Value: &ety.Order_LimitOrder{LimitOrder: &ety.LimitOrder{}}}}
} }
func (m *CompletedOrderRow) CreateRow() *table.Row { func (m *HistoryOrderRow) CreateRow() *table.Row {
return &table.Row{Data: &ety.Order{Value: &ety.Order_LimitOrder{LimitOrder: &ety.LimitOrder{}}}} return &table.Row{Data: &ety.Order{Value: &ety.Order_LimitOrder{LimitOrder: &ety.LimitOrder{}}}}
} }
//SetPayload 设置数据 //SetPayload 设置数据
func (m *CompletedOrderRow) SetPayload(data types.Message) error { func (m *HistoryOrderRow) SetPayload(data types.Message) error {
if txdata, ok := data.(*ety.Order); ok { if txdata, ok := data.(*ety.Order); ok {
m.Order = txdata m.Order = txdata
return nil return nil
...@@ -183,9 +138,13 @@ func (m *CompletedOrderRow) SetPayload(data types.Message) error { ...@@ -183,9 +138,13 @@ func (m *CompletedOrderRow) SetPayload(data types.Message) error {
} }
//Get 按照indexName 查询 indexValue //Get 按照indexName 查询 indexValue
func (m *CompletedOrderRow) Get(key string) ([]byte, error) { func (m *HistoryOrderRow) Get(key string) ([]byte, error) {
if key == "index" { if key == "index" {
return []byte(fmt.Sprintf("%s:%s:%022d", m.GetLimitOrder().LeftAsset.GetSymbol(), m.GetLimitOrder().RightAsset.GetSymbol(), m.Index)), nil return []byte(fmt.Sprintf("%022d", m.Index)), nil
}else if key == "name"{
return []byte(fmt.Sprintf("%s:%s", m.GetLimitOrder().LeftAsset.GetSymbol(), m.GetLimitOrder().RightAsset.GetSymbol())), nil
} else if key == "addr_status"{
return []byte(fmt.Sprintf("%s:%d", m.Addr, m.Status)), nil
} }
return nil, types.ErrNotFound return nil, types.ErrNotFound
} }
......
...@@ -105,7 +105,7 @@ message MarketDepthList { ...@@ -105,7 +105,7 @@ message MarketDepthList {
} }
//查询最新得成交信息,外部接口 //查询最新得成交信息,外部接口
message QueryCompletedOrderList { message QueryHistoryOrderList {
//资产1 //资产1
asset leftAsset = 1; asset leftAsset = 1;
//资产2 //资产2
......
...@@ -24,7 +24,7 @@ const ( ...@@ -24,7 +24,7 @@ const (
NameRevokeOrderAction = "RevokeOrder" NameRevokeOrderAction = "RevokeOrder"
FuncNameQueryMarketDepth = "QueryMarketDepth" FuncNameQueryMarketDepth = "QueryMarketDepth"
FuncNameQueryCompletedOrderList = "QueryCompletedOrderList" FuncNameQueryHistoryOrderList = "QueryHistoryOrderList"
FuncNameQueryOrder = "QueryOrder" FuncNameQueryOrder = "QueryOrder"
FuncNameQueryOrderList = "QueryOrderList" FuncNameQueryOrderList = "QueryOrderList"
) )
......
...@@ -18,7 +18,7 @@ It has these top-level messages: ...@@ -18,7 +18,7 @@ It has these top-level messages:
QueryMarketDepth QueryMarketDepth
MarketDepth MarketDepth
MarketDepthList MarketDepthList
QueryCompletedOrderList QueryHistoryOrderList
QueryOrder QueryOrder
QueryOrderList QueryOrderList
OrderList OrderList
...@@ -26,15 +26,12 @@ It has these top-level messages: ...@@ -26,15 +26,12 @@ It has these top-level messages:
*/ */
package types package types
import ( import proto "github.com/golang/protobuf/proto"
fmt "fmt" import fmt "fmt"
import math "math"
proto "github.com/golang/protobuf/proto"
math "math"
import (
context "golang.org/x/net/context" context "golang.org/x/net/context"
grpc "google.golang.org/grpc" grpc "google.golang.org/grpc"
) )
...@@ -686,7 +683,7 @@ func (m *MarketDepthList) GetPrimaryKey() string { ...@@ -686,7 +683,7 @@ func (m *MarketDepthList) GetPrimaryKey() string {
} }
// 查询最新得成交信息,外部接口 // 查询最新得成交信息,外部接口
type QueryCompletedOrderList struct { type QueryHistoryOrderList struct {
// 资产1 // 资产1
LeftAsset *Asset `protobuf:"bytes,1,opt,name=leftAsset" json:"leftAsset,omitempty"` LeftAsset *Asset `protobuf:"bytes,1,opt,name=leftAsset" json:"leftAsset,omitempty"`
// 资产2 // 资产2
...@@ -699,40 +696,40 @@ type QueryCompletedOrderList struct { ...@@ -699,40 +696,40 @@ type QueryCompletedOrderList struct {
Direction int32 `protobuf:"varint,5,opt,name=direction" json:"direction,omitempty"` Direction int32 `protobuf:"varint,5,opt,name=direction" json:"direction,omitempty"`
} }
func (m *QueryCompletedOrderList) Reset() { *m = QueryCompletedOrderList{} } func (m *QueryHistoryOrderList) Reset() { *m = QueryHistoryOrderList{} }
func (m *QueryCompletedOrderList) String() string { return proto.CompactTextString(m) } func (m *QueryHistoryOrderList) String() string { return proto.CompactTextString(m) }
func (*QueryCompletedOrderList) ProtoMessage() {} func (*QueryHistoryOrderList) ProtoMessage() {}
func (*QueryCompletedOrderList) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} } func (*QueryHistoryOrderList) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} }
func (m *QueryCompletedOrderList) GetLeftAsset() *Asset { func (m *QueryHistoryOrderList) GetLeftAsset() *Asset {
if m != nil { if m != nil {
return m.LeftAsset return m.LeftAsset
} }
return nil return nil
} }
func (m *QueryCompletedOrderList) GetRightAsset() *Asset { func (m *QueryHistoryOrderList) GetRightAsset() *Asset {
if m != nil { if m != nil {
return m.RightAsset return m.RightAsset
} }
return nil return nil
} }
func (m *QueryCompletedOrderList) GetPrimaryKey() string { func (m *QueryHistoryOrderList) GetPrimaryKey() string {
if m != nil { if m != nil {
return m.PrimaryKey return m.PrimaryKey
} }
return "" return ""
} }
func (m *QueryCompletedOrderList) GetCount() int32 { func (m *QueryHistoryOrderList) GetCount() int32 {
if m != nil { if m != nil {
return m.Count return m.Count
} }
return 0 return 0
} }
func (m *QueryCompletedOrderList) GetDirection() int32 { func (m *QueryHistoryOrderList) GetDirection() int32 {
if m != nil { if m != nil {
return m.Direction return m.Direction
} }
...@@ -879,7 +876,7 @@ func init() { ...@@ -879,7 +876,7 @@ func init() {
proto.RegisterType((*QueryMarketDepth)(nil), "types.QueryMarketDepth") proto.RegisterType((*QueryMarketDepth)(nil), "types.QueryMarketDepth")
proto.RegisterType((*MarketDepth)(nil), "types.MarketDepth") proto.RegisterType((*MarketDepth)(nil), "types.MarketDepth")
proto.RegisterType((*MarketDepthList)(nil), "types.MarketDepthList") proto.RegisterType((*MarketDepthList)(nil), "types.MarketDepthList")
proto.RegisterType((*QueryCompletedOrderList)(nil), "types.QueryCompletedOrderList") proto.RegisterType((*QueryHistoryOrderList)(nil), "types.QueryHistoryOrderList")
proto.RegisterType((*QueryOrder)(nil), "types.QueryOrder") proto.RegisterType((*QueryOrder)(nil), "types.QueryOrder")
proto.RegisterType((*QueryOrderList)(nil), "types.QueryOrderList") proto.RegisterType((*QueryOrderList)(nil), "types.QueryOrderList")
proto.RegisterType((*OrderList)(nil), "types.OrderList") proto.RegisterType((*OrderList)(nil), "types.OrderList")
...@@ -927,46 +924,46 @@ var _Exchange_serviceDesc = grpc.ServiceDesc{ ...@@ -927,46 +924,46 @@ var _Exchange_serviceDesc = grpc.ServiceDesc{
func init() { proto.RegisterFile("exchange.proto", fileDescriptor0) } func init() { proto.RegisterFile("exchange.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{ var fileDescriptor0 = []byte{
// 647 bytes of a gzipped FileDescriptorProto // 644 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xcf, 0x6e, 0xd3, 0x4e, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xcd, 0x6e, 0xd3, 0x40,
0x10, 0xae, 0xed, 0xb8, 0xa9, 0x27, 0x3f, 0xa5, 0x3f, 0x56, 0x08, 0x2c, 0x84, 0x50, 0xe4, 0x43, 0x10, 0xae, 0xed, 0xb8, 0xa9, 0x27, 0x28, 0x85, 0x15, 0x20, 0x0b, 0x21, 0x14, 0xf9, 0x50, 0x2a,
0xa9, 0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 0xb6, 0x39, 0x66, 0x28, 0x4a, 0xd5, 0xbe, 0xa1, 0x2c, 0x81,
0x51, 0x96, 0x40, 0x58, 0x39, 0x4f, 0xe7, 0x72, 0x55, 0xe3, 0x62, 0x63, 0x7d, 0x63, 0xa9, 0x6c, 0xb0, 0x70, 0x1e, 0xce, 0xe5, 0xaa, 0xc6, 0xc5, 0xc6, 0xfa, 0xbe, 0x52, 0xd9, 0x84, 0x8c, 0xba,
0x42, 0x46, 0xdd, 0xf7, 0xd5, 0xff, 0xbb, 0x01, 0xdd, 0xbd, 0x10, 0x38, 0xf7, 0xc2, 0x1e, 0xe8, 0xef, 0xab, 0xff, 0x77, 0x03, 0xba, 0x5b, 0x21, 0x70, 0x6e, 0x85, 0x3d, 0xd0, 0xb7, 0x95, 0xf9,
0xfb, 0xca, 0xfc, 0xf5, 0x74, 0x93, 0x9e, 0xf8, 0xfd, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xf3, 0xeb, 0xe9, 0x26, 0x3d, 0xf0, 0xfb, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x99, 0xd7, 0x24, 0x52,
0x6d, 0x05, 0xfd, 0xf4, 0x07, 0x00, 0x00, 0xf2, 0x07, 0x00, 0x00,
} }
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