Commit 526392a7 authored by vipwzw's avatar vipwzw

update chain33 && del query cli

parent fe6bc6ff
...@@ -10,6 +10,7 @@ import ( ...@@ -10,6 +10,7 @@ import (
"github.com/33cn/chain33/common" "github.com/33cn/chain33/common"
jsonrpc "github.com/33cn/chain33/rpc/jsonclient" jsonrpc "github.com/33cn/chain33/rpc/jsonclient"
rpctypes "github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
gt "github.com/33cn/plugin/plugin/dapp/blackwhite/types" gt "github.com/33cn/plugin/plugin/dapp/blackwhite/types"
"github.com/spf13/cobra" "github.com/spf13/cobra"
...@@ -257,7 +258,7 @@ func showBlackwhiteInfo(cmd *cobra.Command, args []string) { ...@@ -257,7 +258,7 @@ func showBlackwhiteInfo(cmd *cobra.Command, args []string) {
loopSeq, _ := cmd.Flags().GetUint32("loopSeq") loopSeq, _ := cmd.Flags().GetUint32("loopSeq")
var params types.Query4Cli var params rpctypes.Query4Jrpc
var rep interface{} var rep interface{}
...@@ -267,7 +268,7 @@ func showBlackwhiteInfo(cmd *cobra.Command, args []string) { ...@@ -267,7 +268,7 @@ func showBlackwhiteInfo(cmd *cobra.Command, args []string) {
GameID: gameID, GameID: gameID,
} }
params.FuncName = gt.GetBlackwhiteRoundInfo params.FuncName = gt.GetBlackwhiteRoundInfo
params.Payload = req params.Payload = types.MustPBToJSON(&req)
rep = &gt.ReplyBlackwhiteRoundInfo{} rep = &gt.ReplyBlackwhiteRoundInfo{}
} else if 1 == typ { } else if 1 == typ {
req := gt.ReqBlackwhiteRoundList{ req := gt.ReqBlackwhiteRoundList{
...@@ -278,7 +279,7 @@ func showBlackwhiteInfo(cmd *cobra.Command, args []string) { ...@@ -278,7 +279,7 @@ func showBlackwhiteInfo(cmd *cobra.Command, args []string) {
Index: index, Index: index,
} }
params.FuncName = gt.GetBlackwhiteByStatusAndAddr params.FuncName = gt.GetBlackwhiteByStatusAndAddr
params.Payload = req params.Payload = types.MustPBToJSON(&req)
rep = &gt.ReplyBlackwhiteRoundList{} rep = &gt.ReplyBlackwhiteRoundList{}
} else if 2 == typ { } else if 2 == typ {
req := gt.ReqLoopResult{ req := gt.ReqLoopResult{
...@@ -286,7 +287,7 @@ func showBlackwhiteInfo(cmd *cobra.Command, args []string) { ...@@ -286,7 +287,7 @@ func showBlackwhiteInfo(cmd *cobra.Command, args []string) {
LoopSeq: int32(loopSeq), LoopSeq: int32(loopSeq),
} }
params.FuncName = gt.GetBlackwhiteloopResult params.FuncName = gt.GetBlackwhiteloopResult
params.Payload = req params.Payload = types.MustPBToJSON(&req)
rep = &gt.ReplyLoopResults{} rep = &gt.ReplyLoopResults{}
} }
......
...@@ -10,6 +10,7 @@ import ( ...@@ -10,6 +10,7 @@ import (
commonlog "github.com/33cn/chain33/common/log" commonlog "github.com/33cn/chain33/common/log"
"github.com/33cn/chain33/rpc/jsonclient" "github.com/33cn/chain33/rpc/jsonclient"
rpctypes "github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
"github.com/33cn/chain33/util/testnode" "github.com/33cn/chain33/util/testnode"
pty "github.com/33cn/plugin/plugin/dapp/blackwhite/types" pty "github.com/33cn/plugin/plugin/dapp/blackwhite/types"
...@@ -83,7 +84,7 @@ func testTimeoutDoneTxCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { ...@@ -83,7 +84,7 @@ func testTimeoutDoneTxCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
func testRoundInfoCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { func testRoundInfoCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{} var rep interface{}
var params types.Query4Cli var params rpctypes.Query4Jrpc
req := &pty.ReqBlackwhiteRoundInfo{} req := &pty.ReqBlackwhiteRoundInfo{}
params.FuncName = pty.GetBlackwhiteRoundInfo params.FuncName = pty.GetBlackwhiteRoundInfo
params.Payload = req params.Payload = req
...@@ -93,10 +94,10 @@ func testRoundInfoCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { ...@@ -93,10 +94,10 @@ func testRoundInfoCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
func testRoundListCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { func testRoundListCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{} var rep interface{}
var params types.Query4Cli var params rpctypes.Query4Jrpc
req := &pty.ReqBlackwhiteRoundList{} req := &pty.ReqBlackwhiteRoundList{}
params.FuncName = pty.GetBlackwhiteByStatusAndAddr params.FuncName = pty.GetBlackwhiteByStatusAndAddr
params.Payload = req params.Payload = types.MustPBToJSON(req)
rep = &pty.ReplyBlackwhiteRoundList{} rep = &pty.ReplyBlackwhiteRoundList{}
return jrpc.Call("Chain33.Query", params, rep) return jrpc.Call("Chain33.Query", params, rep)
...@@ -104,10 +105,10 @@ func testRoundListCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { ...@@ -104,10 +105,10 @@ func testRoundListCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
func testLoopResultCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { func testLoopResultCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{} var rep interface{}
var params types.Query4Cli var params rpctypes.Query4Jrpc
req := &pty.ReqLoopResult{} req := &pty.ReqLoopResult{}
params.FuncName = pty.GetBlackwhiteloopResult params.FuncName = pty.GetBlackwhiteloopResult
params.Payload = req params.Payload = types.MustPBToJSON(req)
rep = &pty.ReplyLoopResults{} rep = &pty.ReplyLoopResults{}
return jrpc.Call("Chain33.Query", params, rep) return jrpc.Call("Chain33.Query", params, rep)
......
...@@ -416,7 +416,7 @@ func estimateContract(cmd *cobra.Command, args []string) { ...@@ -416,7 +416,7 @@ func estimateContract(cmd *cobra.Command, args []string) {
var estGasReq = evmtypes.EstimateEVMGasReq{To: toAddr, Code: bCode, Caller: caller, Amount: amountInt64} var estGasReq = evmtypes.EstimateEVMGasReq{To: toAddr, Code: bCode, Caller: caller, Amount: amountInt64}
var estGasResp evmtypes.EstimateEVMGasResp var estGasResp evmtypes.EstimateEVMGasResp
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr") rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
query := sendQuery(rpcLaddr, "EstimateGas", estGasReq, &estGasResp) query := sendQuery(rpcLaddr, "EstimateGas", &estGasReq, &estGasResp)
if query { if query {
fmt.Fprintf(os.Stdout, "gas cost estimate %v\n", estGasResp.Gas) fmt.Fprintf(os.Stdout, "gas cost estimate %v\n", estGasResp.Gas)
...@@ -481,7 +481,7 @@ func checkContractAddr(cmd *cobra.Command, args []string) { ...@@ -481,7 +481,7 @@ func checkContractAddr(cmd *cobra.Command, args []string) {
var checkAddrReq = evmtypes.CheckEVMAddrReq{Addr: toAddr} var checkAddrReq = evmtypes.CheckEVMAddrReq{Addr: toAddr}
var checkAddrResp evmtypes.CheckEVMAddrResp var checkAddrResp evmtypes.CheckEVMAddrResp
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr") rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
query := sendQuery(rpcLaddr, "CheckAddrExists", checkAddrReq, &checkAddrResp) query := sendQuery(rpcLaddr, "CheckAddrExists", &checkAddrReq, &checkAddrResp)
if query && checkAddrResp.Contract { if query && checkAddrResp.Contract {
proto.MarshalText(os.Stdout, &checkAddrResp) proto.MarshalText(os.Stdout, &checkAddrResp)
...@@ -541,7 +541,7 @@ func evmDebugRPC(cmd *cobra.Command, flag int32) { ...@@ -541,7 +541,7 @@ func evmDebugRPC(cmd *cobra.Command, flag int32) {
var debugReq = evmtypes.EvmDebugReq{Optype: flag} var debugReq = evmtypes.EvmDebugReq{Optype: flag}
var debugResp evmtypes.EvmDebugResp var debugResp evmtypes.EvmDebugResp
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr") rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
query := sendQuery(rpcLaddr, "EvmDebug", debugReq, &debugResp) query := sendQuery(rpcLaddr, "EvmDebug", &debugReq, &debugResp)
if query { if query {
proto.MarshalText(os.Stdout, &debugResp) proto.MarshalText(os.Stdout, &debugResp)
...@@ -646,11 +646,11 @@ func evmWithdraw(cmd *cobra.Command, args []string) { ...@@ -646,11 +646,11 @@ func evmWithdraw(cmd *cobra.Command, args []string) {
ctx.RunWithoutMarshal() ctx.RunWithoutMarshal()
} }
func sendQuery(rpcAddr, funcName string, request interface{}, result proto.Message) bool { func sendQuery(rpcAddr, funcName string, request types.Message, result proto.Message) bool {
params := types.Query4Cli{ params := rpctypes.Query4Jrpc{
Execer: "evm", Execer: "evm",
FuncName: funcName, FuncName: funcName,
Payload: request, Payload: types.MustPBToJSON(request),
} }
jsonrpc, err := jsonclient.NewJSONClient(rpcAddr) jsonrpc, err := jsonclient.NewJSONClient(rpcAddr)
......
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
"strconv" "strconv"
jsonrpc "github.com/33cn/chain33/rpc/jsonclient" jsonrpc "github.com/33cn/chain33/rpc/jsonclient"
rpctypes "github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
pkt "github.com/33cn/plugin/plugin/dapp/pokerbull/types" pkt "github.com/33cn/plugin/plugin/dapp/pokerbull/types"
"github.com/spf13/cobra" "github.com/spf13/cobra"
...@@ -166,7 +167,7 @@ func pokerbullQuery(cmd *cobra.Command, args []string) { ...@@ -166,7 +167,7 @@ func pokerbullQuery(cmd *cobra.Command, args []string) {
index, _ := strconv.ParseInt(indexstr, 10, 64) index, _ := strconv.ParseInt(indexstr, 10, 64)
gameIDs, _ := cmd.Flags().GetString("gameIDs") gameIDs, _ := cmd.Flags().GetString("gameIDs")
var params types.Query4Cli var params rpctypes.Query4Jrpc
params.Execer = pkt.PokerBullX params.Execer = pkt.PokerBullX
req := &pkt.QueryPBGameInfo{ req := &pkt.QueryPBGameInfo{
GameId: gameID, GameId: gameID,
...@@ -174,7 +175,7 @@ func pokerbullQuery(cmd *cobra.Command, args []string) { ...@@ -174,7 +175,7 @@ func pokerbullQuery(cmd *cobra.Command, args []string) {
Status: int32(status), Status: int32(status),
Index: index, Index: index,
} }
params.Payload = req params.Payload = types.MustPBToJSON(req)
if gameID != "" { if gameID != "" {
params.FuncName = pkt.FuncNameQueryGameByID params.FuncName = pkt.FuncNameQueryGameByID
var res pkt.ReplyPBGame var res pkt.ReplyPBGame
...@@ -196,7 +197,7 @@ func pokerbullQuery(cmd *cobra.Command, args []string) { ...@@ -196,7 +197,7 @@ func pokerbullQuery(cmd *cobra.Command, args []string) {
gameIDsS = append(gameIDsS, gameIDs) gameIDsS = append(gameIDsS, gameIDs)
gameIDsS = append(gameIDsS, gameIDs) gameIDsS = append(gameIDsS, gameIDs)
req := &pkt.QueryPBGameInfos{GameIds: gameIDsS} req := &pkt.QueryPBGameInfos{GameIds: gameIDsS}
params.Payload = req params.Payload = types.MustPBToJSON(req)
var res pkt.ReplyPBGameList var res pkt.ReplyPBGameList
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.Run() ctx.Run()
......
...@@ -75,7 +75,7 @@ func testQuitRawTxCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { ...@@ -75,7 +75,7 @@ func testQuitRawTxCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
func testQueryGameByID(t *testing.T, jrpc *jsonclient.JSONClient) error { func testQueryGameByID(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{} var rep interface{}
var params types.Query4Cli var params rpctypes.Query4Jrpc
req := &pty.QueryPBGameInfo{} req := &pty.QueryPBGameInfo{}
params.Execer = "pokerbull" params.Execer = "pokerbull"
params.FuncName = "QueryGameByID" params.FuncName = "QueryGameByID"
...@@ -86,7 +86,7 @@ func testQueryGameByID(t *testing.T, jrpc *jsonclient.JSONClient) error { ...@@ -86,7 +86,7 @@ func testQueryGameByID(t *testing.T, jrpc *jsonclient.JSONClient) error {
func testQueryGameByAddr(t *testing.T, jrpc *jsonclient.JSONClient) error { func testQueryGameByAddr(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{} var rep interface{}
var params types.Query4Cli var params rpctypes.Query4Jrpc
req := &pty.QueryPBGameInfo{} req := &pty.QueryPBGameInfo{}
params.Execer = "pokerbull" params.Execer = "pokerbull"
params.FuncName = "QueryGameByAddr" params.FuncName = "QueryGameByAddr"
......
...@@ -364,10 +364,10 @@ func showAmountOfUTXO(cmd *cobra.Command, args []string) { ...@@ -364,10 +364,10 @@ func showAmountOfUTXO(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr") rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
reqPrivacyToken := pty.ReqPrivacyToken{Token: types.BTY} reqPrivacyToken := pty.ReqPrivacyToken{Token: types.BTY}
var params types.Query4Cli var params rpctypes.Query4Jrpc
params.Execer = pty.PrivacyX params.Execer = pty.PrivacyX
params.FuncName = "ShowAmountsOfUTXO" params.FuncName = "ShowAmountsOfUTXO"
params.Payload = reqPrivacyToken params.Payload = types.MustPBToJSON(&reqPrivacyToken)
var res pty.ReplyPrivacyAmounts var res pty.ReplyPrivacyAmounts
ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res) ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
...@@ -407,10 +407,10 @@ func showUTXOs4SpecifiedAmount(cmd *cobra.Command, args []string) { ...@@ -407,10 +407,10 @@ func showUTXOs4SpecifiedAmount(cmd *cobra.Command, args []string) {
Token: types.BTY, Token: types.BTY,
Amount: amountInt64, Amount: amountInt64,
} }
var params types.Query4Cli var params rpctypes.Query4Jrpc
params.Execer = pty.PrivacyX params.Execer = pty.PrivacyX
params.FuncName = "ShowUTXOs4SpecifiedAmount" params.FuncName = "ShowUTXOs4SpecifiedAmount"
params.Payload = reqPrivacyToken params.Payload = types.MustPBToJSON(&reqPrivacyToken)
var res pty.ReplyUTXOsOfAmount var res pty.ReplyUTXOsOfAmount
ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res) ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
......
...@@ -145,7 +145,7 @@ func testPrivacy2Public(t *testing.T, jrpc *jsonclient.JSONClient) error { ...@@ -145,7 +145,7 @@ func testPrivacy2Public(t *testing.T, jrpc *jsonclient.JSONClient) error {
func testShowAmountsOfUTXO(t *testing.T, jrpc *jsonclient.JSONClient) error { func testShowAmountsOfUTXO(t *testing.T, jrpc *jsonclient.JSONClient) error {
reqPrivacyToken := pty.ReqPrivacyToken{Token: types.BTY} reqPrivacyToken := pty.ReqPrivacyToken{Token: types.BTY}
var params types.Query4Cli var params rpctypes.Query4Jrpc
params.Execer = pty.PrivacyX params.Execer = pty.PrivacyX
params.FuncName = "ShowAmountsOfUTXO" params.FuncName = "ShowAmountsOfUTXO"
params.Payload = reqPrivacyToken params.Payload = reqPrivacyToken
...@@ -160,7 +160,7 @@ func testShowUTXOs4SpecifiedAmount(t *testing.T, jrpc *jsonclient.JSONClient) er ...@@ -160,7 +160,7 @@ func testShowUTXOs4SpecifiedAmount(t *testing.T, jrpc *jsonclient.JSONClient) er
Token: types.BTY, Token: types.BTY,
Amount: 123456, Amount: 123456,
} }
var params types.Query4Cli var params rpctypes.Query4Jrpc
params.Execer = pty.PrivacyX params.Execer = pty.PrivacyX
params.FuncName = "ShowUTXOs4SpecifiedAmount" params.FuncName = "ShowUTXOs4SpecifiedAmount"
params.Payload = reqPrivacyToken params.Payload = reqPrivacyToken
......
...@@ -12,6 +12,7 @@ import ( ...@@ -12,6 +12,7 @@ import (
"strings" "strings"
"github.com/33cn/chain33/rpc/jsonclient" "github.com/33cn/chain33/rpc/jsonclient"
rpctypes "github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
ty "github.com/33cn/plugin/plugin/dapp/relay/types" ty "github.com/33cn/plugin/plugin/dapp/relay/types"
"github.com/spf13/cobra" "github.com/spf13/cobra"
...@@ -75,10 +76,10 @@ func showBtcHeadHeightList(cmd *cobra.Command, args []string) { ...@@ -75,10 +76,10 @@ func showBtcHeadHeightList(cmd *cobra.Command, args []string) {
reqList.Counts = count reqList.Counts = count
reqList.Direction = direct reqList.Direction = direct
params := types.Query4Cli{ params := rpctypes.Query4Jrpc{
Execer: "relay", Execer: "relay",
FuncName: "GetBTCHeaderList", FuncName: "GetBTCHeaderList",
Payload: reqList, Payload: types.MustPBToJSON(&reqList),
} }
rpc, err := jsonclient.NewJSONClient(rpcLaddr) rpc, err := jsonclient.NewJSONClient(rpcLaddr)
if err != nil { if err != nil {
...@@ -119,10 +120,10 @@ func showBtcHeadCurHeight(cmd *cobra.Command, args []string) { ...@@ -119,10 +120,10 @@ func showBtcHeadCurHeight(cmd *cobra.Command, args []string) {
var reqList ty.ReqRelayQryBTCHeadHeight var reqList ty.ReqRelayQryBTCHeadHeight
reqList.BaseHeight = base reqList.BaseHeight = base
params := types.Query4Cli{ params := rpctypes.Query4Jrpc{
Execer: "relay", Execer: "relay",
FuncName: "GetBTCHeaderCurHeight", FuncName: "GetBTCHeaderCurHeight",
Payload: reqList, Payload: types.MustPBToJSON(&reqList),
} }
rpc, err := jsonclient.NewJSONClient(rpcLaddr) rpc, err := jsonclient.NewJSONClient(rpcLaddr)
if err != nil { if err != nil {
...@@ -170,10 +171,10 @@ func showOnesRelayOrders(cmd *cobra.Command, args []string) { ...@@ -170,10 +171,10 @@ func showOnesRelayOrders(cmd *cobra.Command, args []string) {
if 0 != len(coins) { if 0 != len(coins) {
reqAddrCoins.Coins = append(reqAddrCoins.Coins, coins...) reqAddrCoins.Coins = append(reqAddrCoins.Coins, coins...)
} }
params := types.Query4Cli{ params := rpctypes.Query4Jrpc{
Execer: "relay", Execer: "relay",
FuncName: "GetSellRelayOrder", FuncName: "GetSellRelayOrder",
Payload: reqAddrCoins, Payload: types.MustPBToJSON(&reqAddrCoins),
} }
rpc, err := jsonclient.NewJSONClient(rpcLaddr) rpc, err := jsonclient.NewJSONClient(rpcLaddr)
if err != nil { if err != nil {
...@@ -220,10 +221,10 @@ func showRelayAcceptOrders(cmd *cobra.Command, args []string) { ...@@ -220,10 +221,10 @@ func showRelayAcceptOrders(cmd *cobra.Command, args []string) {
if 0 != len(coins) { if 0 != len(coins) {
reqAddrCoins.Coins = append(reqAddrCoins.Coins, coins...) reqAddrCoins.Coins = append(reqAddrCoins.Coins, coins...)
} }
params := types.Query4Cli{ params := rpctypes.Query4Jrpc{
Execer: "relay", Execer: "relay",
FuncName: "GetBuyRelayOrder", FuncName: "GetBuyRelayOrder",
Payload: reqAddrCoins, Payload: types.MustPBToJSON(&reqAddrCoins),
} }
rpc, err := jsonclient.NewJSONClient(rpcLaddr) rpc, err := jsonclient.NewJSONClient(rpcLaddr)
if err != nil { if err != nil {
...@@ -275,10 +276,10 @@ func showCoinRelayOrders(cmd *cobra.Command, args []string) { ...@@ -275,10 +276,10 @@ func showCoinRelayOrders(cmd *cobra.Command, args []string) {
if 0 != len(coins) { if 0 != len(coins) {
reqAddrCoins.Coins = append(reqAddrCoins.Coins, coins...) reqAddrCoins.Coins = append(reqAddrCoins.Coins, coins...)
} }
params := types.Query4Cli{ params := rpctypes.Query4Jrpc{
Execer: "relay", Execer: "relay",
FuncName: "GetRelayOrderByStatus", FuncName: "GetRelayOrderByStatus",
Payload: reqAddrCoins, Payload: types.MustPBToJSON(&reqAddrCoins),
} }
rpc, err := jsonclient.NewJSONClient(rpcLaddr) rpc, err := jsonclient.NewJSONClient(rpcLaddr)
if err != nil { if err != nil {
......
...@@ -64,7 +64,7 @@ func TestJRPCChannel(t *testing.T) { ...@@ -64,7 +64,7 @@ func TestJRPCChannel(t *testing.T) {
func testShowOnesCreateRelayOrdersCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { func testShowOnesCreateRelayOrdersCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{} var rep interface{}
var params types.Query4Cli var params rpctypes.Query4Jrpc
req := &pty.ReqRelayAddrCoins{} req := &pty.ReqRelayAddrCoins{}
params.Execer = "relay" params.Execer = "relay"
params.FuncName = "GetSellRelayOrder" params.FuncName = "GetSellRelayOrder"
...@@ -75,7 +75,7 @@ func testShowOnesCreateRelayOrdersCmd(t *testing.T, jrpc *jsonclient.JSONClient) ...@@ -75,7 +75,7 @@ func testShowOnesCreateRelayOrdersCmd(t *testing.T, jrpc *jsonclient.JSONClient)
func testShowOnesAcceptRelayOrdersCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { func testShowOnesAcceptRelayOrdersCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{} var rep interface{}
var params types.Query4Cli var params rpctypes.Query4Jrpc
req := &pty.ReqRelayAddrCoins{} req := &pty.ReqRelayAddrCoins{}
params.Execer = "relay" params.Execer = "relay"
params.FuncName = "GetBuyRelayOrder" params.FuncName = "GetBuyRelayOrder"
...@@ -86,7 +86,7 @@ func testShowOnesAcceptRelayOrdersCmd(t *testing.T, jrpc *jsonclient.JSONClient) ...@@ -86,7 +86,7 @@ func testShowOnesAcceptRelayOrdersCmd(t *testing.T, jrpc *jsonclient.JSONClient)
func testShowOnesStatusOrdersCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { func testShowOnesStatusOrdersCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{} var rep interface{}
var params types.Query4Cli var params rpctypes.Query4Jrpc
req := &pty.ReqRelayAddrCoins{} req := &pty.ReqRelayAddrCoins{}
params.Execer = "relay" params.Execer = "relay"
params.FuncName = "GetRelayOrderByStatus" params.FuncName = "GetRelayOrderByStatus"
...@@ -97,7 +97,7 @@ func testShowOnesStatusOrdersCmd(t *testing.T, jrpc *jsonclient.JSONClient) erro ...@@ -97,7 +97,7 @@ func testShowOnesStatusOrdersCmd(t *testing.T, jrpc *jsonclient.JSONClient) erro
func testShowBTCHeadHeightListCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { func testShowBTCHeadHeightListCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{} var rep interface{}
var params types.Query4Cli var params rpctypes.Query4Jrpc
req := &pty.ReqRelayBtcHeaderHeightList{} req := &pty.ReqRelayBtcHeaderHeightList{}
params.Execer = "relay" params.Execer = "relay"
params.FuncName = "GetBTCHeaderList" params.FuncName = "GetBTCHeaderList"
......
...@@ -8,6 +8,7 @@ import ( ...@@ -8,6 +8,7 @@ import (
"fmt" "fmt"
jsonrpc "github.com/33cn/chain33/rpc/jsonclient" jsonrpc "github.com/33cn/chain33/rpc/jsonclient"
rpctypes "github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
"github.com/33cn/plugin/plugin/dapp/retrieve/rpc" "github.com/33cn/plugin/plugin/dapp/retrieve/rpc"
rt "github.com/33cn/plugin/plugin/dapp/retrieve/types" rt "github.com/33cn/plugin/plugin/dapp/retrieve/types"
...@@ -226,10 +227,10 @@ func queryRetrieveCmd(cmd *cobra.Command, args []string) { ...@@ -226,10 +227,10 @@ func queryRetrieveCmd(cmd *cobra.Command, args []string) {
DefaultAddress: defaultAddr, DefaultAddress: defaultAddr,
} }
var params types.Query4Cli var params rpctypes.Query4Jrpc
params.Execer = "retrieve" params.Execer = "retrieve"
params.FuncName = "GetRetrieveInfo" params.FuncName = "GetRetrieveInfo"
params.Payload = req params.Payload = types.MustPBToJSON(req)
var res rt.RetrieveQuery var res rt.RetrieveQuery
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
......
...@@ -77,7 +77,7 @@ func testCancelCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { ...@@ -77,7 +77,7 @@ func testCancelCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
func testRetrieveQueryCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { func testRetrieveQueryCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{} var rep interface{}
var params types.Query4Cli var params rpctypes.Query4Jrpc
req := &pty.ReqRetrieveInfo{} req := &pty.ReqRetrieveInfo{}
params.Execer = "retrieve" params.Execer = "retrieve"
params.FuncName = "GetRetrieveInfo" params.FuncName = "GetRetrieveInfo"
......
...@@ -182,10 +182,10 @@ func coldAddressOfMiner(cmd *cobra.Command, args []string) { ...@@ -182,10 +182,10 @@ func coldAddressOfMiner(cmd *cobra.Command, args []string) {
reqaddr := &types.ReqString{ reqaddr := &types.ReqString{
Data: addr, Data: addr,
} }
var params types.Query4Cli var params rpctypes.Query4Jrpc
params.Execer = "ticket" params.Execer = "ticket"
params.FuncName = "MinerSourceList" params.FuncName = "MinerSourceList"
params.Payload = reqaddr params.Payload = types.MustPBToJSON(reqaddr)
var res types.ReplyStrings var res types.ReplyStrings
ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res) ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
......
...@@ -56,7 +56,7 @@ func testCloseTicketCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { ...@@ -56,7 +56,7 @@ func testCloseTicketCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
func testGetColdAddrByMinerCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { func testGetColdAddrByMinerCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{} var rep interface{}
var params types.Query4Cli var params rpctypes.Query4Jrpc
req := &types.ReqString{} req := &types.ReqString{}
params.Execer = "ticket" params.Execer = "ticket"
params.FuncName = "MinerSourceList" params.FuncName = "MinerSourceList"
......
...@@ -142,10 +142,10 @@ func getPreCreatedTokens(cmd *cobra.Command, args []string) { ...@@ -142,10 +142,10 @@ func getPreCreatedTokens(cmd *cobra.Command, args []string) {
var reqtokens tokenty.ReqTokens var reqtokens tokenty.ReqTokens
reqtokens.Status = tokenty.TokenStatusPreCreated reqtokens.Status = tokenty.TokenStatusPreCreated
reqtokens.QueryAll = true reqtokens.QueryAll = true
var params types.Query4Cli var params rpctypes.Query4Jrpc
params.Execer = getRealExecName(paraName, "token") params.Execer = getRealExecName(paraName, "token")
params.FuncName = "GetTokens" params.FuncName = "GetTokens"
params.Payload = reqtokens params.Payload = types.MustPBToJSON(&reqtokens)
rpc, err := jsonclient.NewJSONClient(rpcLaddr) rpc, err := jsonclient.NewJSONClient(rpcLaddr)
if err != nil { if err != nil {
fmt.Fprintln(os.Stderr, err) fmt.Fprintln(os.Stderr, err)
...@@ -188,10 +188,10 @@ func getFinishCreatedTokens(cmd *cobra.Command, args []string) { ...@@ -188,10 +188,10 @@ func getFinishCreatedTokens(cmd *cobra.Command, args []string) {
var reqtokens tokenty.ReqTokens var reqtokens tokenty.ReqTokens
reqtokens.Status = tokenty.TokenStatusCreated reqtokens.Status = tokenty.TokenStatusCreated
reqtokens.QueryAll = true reqtokens.QueryAll = true
var params types.Query4Cli var params rpctypes.Query4Jrpc
params.Execer = getRealExecName(paraName, "token") params.Execer = getRealExecName(paraName, "token")
params.FuncName = "GetTokens" params.FuncName = "GetTokens"
params.Payload = reqtokens params.Payload = types.MustPBToJSON(&reqtokens)
rpc, err := jsonclient.NewJSONClient(rpcLaddr) rpc, err := jsonclient.NewJSONClient(rpcLaddr)
if err != nil { if err != nil {
fmt.Fprintln(os.Stderr, err) fmt.Fprintln(os.Stderr, err)
...@@ -249,10 +249,10 @@ func tokenAssets(cmd *cobra.Command, args []string) { ...@@ -249,10 +249,10 @@ func tokenAssets(cmd *cobra.Command, args []string) {
Execer: execer, Execer: execer,
} }
var params types.Query4Cli var params rpctypes.Query4Jrpc
params.Execer = getRealExecName(paraName, "token") params.Execer = getRealExecName(paraName, "token")
params.FuncName = "GetAccountTokenAssets" params.FuncName = "GetAccountTokenAssets"
params.Payload = req params.Payload = types.MustPBToJSON(&req)
var res tokenty.ReplyAccountTokenAssets var res tokenty.ReplyAccountTokenAssets
ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res) ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
......
...@@ -54,7 +54,7 @@ func TestJRPCChannel(t *testing.T) { ...@@ -54,7 +54,7 @@ func TestJRPCChannel(t *testing.T) {
func testGetTokensPreCreatedCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { func testGetTokensPreCreatedCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{} var rep interface{}
var params types.Query4Cli var params rpctypes.Query4Jrpc
req := &pty.ReqTokens{} req := &pty.ReqTokens{}
params.Execer = "token" params.Execer = "token"
params.FuncName = "GetTokens" params.FuncName = "GetTokens"
...@@ -64,7 +64,7 @@ func testGetTokensPreCreatedCmd(t *testing.T, jrpc *jsonclient.JSONClient) error ...@@ -64,7 +64,7 @@ func testGetTokensPreCreatedCmd(t *testing.T, jrpc *jsonclient.JSONClient) error
} }
func testGetTokensFinishCreatedCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { func testGetTokensFinishCreatedCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
params := types.Query4Cli{ params := rpctypes.Query4Jrpc{
Execer: "token", Execer: "token",
FuncName: "GetTokens", FuncName: "GetTokens",
Payload: pty.ReqTokens{}, Payload: pty.ReqTokens{},
...@@ -75,7 +75,7 @@ func testGetTokensFinishCreatedCmd(t *testing.T, jrpc *jsonclient.JSONClient) er ...@@ -75,7 +75,7 @@ func testGetTokensFinishCreatedCmd(t *testing.T, jrpc *jsonclient.JSONClient) er
func testGetTokenAssetsCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { func testGetTokenAssetsCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{} var rep interface{}
var params types.Query4Cli var params rpctypes.Query4Jrpc
req := &pty.ReqAccountTokenAssets{} req := &pty.ReqAccountTokenAssets{}
params.Execer = "token" params.Execer = "token"
params.FuncName = "GetAccountTokenAssets" params.FuncName = "GetAccountTokenAssets"
......
...@@ -11,6 +11,7 @@ import ( ...@@ -11,6 +11,7 @@ import (
"strings" "strings"
jsonrpc "github.com/33cn/chain33/rpc/jsonclient" jsonrpc "github.com/33cn/chain33/rpc/jsonclient"
rpctypes "github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
pty "github.com/33cn/plugin/plugin/dapp/trade/types" pty "github.com/33cn/plugin/plugin/dapp/trade/types"
"github.com/spf13/cobra" "github.com/spf13/cobra"
...@@ -71,10 +72,10 @@ func showOnesSellOrders(cmd *cobra.Command, args []string) { ...@@ -71,10 +72,10 @@ func showOnesSellOrders(cmd *cobra.Command, args []string) {
if 0 != len(tokens) { if 0 != len(tokens) {
reqAddrtokens.Token = append(reqAddrtokens.Token, tokens...) reqAddrtokens.Token = append(reqAddrtokens.Token, tokens...)
} }
params := types.Query4Cli{ params := rpctypes.Query4Jrpc{
Execer: "trade", Execer: "trade",
FuncName: "GetOnesSellOrder", FuncName: "GetOnesSellOrder",
Payload: reqAddrtokens, Payload: types.MustPBToJSON(&reqAddrtokens),
} }
var res pty.ReplySellOrders var res pty.ReplySellOrders
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
...@@ -113,10 +114,10 @@ func showOnesSellOrdersStatus(cmd *cobra.Command, args []string) { ...@@ -113,10 +114,10 @@ func showOnesSellOrdersStatus(cmd *cobra.Command, args []string) {
reqAddrtokens.Status = statusInt reqAddrtokens.Status = statusInt
reqAddrtokens.Addr = addr reqAddrtokens.Addr = addr
var params types.Query4Cli var params rpctypes.Query4Jrpc
params.Execer = "trade" params.Execer = "trade"
params.FuncName = "GetOnesSellOrderWithStatus" params.FuncName = "GetOnesSellOrderWithStatus"
params.Payload = reqAddrtokens params.Payload = types.MustPBToJSON(&reqAddrtokens)
var res pty.ReplySellOrders var res pty.ReplySellOrders
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.SetResultCb(parseSellOrders) ctx.SetResultCb(parseSellOrders)
...@@ -166,10 +167,10 @@ func showTokenSellOrdersStatus(cmd *cobra.Command, args []string) { ...@@ -166,10 +167,10 @@ func showTokenSellOrdersStatus(cmd *cobra.Command, args []string) {
req.Direction = dir req.Direction = dir
req.FromKey = from req.FromKey = from
req.Status = statusInt req.Status = statusInt
var params types.Query4Cli var params rpctypes.Query4Jrpc
params.Execer = "trade" params.Execer = "trade"
params.FuncName = "GetTokenSellOrderByStatus" params.FuncName = "GetTokenSellOrderByStatus"
params.Payload = req params.Payload = types.MustPBToJSON(&req)
var res pty.ReplySellOrders var res pty.ReplySellOrders
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.SetResultCb(parseSellOrders) ctx.SetResultCb(parseSellOrders)
...@@ -229,10 +230,10 @@ func showOnesBuyOrders(cmd *cobra.Command, args []string) { ...@@ -229,10 +230,10 @@ func showOnesBuyOrders(cmd *cobra.Command, args []string) {
if 0 != len(tokens) { if 0 != len(tokens) {
reqAddrtokens.Token = append(reqAddrtokens.Token, tokens...) reqAddrtokens.Token = append(reqAddrtokens.Token, tokens...)
} }
var params types.Query4Cli var params rpctypes.Query4Jrpc
params.Execer = "trade" params.Execer = "trade"
params.FuncName = "GetOnesBuyOrder" params.FuncName = "GetOnesBuyOrder"
params.Payload = reqAddrtokens params.Payload = types.MustPBToJSON(&reqAddrtokens)
var res pty.ReplyBuyOrders var res pty.ReplyBuyOrders
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.SetResultCb(parseBuyOrders) ctx.SetResultCb(parseBuyOrders)
...@@ -269,10 +270,10 @@ func showOnesBuyOrdersStatus(cmd *cobra.Command, args []string) { ...@@ -269,10 +270,10 @@ func showOnesBuyOrdersStatus(cmd *cobra.Command, args []string) {
var reqAddrtokens pty.ReqAddrAssets var reqAddrtokens pty.ReqAddrAssets
reqAddrtokens.Addr = buyer reqAddrtokens.Addr = buyer
reqAddrtokens.Status = statusInt reqAddrtokens.Status = statusInt
var params types.Query4Cli var params rpctypes.Query4Jrpc
params.Execer = "trade" params.Execer = "trade"
params.FuncName = "GetOnesBuyOrderWithStatus" params.FuncName = "GetOnesBuyOrderWithStatus"
params.Payload = reqAddrtokens params.Payload = types.MustPBToJSON(&reqAddrtokens)
var res pty.ReplyBuyOrders var res pty.ReplyBuyOrders
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.SetResultCb(parseBuyOrders) ctx.SetResultCb(parseBuyOrders)
...@@ -322,10 +323,10 @@ func showTokenBuyOrdersStatus(cmd *cobra.Command, args []string) { ...@@ -322,10 +323,10 @@ func showTokenBuyOrdersStatus(cmd *cobra.Command, args []string) {
req.Direction = dir req.Direction = dir
req.FromKey = from req.FromKey = from
req.Status = statusInt req.Status = statusInt
var params types.Query4Cli var params rpctypes.Query4Jrpc
params.Execer = "trade" params.Execer = "trade"
params.FuncName = "GetTokenBuyOrderByStatus" params.FuncName = "GetTokenBuyOrderByStatus"
params.Payload = req params.Payload = types.MustPBToJSON(&req)
var res pty.ReplyBuyOrders var res pty.ReplyBuyOrders
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.SetResultCb(parseBuyOrders) ctx.SetResultCb(parseBuyOrders)
...@@ -396,10 +397,10 @@ func showOnesOrdersStatus(cmd *cobra.Command, args []string) { ...@@ -396,10 +397,10 @@ func showOnesOrdersStatus(cmd *cobra.Command, args []string) {
reqAddrtokens.Direction = dir reqAddrtokens.Direction = dir
reqAddrtokens.FromKey = from reqAddrtokens.FromKey = from
reqAddrtokens.Status = status reqAddrtokens.Status = status
var params types.Query4Cli var params rpctypes.Query4Jrpc
params.Execer = "trade" params.Execer = "trade"
params.FuncName = "GetOnesOrderWithStatus" params.FuncName = "GetOnesOrderWithStatus"
params.Payload = reqAddrtokens params.Payload = types.MustPBToJSON(&reqAddrtokens)
var res pty.ReplyTradeOrders var res pty.ReplyTradeOrders
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.SetResultCb(parseTradeOrders) ctx.SetResultCb(parseTradeOrders)
......
...@@ -75,7 +75,7 @@ func testCreateRawTradeRevokeTxCmd(t *testing.T, jrpc *jsonclient.JSONClient) er ...@@ -75,7 +75,7 @@ func testCreateRawTradeRevokeTxCmd(t *testing.T, jrpc *jsonclient.JSONClient) er
} }
func testShowOnesSellOrdersCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { func testShowOnesSellOrdersCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
params := types.Query4Cli{ params := rpctypes.Query4Jrpc{
Execer: "trade", Execer: "trade",
FuncName: "GetOnesSellOrder", FuncName: "GetOnesSellOrder",
Payload: pty.ReqAddrAssets{}, Payload: pty.ReqAddrAssets{},
...@@ -86,7 +86,7 @@ func testShowOnesSellOrdersCmd(t *testing.T, jrpc *jsonclient.JSONClient) error ...@@ -86,7 +86,7 @@ func testShowOnesSellOrdersCmd(t *testing.T, jrpc *jsonclient.JSONClient) error
func testShowOnesSellOrdersStatusCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { func testShowOnesSellOrdersStatusCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{} var rep interface{}
var params types.Query4Cli var params rpctypes.Query4Jrpc
req := &pty.ReqAddrAssets{} req := &pty.ReqAddrAssets{}
params.Execer = "trade" params.Execer = "trade"
params.FuncName = "GetOnesSellOrderWithStatus" params.FuncName = "GetOnesSellOrderWithStatus"
...@@ -97,7 +97,7 @@ func testShowOnesSellOrdersStatusCmd(t *testing.T, jrpc *jsonclient.JSONClient) ...@@ -97,7 +97,7 @@ func testShowOnesSellOrdersStatusCmd(t *testing.T, jrpc *jsonclient.JSONClient)
func testShowTokenSellOrdersStatusCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { func testShowTokenSellOrdersStatusCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{} var rep interface{}
var params types.Query4Cli var params rpctypes.Query4Jrpc
req := &pty.ReqTokenSellOrder{} req := &pty.ReqTokenSellOrder{}
params.Execer = "trade" params.Execer = "trade"
params.FuncName = "GetTokenSellOrderByStatus" params.FuncName = "GetTokenSellOrderByStatus"
...@@ -109,7 +109,7 @@ func testShowTokenSellOrdersStatusCmd(t *testing.T, jrpc *jsonclient.JSONClient) ...@@ -109,7 +109,7 @@ func testShowTokenSellOrdersStatusCmd(t *testing.T, jrpc *jsonclient.JSONClient)
func testShowOnesBuyOrderCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { func testShowOnesBuyOrderCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{} var rep interface{}
var params types.Query4Cli var params rpctypes.Query4Jrpc
req := &pty.ReqAddrAssets{} req := &pty.ReqAddrAssets{}
params.Execer = "trade" params.Execer = "trade"
params.FuncName = "GetOnesBuyOrder" params.FuncName = "GetOnesBuyOrder"
...@@ -121,7 +121,7 @@ func testShowOnesBuyOrderCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { ...@@ -121,7 +121,7 @@ func testShowOnesBuyOrderCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
func testShowOnesBuyOrdersStatusCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { func testShowOnesBuyOrdersStatusCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{} var rep interface{}
var params types.Query4Cli var params rpctypes.Query4Jrpc
req := &pty.ReqAddrAssets{} req := &pty.ReqAddrAssets{}
params.Execer = "trade" params.Execer = "trade"
params.FuncName = "GetOnesBuyOrderWithStatus" params.FuncName = "GetOnesBuyOrderWithStatus"
...@@ -133,7 +133,7 @@ func testShowOnesBuyOrdersStatusCmd(t *testing.T, jrpc *jsonclient.JSONClient) e ...@@ -133,7 +133,7 @@ func testShowOnesBuyOrdersStatusCmd(t *testing.T, jrpc *jsonclient.JSONClient) e
func testShowTokenBuyOrdersStatusCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { func testShowTokenBuyOrdersStatusCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{} var rep interface{}
var params types.Query4Cli var params rpctypes.Query4Jrpc
req := &pty.ReqTokenBuyOrder{} req := &pty.ReqTokenBuyOrder{}
params.Execer = "trade" params.Execer = "trade"
params.FuncName = "GetTokenBuyOrderByStatus" params.FuncName = "GetTokenBuyOrderByStatus"
...@@ -145,7 +145,7 @@ func testShowTokenBuyOrdersStatusCmd(t *testing.T, jrpc *jsonclient.JSONClient) ...@@ -145,7 +145,7 @@ func testShowTokenBuyOrdersStatusCmd(t *testing.T, jrpc *jsonclient.JSONClient)
func testShowOnesOrdersStatusCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { func testShowOnesOrdersStatusCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{} var rep interface{}
var params types.Query4Cli var params rpctypes.Query4Jrpc
req := &pty.ReqAddrAssets{} req := &pty.ReqAddrAssets{}
params.Execer = "trade" params.Execer = "trade"
params.FuncName = "GetOnesOrderWithStatus" params.FuncName = "GetOnesOrderWithStatus"
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## [Unreleased] ## [Unreleased]
## [6.0.2]
### Changed
- changed cli version cmd return json format and added title app localdb version info
## [6.0.1] ## [6.0.1]
### Changed ### Changed
- Update configuration files from p2p/verMix to p2p/verMin from[@libangzhu](https://github.com/libangzhu). - Update configuration files from p2p/verMix to p2p/verMin from[@libangzhu](https://github.com/libangzhu).
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
package version package version
const version = "6.0.1" const version = "6.0.2"
//var //var
var ( var (
......
...@@ -138,6 +138,7 @@ func (exec *Executor) procExecQuery(msg queue.Message) { ...@@ -138,6 +138,7 @@ func (exec *Executor) procExecQuery(msg queue.Message) {
db := NewStateDB(exec.client, data.StateHash, localdb, opt) db := NewStateDB(exec.client, data.StateHash, localdb, opt)
db.(*StateDB).enableMVCC() db.(*StateDB).enableMVCC()
driver.SetStateDB(db) driver.SetStateDB(db)
driver.SetAPI(exec.qclient)
//查询的情况下下,执行器不做严格校验,allow,尽可能的加载执行器,并且做查询 //查询的情况下下,执行器不做严格校验,allow,尽可能的加载执行器,并且做查询
......
...@@ -232,9 +232,13 @@ func TestExecBlock(t *testing.T) { ...@@ -232,9 +232,13 @@ func TestExecBlock(t *testing.T) {
func BenchmarkExecBlock(b *testing.B) { func BenchmarkExecBlock(b *testing.B) {
mock33 := newMockNode() mock33 := newMockNode()
defer mock33.Close() defer mock33.Close()
block := util.CreateNoneBlock(mock33.GetGenesisKey(), 10000) block := util.CreateCoinsBlock(mock33.GetGenesisKey(), 10000)
mock33.WaitHeight(0)
block0 := mock33.GetBlock(0)
account := mock33.GetAccount(block0.StateHash, mock33.GetGenesisAddress())
assert.Equal(b, int64(10000000000000000), account.Balance)
b.StartTimer() b.StartTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
util.ExecBlock(mock33.GetClient(), nil, block, false, true) util.ExecBlock(mock33.GetClient(), block0.StateHash, block, false, true)
} }
} }
...@@ -897,7 +897,12 @@ func (c *Chain33) DumpPrivkey(in types.ReqString, result *interface{}) error { ...@@ -897,7 +897,12 @@ func (c *Chain33) DumpPrivkey(in types.ReqString, result *interface{}) error {
// Version version // Version version
func (c *Chain33) Version(in *types.ReqNil, result *interface{}) error { func (c *Chain33) Version(in *types.ReqNil, result *interface{}) error {
*result = version.GetVersion() *result = &rpctypes.NodeVersion{
Title: types.GetTitle(),
App: version.GetAppVersion(),
Chain33: version.GetVersion(),
LocalDb: version.GetLocalDBVersion(),
}
return nil return nil
} }
......
...@@ -75,9 +75,10 @@ func TestJSONClient_Call(t *testing.T) { ...@@ -75,9 +75,10 @@ func TestJSONClient_Call(t *testing.T) {
assert.Nil(t, err) assert.Nil(t, err)
assert.NotNil(t, jsonClient) assert.NotNil(t, jsonClient)
err = jsonClient.Call("Chain33.Version", nil, &result) var nodeVersion rpctypes.NodeVersion
err = jsonClient.Call("Chain33.Version", nil, &nodeVersion)
assert.Nil(t, err) assert.Nil(t, err)
assert.NotEmpty(t, result) assert.Equal(t, "6.0.2", nodeVersion.Chain33)
var isSnyc bool var isSnyc bool
err = jsonClient.Call("Chain33.IsSync", &types.ReqNil{}, &isSnyc) err = jsonClient.Call("Chain33.IsSync", &types.ReqNil{}, &isSnyc)
......
...@@ -305,6 +305,14 @@ type NodeNetinfo struct { ...@@ -305,6 +305,14 @@ type NodeNetinfo struct {
Inbounds int32 `json:"inbounds"` Inbounds int32 `json:"inbounds"`
} }
// NodeVersion node version
type NodeVersion struct {
Title string `json:"title"`
App string `json:"app"`
Chain33 string `json:"chain33"`
LocalDb string `json:"localDb"`
}
// ReplyPrivacyPkPair reply privekey pubkey pair // ReplyPrivacyPkPair reply privekey pubkey pair
type ReplyPrivacyPkPair struct { type ReplyPrivacyPkPair struct {
ShowSuccessful bool `json:"showSuccessful,omitempty"` ShowSuccessful bool `json:"showSuccessful,omitempty"`
......
...@@ -145,11 +145,11 @@ func totalCoins(cmd *cobra.Command, args []string) { ...@@ -145,11 +145,11 @@ func totalCoins(cmd *cobra.Command, args []string) {
} else { } else {
var req types.ReqString var req types.ReqString
req.Data = symbol req.Data = symbol
var params types.Query4Cli var params rpctypes.Query4Jrpc
params.Execer = "token" params.Execer = "token"
// 查询Token的总量 // 查询Token的总量
params.FuncName = "GetTotalAmount" params.FuncName = "GetTotalAmount"
params.Payload = req params.Payload = types.MustPBToJSON(&req)
var res types.TotalAmount var res types.TotalAmount
//查询Token总量 //查询Token总量
......
...@@ -80,6 +80,10 @@ func CreateRawTx(cmd *cobra.Command, to string, amount float64, note string, isW ...@@ -80,6 +80,10 @@ func CreateRawTx(cmd *cobra.Command, to string, amount float64, note string, isW
if amount < 0 { if amount < 0 {
return "", types.ErrAmount return "", types.ErrAmount
} }
if float64(types.MaxCoin/types.Coin) < amount {
return "", types.ErrAmount
}
paraName, _ := cmd.Flags().GetString("paraName") paraName, _ := cmd.Flags().GetString("paraName")
amountInt64 := int64(math.Trunc((amount+0.0000001)*1e4)) * 1e4 amountInt64 := int64(math.Trunc((amount+0.0000001)*1e4)) * 1e4
initExecName := execName initExecName := execName
......
...@@ -6,6 +6,7 @@ package commands ...@@ -6,6 +6,7 @@ package commands
import ( import (
"github.com/33cn/chain33/rpc/jsonclient" "github.com/33cn/chain33/rpc/jsonclient"
"github.com/33cn/chain33/rpc/types"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
...@@ -22,7 +23,8 @@ func VersionCmd() *cobra.Command { ...@@ -22,7 +23,8 @@ func VersionCmd() *cobra.Command {
func version(cmd *cobra.Command, args []string) { func version(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr") rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
var res types.NodeVersion
ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.Version", nil, &res)
ctx.Run()
ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.Version", nil, nil)
ctx.RunWithoutMarshal()
} }
...@@ -12,6 +12,7 @@ import ( ...@@ -12,6 +12,7 @@ import (
"github.com/33cn/chain33/util" "github.com/33cn/chain33/util"
"github.com/33cn/chain33/rpc/jsonclient" "github.com/33cn/chain33/rpc/jsonclient"
rpctypes "github.com/33cn/chain33/rpc/types"
pty "github.com/33cn/chain33/system/dapp/manage/types" pty "github.com/33cn/chain33/system/dapp/manage/types"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
"github.com/spf13/cobra" "github.com/spf13/cobra"
...@@ -101,10 +102,10 @@ func queryConfig(cmd *cobra.Command, args []string) { ...@@ -101,10 +102,10 @@ func queryConfig(cmd *cobra.Command, args []string) {
req := &types.ReqString{ req := &types.ReqString{
Data: key, Data: key,
} }
var params types.Query4Cli var params rpctypes.Query4Jrpc
params.Execer = util.GetParaExecName(paraName, "manage") params.Execer = util.GetParaExecName(paraName, "manage")
params.FuncName = "GetConfigItem" params.FuncName = "GetConfigItem"
params.Payload = req params.Payload = types.MustPBToJSON(req)
var res types.ReplyConfig var res types.ReplyConfig
ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res) ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
......
...@@ -33,7 +33,7 @@ var ( ...@@ -33,7 +33,7 @@ var (
// coin conversation // coin conversation
const ( const (
Coin int64 = 1e8 Coin int64 = 1e8
MaxCoin int64 = 1e17 MaxCoin int64 = 9e18
MaxTxSize = 100000 //100K MaxTxSize = 100000 //100K
MaxTxGroupSize int32 = 20 MaxTxGroupSize int32 = 20
MaxBlockSize = 20000000 //20M MaxBlockSize = 20000000 //20M
......
...@@ -18,6 +18,7 @@ import ( ...@@ -18,6 +18,7 @@ import (
log "github.com/33cn/chain33/common/log/log15" log "github.com/33cn/chain33/common/log/log15"
"github.com/33cn/chain33/types/jsonpb" "github.com/33cn/chain33/types/jsonpb"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
// 注册system的crypto 加密算法 // 注册system的crypto 加密算法
_ "github.com/33cn/chain33/system/crypto/init" _ "github.com/33cn/chain33/system/crypto/init"
) )
...@@ -30,13 +31,6 @@ const Size1Kshiftlen uint = 10 ...@@ -30,13 +31,6 @@ const Size1Kshiftlen uint = 10
// Message 声明proto.Message // Message 声明proto.Message
type Message proto.Message type Message proto.Message
// Query4Cli cli命令行查询格式
type Query4Cli struct {
Execer string `json:"execer"`
FuncName string `json:"funcName"`
Payload interface{} `json:"payload"`
}
//TxGroup 交易组的接口,Transactions 和 Transaction 都符合这个接口 //TxGroup 交易组的接口,Transactions 和 Transaction 都符合这个接口
type TxGroup interface { type TxGroup interface {
Tx() *Transaction Tx() *Transaction
...@@ -429,6 +423,15 @@ func PBToJSON(r Message) ([]byte, error) { ...@@ -429,6 +423,15 @@ func PBToJSON(r Message) ([]byte, error) {
return buf.Bytes(), nil return buf.Bytes(), nil
} }
//MustPBToJSON panic when error
func MustPBToJSON(req Message) []byte {
data, err := PBToJSON(req)
if err != nil {
panic(err)
}
return data
}
// MustDecode 数据是否已经编码 // MustDecode 数据是否已经编码
func MustDecode(data []byte, v interface{}) { func MustDecode(data []byte, v interface{}) {
err := json.Unmarshal(data, v) err := json.Unmarshal(data, v)
......
...@@ -78,7 +78,7 @@ func GenNoneTxs(priv crypto.PrivKey, n int64) (txs []*types.Transaction) { ...@@ -78,7 +78,7 @@ func GenNoneTxs(priv crypto.PrivKey, n int64) (txs []*types.Transaction) {
func GenCoinsTxs(priv crypto.PrivKey, n int64) (txs []*types.Transaction) { func GenCoinsTxs(priv crypto.PrivKey, n int64) (txs []*types.Transaction) {
to, _ := Genaddress() to, _ := Genaddress()
for i := 0; i < int(n); i++ { for i := 0; i < int(n); i++ {
txs = append(txs, CreateCoinsTx(priv, to, types.Coin*(n+1))) txs = append(txs, CreateCoinsTx(priv, to, n+1))
} }
return txs return txs
} }
...@@ -188,7 +188,7 @@ var zeroHash [32]byte ...@@ -188,7 +188,7 @@ var zeroHash [32]byte
// CreateNoneBlock : Create None Block // CreateNoneBlock : Create None Block
func CreateNoneBlock(priv crypto.PrivKey, n int64) *types.Block { func CreateNoneBlock(priv crypto.PrivKey, n int64) *types.Block {
newblock := &types.Block{} newblock := &types.Block{}
newblock.Height = -1 newblock.Height = 1
newblock.BlockTime = types.Now().Unix() newblock.BlockTime = types.Now().Unix()
newblock.ParentHash = zeroHash[:] newblock.ParentHash = zeroHash[:]
newblock.Txs = GenNoneTxs(priv, n) newblock.Txs = GenNoneTxs(priv, n)
...@@ -196,6 +196,17 @@ func CreateNoneBlock(priv crypto.PrivKey, n int64) *types.Block { ...@@ -196,6 +196,17 @@ func CreateNoneBlock(priv crypto.PrivKey, n int64) *types.Block {
return newblock return newblock
} }
//CreateCoinsBlock : create coins block, n size
func CreateCoinsBlock(priv crypto.PrivKey, n int64) *types.Block {
newblock := &types.Block{}
newblock.Height = 1
newblock.BlockTime = types.Now().Unix()
newblock.ParentHash = zeroHash[:]
newblock.Txs = GenCoinsTxs(priv, n)
newblock.TxHash = merkle.CalcMerkleRoot(newblock.Txs)
return newblock
}
// ExecBlock : just exec block // ExecBlock : just exec block
func ExecBlock(client queue.Client, prevStateRoot []byte, block *types.Block, errReturn bool, sync bool) (*types.BlockDetail, []*types.Transaction, error) { func ExecBlock(client queue.Client, prevStateRoot []byte, block *types.Block, errReturn bool, sync bool) (*types.BlockDetail, []*types.Transaction, error) {
//发送执行交易给execs模块 //发送执行交易给execs模块
......
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