Commit 526392a7 authored by vipwzw's avatar vipwzw

update chain33 && del query cli

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