Commit 60252d13 authored by harrylee2015's avatar harrylee2015

Merge remote-tracking branch 'upstream/master' into game

parents e56fb37a 0ac1f080
...@@ -17,11 +17,14 @@ func calcCertHeightKey(height int64) []byte { ...@@ -17,11 +17,14 @@ func calcCertHeightKey(height int64) []byte {
} }
// ExecLocal_New 启用证书交易执行 // ExecLocal_New 启用证书交易执行
func (c *Cert) ExecLocal_New(payload *ct.CertNew, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (c *Cert) ExecLocal_New(payload *ct.CertNew, tx *types.Transaction, receiptData types.ExecTypeGet, index int) (*types.LocalDBSet, error) {
if !authority.IsAuthEnable { if !authority.IsAuthEnable {
clog.Error("Authority is not available. Please check the authority config or authority initialize error logs.") clog.Error("Authority is not available. Please check the authority config or authority initialize error logs.")
return nil, ct.ErrInitializeAuthority return nil, ct.ErrInitializeAuthority
} }
if receiptData.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
var set types.LocalDBSet var set types.LocalDBSet
historityCertdata := &types.HistoryCertStore{} historityCertdata := &types.HistoryCertStore{}
...@@ -46,11 +49,14 @@ func (c *Cert) ExecLocal_New(payload *ct.CertNew, tx *types.Transaction, receipt ...@@ -46,11 +49,14 @@ func (c *Cert) ExecLocal_New(payload *ct.CertNew, tx *types.Transaction, receipt
} }
// ExecLocal_Update 更新证书交易执行 // ExecLocal_Update 更新证书交易执行
func (c *Cert) ExecLocal_Update(payload *ct.CertUpdate, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (c *Cert) ExecLocal_Update(payload *ct.CertUpdate, tx *types.Transaction, receiptData types.ExecTypeGet, index int) (*types.LocalDBSet, error) {
if !authority.IsAuthEnable { if !authority.IsAuthEnable {
clog.Error("Authority is not available. Please check the authority config or authority initialize error logs.") clog.Error("Authority is not available. Please check the authority config or authority initialize error logs.")
return nil, ct.ErrInitializeAuthority return nil, ct.ErrInitializeAuthority
} }
if receiptData.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
var set types.LocalDBSet var set types.LocalDBSet
// 写入上一纪录的next-height // 写入上一纪录的next-height
...@@ -76,11 +82,14 @@ func (c *Cert) ExecLocal_Update(payload *ct.CertUpdate, tx *types.Transaction, r ...@@ -76,11 +82,14 @@ func (c *Cert) ExecLocal_Update(payload *ct.CertUpdate, tx *types.Transaction, r
} }
// ExecLocal_Normal 非证书变更交易执行 // ExecLocal_Normal 非证书变更交易执行
func (c *Cert) ExecLocal_Normal(payload *ct.CertNormal, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (c *Cert) ExecLocal_Normal(payload *ct.CertNormal, tx *types.Transaction, receiptData types.ExecTypeGet, index int) (*types.LocalDBSet, error) {
if !authority.IsAuthEnable { if !authority.IsAuthEnable {
clog.Error("Authority is not available. Please check the authority config or authority initialize error logs.") clog.Error("Authority is not available. Please check the authority config or authority initialize error logs.")
return nil, ct.ErrInitializeAuthority return nil, ct.ErrInitializeAuthority
} }
if receiptData.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
var set types.LocalDBSet var set types.LocalDBSet
return &set, nil return &set, nil
......
...@@ -30,5 +30,5 @@ func (g *Game) Query_QueryGameById(in *gt.QueryGameInfo) (types.Message, error) ...@@ -30,5 +30,5 @@ func (g *Game) Query_QueryGameById(in *gt.QueryGameInfo) (types.Message, error)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &gt.ReplyGame{game}, nil return &gt.ReplyGame{Game: game}, nil
} }
...@@ -11,7 +11,10 @@ import ( ...@@ -11,7 +11,10 @@ import (
) )
// ExecDelLocal_Hlock Action // ExecDelLocal_Hlock Action
func (h *Hashlock) ExecDelLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (h *Hashlock) ExecDelLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transaction, receipt types.ExecTypeGet, index int) (*types.LocalDBSet, error) {
if receipt.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
info := pty.Hashlockquery{Time: hlock.Time, Status: hashlockLocked, Amount: hlock.Amount, CreateTime: h.GetBlockTime(), CurrentTime: 0} info := pty.Hashlockquery{Time: hlock.Time, Status: hashlockLocked, Amount: hlock.Amount, CreateTime: h.GetBlockTime(), CurrentTime: 0}
kv, err := UpdateHashReciver(h.GetLocalDB(), hlock.Hash, info) kv, err := UpdateHashReciver(h.GetLocalDB(), hlock.Hash, info)
if err != nil { if err != nil {
...@@ -21,7 +24,10 @@ func (h *Hashlock) ExecDelLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transac ...@@ -21,7 +24,10 @@ func (h *Hashlock) ExecDelLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transac
} }
// ExecDelLocal_Hsend Action // ExecDelLocal_Hsend Action
func (h *Hashlock) ExecDelLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (h *Hashlock) ExecDelLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transaction, receipt types.ExecTypeGet, index int) (*types.LocalDBSet, error) {
if receipt.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
info := pty.Hashlockquery{Time: 0, Status: hashlockSent, Amount: 0, CreateTime: 0, CurrentTime: 0} info := pty.Hashlockquery{Time: 0, Status: hashlockSent, Amount: 0, CreateTime: 0, CurrentTime: 0}
kv, err := UpdateHashReciver(h.GetLocalDB(), common.Sha256(hsend.Secret), info) kv, err := UpdateHashReciver(h.GetLocalDB(), common.Sha256(hsend.Secret), info)
if err != nil { if err != nil {
...@@ -31,7 +37,10 @@ func (h *Hashlock) ExecDelLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transac ...@@ -31,7 +37,10 @@ func (h *Hashlock) ExecDelLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transac
} }
// ExecDelLocal_Hunlock Action // ExecDelLocal_Hunlock Action
func (h *Hashlock) ExecDelLocal_Hunlock(hunlock *pty.HashlockUnlock, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (h *Hashlock) ExecDelLocal_Hunlock(hunlock *pty.HashlockUnlock, tx *types.Transaction, receipt types.ExecTypeGet, index int) (*types.LocalDBSet, error) {
if receipt.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
info := pty.Hashlockquery{Time: 0, Status: hashlockUnlocked, Amount: 0, CreateTime: 0, CurrentTime: 0} info := pty.Hashlockquery{Time: 0, Status: hashlockUnlocked, Amount: 0, CreateTime: 0, CurrentTime: 0}
kv, err := UpdateHashReciver(h.GetLocalDB(), common.Sha256(hunlock.Secret), info) kv, err := UpdateHashReciver(h.GetLocalDB(), common.Sha256(hunlock.Secret), info)
if err != nil { if err != nil {
......
...@@ -11,7 +11,10 @@ import ( ...@@ -11,7 +11,10 @@ import (
) )
// ExecLocal_Hlock Action // ExecLocal_Hlock Action
func (h *Hashlock) ExecLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (h *Hashlock) ExecLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transaction, receipt types.ExecTypeGet, index int) (*types.LocalDBSet, error) {
if receipt.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
info := pty.Hashlockquery{Time: hlock.Time, Status: hashlockLocked, Amount: hlock.Amount, CreateTime: h.GetBlockTime(), CurrentTime: 0} info := pty.Hashlockquery{Time: hlock.Time, Status: hashlockLocked, Amount: hlock.Amount, CreateTime: h.GetBlockTime(), CurrentTime: 0}
clog.Error("ExecLocal", "info", info) clog.Error("ExecLocal", "info", info)
kv, err := UpdateHashReciver(h.GetLocalDB(), hlock.Hash, info) kv, err := UpdateHashReciver(h.GetLocalDB(), hlock.Hash, info)
...@@ -22,7 +25,10 @@ func (h *Hashlock) ExecLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transactio ...@@ -22,7 +25,10 @@ func (h *Hashlock) ExecLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transactio
} }
// ExecLocal_Hsend Action // ExecLocal_Hsend Action
func (h *Hashlock) ExecLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (h *Hashlock) ExecLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transaction, receipt types.ExecTypeGet, index int) (*types.LocalDBSet, error) {
if receipt.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
info := pty.Hashlockquery{Time: 0, Status: hashlockSent, Amount: 0, CreateTime: 0, CurrentTime: 0} info := pty.Hashlockquery{Time: 0, Status: hashlockSent, Amount: 0, CreateTime: 0, CurrentTime: 0}
clog.Error("ExecLocal", "info", info) clog.Error("ExecLocal", "info", info)
kv, err := UpdateHashReciver(h.GetLocalDB(), common.Sha256(hsend.Secret), info) kv, err := UpdateHashReciver(h.GetLocalDB(), common.Sha256(hsend.Secret), info)
...@@ -33,7 +39,10 @@ func (h *Hashlock) ExecLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transactio ...@@ -33,7 +39,10 @@ func (h *Hashlock) ExecLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transactio
} }
// ExecLocal_Hunlock Action // ExecLocal_Hunlock Action
func (h *Hashlock) ExecLocal_Hunlock(hunlock *pty.HashlockUnlock, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (h *Hashlock) ExecLocal_Hunlock(hunlock *pty.HashlockUnlock, tx *types.Transaction, receipt types.ExecTypeGet, index int) (*types.LocalDBSet, error) {
if receipt.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
info := pty.Hashlockquery{Time: 0, Status: hashlockUnlocked, Amount: 0, CreateTime: 0, CurrentTime: 0} info := pty.Hashlockquery{Time: 0, Status: hashlockUnlocked, Amount: 0, CreateTime: 0, CurrentTime: 0}
clog.Error("ExecLocal", "info", info) clog.Error("ExecLocal", "info", info)
kv, err := UpdateHashReciver(h.GetLocalDB(), common.Sha256(hunlock.Secret), info) kv, err := UpdateHashReciver(h.GetLocalDB(), common.Sha256(hunlock.Secret), info)
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package wallet package wallet
import ( import (
"encoding/hex"
"fmt" "fmt"
"sync" "sync"
"sync/atomic" "sync/atomic"
...@@ -611,17 +612,20 @@ func (policy *ticketPolicy) buyTicket(height int64) ([][]byte, int, error) { ...@@ -611,17 +612,20 @@ func (policy *ticketPolicy) buyTicket(height int64) ([][]byte, int, error) {
} }
count := 0 count := 0
var hashes [][]byte var hashes [][]byte
bizlog.Debug("ticketPolicy buyTicket begin")
for _, priv := range privs { for _, priv := range privs {
hash, n, err := policy.buyTicketOne(height, priv) hash, n, err := policy.buyTicketOne(height, priv)
if err != nil { if err != nil {
bizlog.Error("buyTicketOne", "err", err) bizlog.Error("ticketPolicy buyTicket buyTicketOne", "err", err)
continue continue
} }
count += n count += n
if hash != nil { if hash != nil {
hashes = append(hashes, hash) hashes = append(hashes, hash)
} }
bizlog.Debug("ticketPolicy buyTicket", "Address", address.PubKeyToAddress(priv.PubKey().Bytes()).String(), "txhash", hex.EncodeToString(hash), "n", n)
} }
bizlog.Debug("ticketPolicy buyTicket end")
return hashes, count, nil return hashes, count, nil
} }
...@@ -705,6 +709,7 @@ func (policy *ticketPolicy) buyMinerAddrTicket(height int64) ([][]byte, int, err ...@@ -705,6 +709,7 @@ func (policy *ticketPolicy) buyMinerAddrTicket(height int64) ([][]byte, int, err
} }
count := 0 count := 0
var hashes [][]byte var hashes [][]byte
bizlog.Debug("ticketPolicy buyMinerAddrTicket begin")
for _, priv := range privs { for _, priv := range privs {
hashlist, n, err := policy.buyMinerAddrTicketOne(height, priv) hashlist, n, err := policy.buyMinerAddrTicketOne(height, priv)
if err != nil { if err != nil {
...@@ -717,7 +722,9 @@ func (policy *ticketPolicy) buyMinerAddrTicket(height int64) ([][]byte, int, err ...@@ -717,7 +722,9 @@ func (policy *ticketPolicy) buyMinerAddrTicket(height int64) ([][]byte, int, err
if hashlist != nil { if hashlist != nil {
hashes = append(hashes, hashlist...) hashes = append(hashes, hashlist...)
} }
bizlog.Debug("ticketPolicy buyMinerAddrTicket", "Address", address.PubKeyToAddress(priv.PubKey().Bytes()).String(), "n", n)
} }
bizlog.Debug("ticketPolicy buyMinerAddrTicket end")
return hashes, count, nil return hashes, count, nil
} }
......
...@@ -88,13 +88,13 @@ func TestTrade_Exec_SellLimit(t *testing.T) { ...@@ -88,13 +88,13 @@ func TestTrade_Exec_SellLimit(t *testing.T) {
driver.SetStateDB(stateDB) driver.SetStateDB(stateDB)
sell := &pty.TradeSellTx{ sell := &pty.TradeSellTx{
Symbol, TokenSymbol: Symbol,
sellArgs.amount, AmountPerBoardlot: sellArgs.amount,
sellArgs.min, MinBoardlot: sellArgs.min,
sellArgs.price, PricePerBoardlot: sellArgs.price,
sellArgs.total, TotalBoardlot: sellArgs.total,
0, Fee: 0,
AssetExecToken, AssetExec: AssetExecToken,
} }
tx, _ := pty.CreateRawTradeSellTx(sell) tx, _ := pty.CreateRawTradeSellTx(sell)
tx, _ = signTx(tx, PrivKeyA) tx, _ = signTx(tx, PrivKeyA)
...@@ -125,9 +125,9 @@ func TestTrade_Exec_SellLimit(t *testing.T) { ...@@ -125,9 +125,9 @@ func TestTrade_Exec_SellLimit(t *testing.T) {
assert.Equal(t, string(Nodes[0]), sellOrder.Address) assert.Equal(t, string(Nodes[0]), sellOrder.Address)
buy := &pty.TradeBuyTx{ buy := &pty.TradeBuyTx{
sellOrder.SellID, SellID: sellOrder.SellID,
buyArgs.total, BoardlotCnt: buyArgs.total,
0, Fee: 0,
} }
tx, _ = pty.CreateRawTradeBuyTx(buy) tx, _ = pty.CreateRawTradeBuyTx(buy)
tx, _ = signTx(tx, PrivKeyB) tx, _ = signTx(tx, PrivKeyB)
...@@ -197,13 +197,13 @@ func TestTrade_Exec_BuyLimit(t *testing.T) { ...@@ -197,13 +197,13 @@ func TestTrade_Exec_BuyLimit(t *testing.T) {
driver.SetStateDB(stateDB) driver.SetStateDB(stateDB)
buy := &pty.TradeBuyLimitTx{ buy := &pty.TradeBuyLimitTx{
Symbol, TokenSymbol: Symbol,
buyArgs.amount, AmountPerBoardlot: buyArgs.amount,
buyArgs.min, MinBoardlot: buyArgs.min,
buyArgs.price, PricePerBoardlot: buyArgs.price,
buyArgs.total, TotalBoardlot: buyArgs.total,
0, Fee: 0,
AssetExecPara, AssetExec: AssetExecPara,
} }
tx, _ := pty.CreateRawTradeBuyLimitTx(buy) tx, _ := pty.CreateRawTradeBuyLimitTx(buy)
tx, _ = signTx(tx, PrivKeyB) tx, _ = signTx(tx, PrivKeyB)
...@@ -234,9 +234,9 @@ func TestTrade_Exec_BuyLimit(t *testing.T) { ...@@ -234,9 +234,9 @@ func TestTrade_Exec_BuyLimit(t *testing.T) {
assert.Equal(t, string(Nodes[1]), buyLimitOrder.Address) assert.Equal(t, string(Nodes[1]), buyLimitOrder.Address)
sell := &pty.TradeSellMarketTx{ sell := &pty.TradeSellMarketTx{
buyLimitOrder.BuyID, BuyID: buyLimitOrder.BuyID,
sellArgs.total, BoardlotCnt: sellArgs.total,
0, Fee: 0,
} }
tx, _ = pty.CreateRawTradeSellMarketTx(sell) tx, _ = pty.CreateRawTradeSellMarketTx(sell)
tx, _ = signTx(tx, PrivKeyA) tx, _ = signTx(tx, PrivKeyA)
......
...@@ -158,13 +158,13 @@ func genBuyMarketOrderKeyValue(kv []*types.KeyValue, receipt *pty.ReceiptBuyBase ...@@ -158,13 +158,13 @@ func genBuyMarketOrderKeyValue(kv []*types.KeyValue, receipt *pty.ReceiptBuyBase
keyID := receipt.TxHash keyID := receipt.TxHash
newkey := calcTokenBuyOrderKey(receipt.TokenSymbol, receipt.Owner, status, keyID, height) newkey := calcTokenBuyOrderKey(receipt.TokenSymbol, receipt.Owner, status, keyID, height)
kv = append(kv, &types.KeyValue{newkey, value}) kv = append(kv, &types.KeyValue{Key: newkey, Value: value})
newkey = calcOnesBuyOrderKeyStatus(receipt.TokenSymbol, receipt.Owner, status, keyID) newkey = calcOnesBuyOrderKeyStatus(receipt.TokenSymbol, receipt.Owner, status, keyID)
kv = append(kv, &types.KeyValue{newkey, value}) kv = append(kv, &types.KeyValue{Key: newkey, Value: value})
newkey = calcOnesBuyOrderKeyToken(receipt.TokenSymbol, receipt.Owner, status, keyID) newkey = calcOnesBuyOrderKeyToken(receipt.TokenSymbol, receipt.Owner, status, keyID)
kv = append(kv, &types.KeyValue{newkey, value}) kv = append(kv, &types.KeyValue{Key: newkey, Value: value})
priceBoardlot, err := strconv.ParseFloat(receipt.PricePerBoardlot, 64) priceBoardlot, err := strconv.ParseFloat(receipt.PricePerBoardlot, 64)
if err != nil { if err != nil {
...@@ -180,11 +180,11 @@ func genBuyMarketOrderKeyValue(kv []*types.KeyValue, receipt *pty.ReceiptBuyBase ...@@ -180,11 +180,11 @@ func genBuyMarketOrderKeyValue(kv []*types.KeyValue, receipt *pty.ReceiptBuyBase
newkey = calcTokensBuyOrderKeyStatus(receipt.TokenSymbol, status, newkey = calcTokensBuyOrderKeyStatus(receipt.TokenSymbol, status,
price, receipt.Owner, keyID) price, receipt.Owner, keyID)
kv = append(kv, &types.KeyValue{newkey, value}) kv = append(kv, &types.KeyValue{Key: newkey, Value: value})
st, ty := fromStatus(status) st, ty := fromStatus(status)
newkey = calcOnesOrderKey(receipt.Owner, st, ty, height, keyID) newkey = calcOnesOrderKey(receipt.Owner, st, ty, height, keyID)
kv = append(kv, &types.KeyValue{newkey, value}) kv = append(kv, &types.KeyValue{Key: newkey, Value: value})
return kv return kv
} }
...@@ -195,13 +195,13 @@ func genSellMarketOrderKeyValue(kv []*types.KeyValue, receipt *pty.ReceiptSellBa ...@@ -195,13 +195,13 @@ func genSellMarketOrderKeyValue(kv []*types.KeyValue, receipt *pty.ReceiptSellBa
keyID := receipt.TxHash keyID := receipt.TxHash
newkey := calcTokenSellOrderKey(receipt.TokenSymbol, receipt.Owner, status, keyID, height) newkey := calcTokenSellOrderKey(receipt.TokenSymbol, receipt.Owner, status, keyID, height)
kv = append(kv, &types.KeyValue{newkey, value}) kv = append(kv, &types.KeyValue{Key: newkey, Value: value})
newkey = calcOnesSellOrderKeyStatus(receipt.TokenSymbol, receipt.Owner, status, keyID) newkey = calcOnesSellOrderKeyStatus(receipt.TokenSymbol, receipt.Owner, status, keyID)
kv = append(kv, &types.KeyValue{newkey, value}) kv = append(kv, &types.KeyValue{Key: newkey, Value: value})
newkey = calcOnesSellOrderKeyToken(receipt.TokenSymbol, receipt.Owner, status, keyID) newkey = calcOnesSellOrderKeyToken(receipt.TokenSymbol, receipt.Owner, status, keyID)
kv = append(kv, &types.KeyValue{newkey, value}) kv = append(kv, &types.KeyValue{Key: newkey, Value: value})
priceBoardlot, err := strconv.ParseFloat(receipt.PricePerBoardlot, 64) priceBoardlot, err := strconv.ParseFloat(receipt.PricePerBoardlot, 64)
if err != nil { if err != nil {
...@@ -217,11 +217,11 @@ func genSellMarketOrderKeyValue(kv []*types.KeyValue, receipt *pty.ReceiptSellBa ...@@ -217,11 +217,11 @@ func genSellMarketOrderKeyValue(kv []*types.KeyValue, receipt *pty.ReceiptSellBa
newkey = calcTokensSellOrderKeyStatus(receipt.TokenSymbol, status, newkey = calcTokensSellOrderKeyStatus(receipt.TokenSymbol, status,
price, receipt.Owner, keyID) price, receipt.Owner, keyID)
kv = append(kv, &types.KeyValue{newkey, value}) kv = append(kv, &types.KeyValue{Key: newkey, Value: value})
st, ty := fromStatus(status) st, ty := fromStatus(status)
newkey = calcOnesOrderKey(receipt.Owner, st, ty, height, keyID) newkey = calcOnesOrderKey(receipt.Owner, st, ty, height, keyID)
kv = append(kv, &types.KeyValue{newkey, value}) kv = append(kv, &types.KeyValue{Key: newkey, Value: value})
return kv return kv
} }
...@@ -235,42 +235,42 @@ func calcPriceOfToken(priceBoardlot, AmountPerBoardlot int64) int64 { ...@@ -235,42 +235,42 @@ func calcPriceOfToken(priceBoardlot, AmountPerBoardlot int64) int64 {
func genBuyLimitOrderKeyValue(kv []*types.KeyValue, buyOrder *pty.BuyLimitOrder, status int32, value []byte) []*types.KeyValue { func genBuyLimitOrderKeyValue(kv []*types.KeyValue, buyOrder *pty.BuyLimitOrder, status int32, value []byte) []*types.KeyValue {
newkey := calcTokenBuyOrderKey(buyOrder.TokenSymbol, buyOrder.Address, status, buyOrder.BuyID, buyOrder.Height) newkey := calcTokenBuyOrderKey(buyOrder.TokenSymbol, buyOrder.Address, status, buyOrder.BuyID, buyOrder.Height)
kv = append(kv, &types.KeyValue{newkey, value}) kv = append(kv, &types.KeyValue{Key: newkey, Value: value})
newkey = calcOnesBuyOrderKeyStatus(buyOrder.TokenSymbol, buyOrder.Address, status, buyOrder.BuyID) newkey = calcOnesBuyOrderKeyStatus(buyOrder.TokenSymbol, buyOrder.Address, status, buyOrder.BuyID)
kv = append(kv, &types.KeyValue{newkey, value}) kv = append(kv, &types.KeyValue{Key: newkey, Value: value})
newkey = calcOnesBuyOrderKeyToken(buyOrder.TokenSymbol, buyOrder.Address, status, buyOrder.BuyID) newkey = calcOnesBuyOrderKeyToken(buyOrder.TokenSymbol, buyOrder.Address, status, buyOrder.BuyID)
kv = append(kv, &types.KeyValue{newkey, value}) kv = append(kv, &types.KeyValue{Key: newkey, Value: value})
newkey = calcTokensBuyOrderKeyStatus(buyOrder.TokenSymbol, status, newkey = calcTokensBuyOrderKeyStatus(buyOrder.TokenSymbol, status,
calcPriceOfToken(buyOrder.PricePerBoardlot, buyOrder.AmountPerBoardlot), buyOrder.Address, buyOrder.BuyID) calcPriceOfToken(buyOrder.PricePerBoardlot, buyOrder.AmountPerBoardlot), buyOrder.Address, buyOrder.BuyID)
kv = append(kv, &types.KeyValue{newkey, value}) kv = append(kv, &types.KeyValue{Key: newkey, Value: value})
st, ty := fromStatus(status) st, ty := fromStatus(status)
newkey = calcOnesOrderKey(buyOrder.Address, st, ty, buyOrder.Height, buyOrder.BuyID) newkey = calcOnesOrderKey(buyOrder.Address, st, ty, buyOrder.Height, buyOrder.BuyID)
kv = append(kv, &types.KeyValue{newkey, value}) kv = append(kv, &types.KeyValue{Key: newkey, Value: value})
return kv return kv
} }
func genSellOrderKeyValue(kv []*types.KeyValue, sellorder *pty.SellOrder, status int32, value []byte) []*types.KeyValue { func genSellOrderKeyValue(kv []*types.KeyValue, sellorder *pty.SellOrder, status int32, value []byte) []*types.KeyValue {
newkey := calcTokenSellOrderKey(sellorder.TokenSymbol, sellorder.Address, status, sellorder.SellID, sellorder.Height) newkey := calcTokenSellOrderKey(sellorder.TokenSymbol, sellorder.Address, status, sellorder.SellID, sellorder.Height)
kv = append(kv, &types.KeyValue{newkey, value}) kv = append(kv, &types.KeyValue{Key: newkey, Value: value})
newkey = calcOnesSellOrderKeyStatus(sellorder.TokenSymbol, sellorder.Address, status, sellorder.SellID) newkey = calcOnesSellOrderKeyStatus(sellorder.TokenSymbol, sellorder.Address, status, sellorder.SellID)
kv = append(kv, &types.KeyValue{newkey, value}) kv = append(kv, &types.KeyValue{Key: newkey, Value: value})
newkey = calcOnesSellOrderKeyToken(sellorder.TokenSymbol, sellorder.Address, status, sellorder.SellID) newkey = calcOnesSellOrderKeyToken(sellorder.TokenSymbol, sellorder.Address, status, sellorder.SellID)
kv = append(kv, &types.KeyValue{newkey, value}) kv = append(kv, &types.KeyValue{Key: newkey, Value: value})
newkey = calcTokensSellOrderKeyStatus(sellorder.TokenSymbol, status, newkey = calcTokensSellOrderKeyStatus(sellorder.TokenSymbol, status,
calcPriceOfToken(sellorder.PricePerBoardlot, sellorder.AmountPerBoardlot), sellorder.Address, sellorder.SellID) calcPriceOfToken(sellorder.PricePerBoardlot, sellorder.AmountPerBoardlot), sellorder.Address, sellorder.SellID)
kv = append(kv, &types.KeyValue{newkey, value}) kv = append(kv, &types.KeyValue{Key: newkey, Value: value})
st, ty := fromStatus(status) st, ty := fromStatus(status)
newkey = calcOnesOrderKey(sellorder.Address, st, ty, sellorder.Height, sellorder.SellID) newkey = calcOnesOrderKey(sellorder.Address, st, ty, sellorder.Height, sellorder.SellID)
kv = append(kv, &types.KeyValue{newkey, value}) kv = append(kv, &types.KeyValue{Key: newkey, Value: value})
return kv return kv
} }
...@@ -15,54 +15,54 @@ import ( ...@@ -15,54 +15,54 @@ import (
var ( var (
sellorderOnsale = pty.SellOrder{ sellorderOnsale = pty.SellOrder{
"Tokensymbol", TokenSymbol: "Tokensymbol",
"Address", Address: "Address",
20 * 1e8, // Amountperboardlot int64 `protobuf:"varint,3,opt,name=amountperboardlot" json:"amountperboardlot,omitempty"` AmountPerBoardlot: 20 * 1e8, // Amountperboardlot int64 `protobuf:"varint,3,opt,name=amountperboardlot" json:"amountperboardlot,omitempty"`
2, // Minboardlot int64 `protobuf:"varint,4,opt,name=minboardlot" json:"minboardlot,omitempty"` MinBoardlot: 2, // Minboardlot int64 `protobuf:"varint,4,opt,name=minboardlot" json:"minboardlot,omitempty"`
1 * 1e8, //Priceperboardlot int64 `protobuf:"varint,5,opt,name=priceperboardlot" json:"priceperboardlot,omitempty"` PricePerBoardlot: 1 * 1e8, //Priceperboardlot int64 `protobuf:"varint,5,opt,name=priceperboardlot" json:"priceperboardlot,omitempty"`
60, // Totalboardlot int64 `protobuf:"varint,6,opt,name=totalboardlot" json:"totalboardlot,omitempty"` TotalBoardlot: 60, // Totalboardlot int64 `protobuf:"varint,6,opt,name=totalboardlot" json:"totalboardlot,omitempty"`
2, // Soldboardlot int64 `protobuf:"varint,7,opt,name=soldboardlot" json:"soldboardlot,omitempty"` SoldBoardlot: 2, // Soldboardlot int64 `protobuf:"varint,7,opt,name=soldboardlot" json:"soldboardlot,omitempty"`
0, //Starttime int64 `protobuf:"varint,8,opt,name=starttime" json:"starttime,omitempty"` Starttime: 0, //Starttime int64 `protobuf:"varint,8,opt,name=starttime" json:"starttime,omitempty"`
0, //Stoptime int64 `protobuf:"varint,9,opt,name=stoptime" json:"stoptime,omitempty"` Stoptime: 0, //Stoptime int64 `protobuf:"varint,9,opt,name=stoptime" json:"stoptime,omitempty"`
false, //Crowdfund bool `protobuf:"varint,10,opt,name=crowdfund" json:"crowdfund,omitempty"` Crowdfund: false, //Crowdfund bool `protobuf:"varint,10,opt,name=crowdfund" json:"crowdfund,omitempty"`
"IAMSELLID", // Sellid string `protobuf:"bytes,11,opt,name=sellid" json:"sellid,omitempty"` SellID: "IAMSELLID", // Sellid string `protobuf:"bytes,11,opt,name=sellid" json:"sellid,omitempty"`
pty.TradeOrderStatusOnSale, //Status int32 `protobuf:"varint,12,opt,name=status" json:"status,omitempty"` Status: pty.TradeOrderStatusOnSale, //Status int32 `protobuf:"varint,12,opt,name=status" json:"status,omitempty"`
100, //Height int64 `protobuf:"varint,13,opt,name=height" json:"height,omitempty"` Height: 100, //Height int64 `protobuf:"varint,13,opt,name=height" json:"height,omitempty"`
"token", AssetExec: "token",
} }
sellorderSoldOut = pty.SellOrder{ sellorderSoldOut = pty.SellOrder{
"Tokensymbol", TokenSymbol: "Tokensymbol",
"Address", Address: "Address",
20 * 1e8, // Amountperboardlot int64 `protobuf:"varint,3,opt,name=amountperboardlot" json:"amountperboardlot,omitempty"` AmountPerBoardlot: 20 * 1e8, // Amountperboardlot int64 `protobuf:"varint,3,opt,name=amountperboardlot" json:"amountperboardlot,omitempty"`
2, // Minboardlot int64 `protobuf:"varint,4,opt,name=minboardlot" json:"minboardlot,omitempty"` MinBoardlot: 2, // Minboardlot int64 `protobuf:"varint,4,opt,name=minboardlot" json:"minboardlot,omitempty"`
1 * 1e8, //Priceperboardlot int64 `protobuf:"varint,5,opt,name=priceperboardlot" json:"priceperboardlot,omitempty"` PricePerBoardlot: 1 * 1e8, //Priceperboardlot int64 `protobuf:"varint,5,opt,name=priceperboardlot" json:"priceperboardlot,omitempty"`
60, // Totalboardlot int64 `protobuf:"varint,6,opt,name=totalboardlot" json:"totalboardlot,omitempty"` TotalBoardlot: 60, // Totalboardlot int64 `protobuf:"varint,6,opt,name=totalboardlot" json:"totalboardlot,omitempty"`
2, // Soldboardlot int64 `protobuf:"varint,7,opt,name=soldboardlot" json:"soldboardlot,omitempty"` SoldBoardlot: 2, // Soldboardlot int64 `protobuf:"varint,7,opt,name=soldboardlot" json:"soldboardlot,omitempty"`
0, //Starttime int64 `protobuf:"varint,8,opt,name=starttime" json:"starttime,omitempty"` Starttime: 0, //Starttime int64 `protobuf:"varint,8,opt,name=starttime" json:"starttime,omitempty"`
0, //Stoptime int64 `protobuf:"varint,9,opt,name=stoptime" json:"stoptime,omitempty"` Stoptime: 0, //Stoptime int64 `protobuf:"varint,9,opt,name=stoptime" json:"stoptime,omitempty"`
false, //Crowdfund bool `protobuf:"varint,10,opt,name=crowdfund" json:"crowdfund,omitempty"` Crowdfund: false, //Crowdfund bool `protobuf:"varint,10,opt,name=crowdfund" json:"crowdfund,omitempty"`
"IAMSELLID", // Sellid string `protobuf:"bytes,11,opt,name=sellid" json:"sellid,omitempty"` SellID: "IAMSELLID", // Sellid string `protobuf:"bytes,11,opt,name=sellid" json:"sellid,omitempty"`
pty.TradeOrderStatusSoldOut, //Status int32 `protobuf:"varint,12,opt,name=status" json:"status,omitempty"` Status: pty.TradeOrderStatusSoldOut, //Status int32 `protobuf:"varint,12,opt,name=status" json:"status,omitempty"`
100, //Height int64 `protobuf:"varint,13,opt,name=height" json:"height,omitempty"` Height: 100, //Height int64 `protobuf:"varint,13,opt,name=height" json:"height,omitempty"`
"token", AssetExec: "token",
} }
sellorderRevoked = pty.SellOrder{ sellorderRevoked = pty.SellOrder{
"Tokensymbol", TokenSymbol: "Tokensymbol",
"Address", Address: "Address",
20 * 1e8, // Amountperboardlot int64 `protobuf:"varint,3,opt,name=amountperboardlot" json:"amountperboardlot,omitempty"` AmountPerBoardlot: 20 * 1e8, // Amountperboardlot int64 `protobuf:"varint,3,opt,name=amountperboardlot" json:"amountperboardlot,omitempty"`
2, // Minboardlot int64 `protobuf:"varint,4,opt,name=minboardlot" json:"minboardlot,omitempty"` MinBoardlot: 2, // Minboardlot int64 `protobuf:"varint,4,opt,name=minboardlot" json:"minboardlot,omitempty"`
1 * 1e8, //Priceperboardlot int64 `protobuf:"varint,5,opt,name=priceperboardlot" json:"priceperboardlot,omitempty"` PricePerBoardlot: 1 * 1e8, //Priceperboardlot int64 `protobuf:"varint,5,opt,name=priceperboardlot" json:"priceperboardlot,omitempty"`
60, // Totalboardlot int64 `protobuf:"varint,6,opt,name=totalboardlot" json:"totalboardlot,omitempty"` TotalBoardlot: 60, // Totalboardlot int64 `protobuf:"varint,6,opt,name=totalboardlot" json:"totalboardlot,omitempty"`
2, // Soldboardlot int64 `protobuf:"varint,7,opt,name=soldboardlot" json:"soldboardlot,omitempty"` SoldBoardlot: 2, // Soldboardlot int64 `protobuf:"varint,7,opt,name=soldboardlot" json:"soldboardlot,omitempty"`
0, //Starttime int64 `protobuf:"varint,8,opt,name=starttime" json:"starttime,omitempty"` Starttime: 0, //Starttime int64 `protobuf:"varint,8,opt,name=starttime" json:"starttime,omitempty"`
0, //Stoptime int64 `protobuf:"varint,9,opt,name=stoptime" json:"stoptime,omitempty"` Stoptime: 0, //Stoptime int64 `protobuf:"varint,9,opt,name=stoptime" json:"stoptime,omitempty"`
false, //Crowdfund bool `protobuf:"varint,10,opt,name=crowdfund" json:"crowdfund,omitempty"` Crowdfund: false, //Crowdfund bool `protobuf:"varint,10,opt,name=crowdfund" json:"crowdfund,omitempty"`
"IAMSELLID", // Sellid string `protobuf:"bytes,11,opt,name=sellid" json:"sellid,omitempty"` SellID: "IAMSELLID", // Sellid string `protobuf:"bytes,11,opt,name=sellid" json:"sellid,omitempty"`
pty.TradeOrderStatusRevoked, //Status int32 `protobuf:"varint,12,opt,name=status" json:"status,omitempty"` Status: pty.TradeOrderStatusRevoked, //Status int32 `protobuf:"varint,12,opt,name=status" json:"status,omitempty"`
100, //Height int64 `protobuf:"varint,13,opt,name=height" json:"height,omitempty"` Height: 100, //Height int64 `protobuf:"varint,13,opt,name=height" json:"height,omitempty"`
"token", AssetExec: "token",
} }
) )
......
This diff is collapsed.
...@@ -35,7 +35,7 @@ func (cc *channelClient) CreateRawTradeBuyTx(ctx context.Context, in *ptypes.Tra ...@@ -35,7 +35,7 @@ func (cc *channelClient) CreateRawTradeBuyTx(ctx context.Context, in *ptypes.Tra
} }
buy := &ptypes.Trade{ buy := &ptypes.Trade{
Ty: ptypes.TradeBuyMarket, Ty: ptypes.TradeBuyMarket,
Value: &ptypes.Trade_BuyMarket{in}, Value: &ptypes.Trade_BuyMarket{BuyMarket: in},
} }
tx, err := types.CreateFormatTx(types.ExecName(ptypes.TradeX), types.Encode(buy)) tx, err := types.CreateFormatTx(types.ExecName(ptypes.TradeX), types.Encode(buy))
if err != nil { if err != nil {
...@@ -52,7 +52,7 @@ func (cc *channelClient) CreateRawTradeRevokeTx(ctx context.Context, in *ptypes. ...@@ -52,7 +52,7 @@ func (cc *channelClient) CreateRawTradeRevokeTx(ctx context.Context, in *ptypes.
} }
buy := &ptypes.Trade{ buy := &ptypes.Trade{
Ty: ptypes.TradeRevokeSell, Ty: ptypes.TradeRevokeSell,
Value: &ptypes.Trade_RevokeSell{in}, Value: &ptypes.Trade_RevokeSell{RevokeSell: in},
} }
tx, err := types.CreateFormatTx(types.ExecName(ptypes.TradeX), types.Encode(buy)) tx, err := types.CreateFormatTx(types.ExecName(ptypes.TradeX), types.Encode(buy))
if err != nil { if err != nil {
...@@ -69,7 +69,7 @@ func (cc *channelClient) CreateRawTradeBuyLimitTx(ctx context.Context, in *ptype ...@@ -69,7 +69,7 @@ func (cc *channelClient) CreateRawTradeBuyLimitTx(ctx context.Context, in *ptype
} }
buy := &ptypes.Trade{ buy := &ptypes.Trade{
Ty: ptypes.TradeBuyLimit, Ty: ptypes.TradeBuyLimit,
Value: &ptypes.Trade_BuyLimit{in}, Value: &ptypes.Trade_BuyLimit{BuyLimit: in},
} }
tx, err := types.CreateFormatTx(types.ExecName(ptypes.TradeX), types.Encode(buy)) tx, err := types.CreateFormatTx(types.ExecName(ptypes.TradeX), types.Encode(buy))
if err != nil { if err != nil {
...@@ -86,7 +86,7 @@ func (cc *channelClient) CreateRawTradeSellMarketTx(ctx context.Context, in *pty ...@@ -86,7 +86,7 @@ func (cc *channelClient) CreateRawTradeSellMarketTx(ctx context.Context, in *pty
} }
buy := &ptypes.Trade{ buy := &ptypes.Trade{
Ty: ptypes.TradeSellMarket, Ty: ptypes.TradeSellMarket,
Value: &ptypes.Trade_SellMarket{in}, Value: &ptypes.Trade_SellMarket{SellMarket: in},
} }
tx, err := types.CreateFormatTx(types.ExecName(ptypes.TradeX), types.Encode(buy)) tx, err := types.CreateFormatTx(types.ExecName(ptypes.TradeX), types.Encode(buy))
if err != nil { if err != nil {
...@@ -103,7 +103,7 @@ func (cc *channelClient) CreateRawTradeRevokeBuyTx(ctx context.Context, in *ptyp ...@@ -103,7 +103,7 @@ func (cc *channelClient) CreateRawTradeRevokeBuyTx(ctx context.Context, in *ptyp
} }
buy := &ptypes.Trade{ buy := &ptypes.Trade{
Ty: ptypes.TradeRevokeBuy, Ty: ptypes.TradeRevokeBuy,
Value: &ptypes.Trade_RevokeBuy{in}, Value: &ptypes.Trade_RevokeBuy{RevokeBuy: in},
} }
tx, err := types.CreateFormatTx(types.ExecName(ptypes.TradeX), types.Encode(buy)) tx, err := types.CreateFormatTx(types.ExecName(ptypes.TradeX), types.Encode(buy))
if err != nil { if err != nil {
......
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