Commit db73b524 authored by vipwzw's avatar vipwzw

Merge remote-tracking branch 'upstream/master'

parents 95acd3bf 44464808
......@@ -8,6 +8,7 @@ datadir*
.idea
.vscode
build/chain33*
chain33_raft-1
build/datadir
build/bityuan*
build/para
......
......@@ -9,7 +9,7 @@ jobs:
include:
- stage: check_fmt
sudo: require
go: "1.9.x"
go: "1.11.x"
install:
- go get -u golang.org/x/tools/cmd/goimports
- go get -u gopkg.in/alecthomas/gometalinter.v2
......
......@@ -13,7 +13,6 @@ CHAIN33_PATH=vendor/${CHAIN33}
LDFLAGS := -ldflags "-w -s"
PKG_LIST_VET := `go list ./... | grep -v "vendor" | grep -v plugin/dapp/evm/executor/vm/common/crypto/bn256`
PKG_LIST := `go list ./... | grep -v "vendor" | grep -v "chain33/test" | grep -v "mocks" | grep -v "pbft"`
PKG_LIST_Q := `go list ./... | grep -v "vendor" | grep -v "chain33/test" | grep -v "mocks" | grep -v "blockchain" | grep -v "pbft"`
BUILD_FLAGS = -ldflags "-X github.com/33cn/chain33/common/version.GitCommit=`git rev-parse --short=8 HEAD`"
MKPATH=$(abspath $(lastword $(MAKEFILE_LIST)))
MKDIR=$(dir $(MKPATH))
......@@ -88,13 +87,16 @@ race: ## Run data race detector
test: ## Run unittests
@go test -race $(PKG_LIST)
testq: ## Run unittests
@go test $(PKG_LIST)
fmt: fmt_proto fmt_shell ## go fmt
@go fmt ./...
@find . -name '*.go' -not -path "./vendor/*" | xargs goimports -l -w
.PHONY: fmt_proto fmt_shell
fmt_proto: ## go fmt protobuf file
@find . -name '*.proto' -not -path "./vendor/*" | xargs clang-format -i
#@find . -name '*.proto' -not -path "./vendor/*" | xargs clang-format -i
fmt_shell: ## check shell file
@find . -name '*.sh' -not -path "./vendor/*" | xargs shfmt -w -s -i 4 -ci -bn
......@@ -174,15 +176,6 @@ checkgofmt: ## get all go files and run go fmt on them
exit 1; \
fi;
.PHONY: mock
mock:
@cd client && mockery -name=QueueProtocolAPI && mv mocks/QueueProtocolAPI.go mocks/api.go && cd -
@cd queue && mockery -name=Client && mv mocks/Client.go mocks/client.go && cd -
@cd common/db && mockery -name=KV && mv mocks/KV.go mocks/kv.go && cd -
@cd common/db && mockery -name=KVDB && mv mocks/KVDB.go mocks/kvdb.go && cd -
@cd types/ && mockery -name=Chain33Client && mv mocks/Chain33Client.go mocks/chain33client.go && cd -
.PHONY: auto_ci_before auto_ci_after auto_ci
auto_ci_before: clean fmt protobuf
@echo "auto_ci"
......@@ -266,7 +259,7 @@ pullpush:
make pullsync
git push ${name} ${name}-${b}:${b}
webhook_auto_ci: clean fmt_proto fmt_shell protobuf mock
webhook_auto_ci: clean fmt_proto fmt_shell protobuf
@-find . -name '*.go' -not -path './vendor/*' | xargs gofmt -l -w -s
@-${auto_fmt}
@-find . -name '*.go' -not -path './vendor/*' | xargs gofmt -l -w -s
......
......@@ -149,7 +149,7 @@ func prepareTxList() *types.Transaction {
key = generateKey(i, 32)
value = generateValue(i, 180)
nput := &pty.NormAction_Nput{Nput: &pty.NormPut{Key: key, Value: []byte(value)}}
nput := &pty.NormAction_Nput{Nput: &pty.NormPut{Key: []byte(key), Value: []byte(value)}}
action := &pty.NormAction{Value: nput, Ty: pty.NormActionPut}
tx := &types.Transaction{Execer: []byte("norm"), Payload: types.Encode(action), Fee: 0}
tx.To = address.ExecAddress("norm")
......
......@@ -330,7 +330,7 @@ func RandStringBytes(n int) string {
// NormPut run put action
func NormPut(privkey string, key string, value string) {
fmt.Println(key, "=", value)
nput := &pty.NormAction_Nput{Nput: &pty.NormPut{Key: key, Value: []byte(value)}}
nput := &pty.NormAction_Nput{Nput: &pty.NormPut{Key: []byte(key), Value: []byte(value)}}
action := &pty.NormAction{Value: nput, Ty: pty.NormActionPut}
tx := &types.Transaction{Execer: []byte("norm"), Payload: types.Encode(action), Fee: fee}
tx.To = address.ExecAddress("norm")
......@@ -350,7 +350,7 @@ func NormPut(privkey string, key string, value string) {
// NormGet run query action
func NormGet(key string) {
in := &pty.NormGetKey{Key: key}
in := &pty.NormGetKey{Key: []byte(key)}
data, err := proto.Marshal(in)
if err != nil {
fmt.Fprintln(os.Stderr, err)
......
......@@ -147,7 +147,7 @@ func prepareTxList() *types.Transaction {
key = generateKey(i, 32)
value = generateValue(i, 180)
nput := &pty.NormAction_Nput{Nput: &pty.NormPut{Key: key, Value: []byte(value)}}
nput := &pty.NormAction_Nput{Nput: &pty.NormPut{Key: []byte(key), Value: []byte(value)}}
action := &pty.NormAction{Value: nput, Ty: pty.NormActionPut}
tx := &types.Transaction{Execer: []byte("norm"), Payload: types.Encode(action), Fee: fee}
tx.To = address.ExecAddress("norm")
......
......@@ -59,12 +59,12 @@ var (
"TimeoutDone": BlackwhiteActionTimeoutDone,
}
logInfo = map[int64]*types.LogInfo{
TyLogBlackwhiteCreate: {reflect.TypeOf(ReceiptBlackwhite{}), "LogBlackwhiteCreate"},
TyLogBlackwhitePlay: {reflect.TypeOf(ReceiptBlackwhite{}), "LogBlackwhitePlay"},
TyLogBlackwhiteShow: {reflect.TypeOf(ReceiptBlackwhite{}), "LogBlackwhiteShow"},
TyLogBlackwhiteTimeout: {reflect.TypeOf(ReceiptBlackwhite{}), "LogBlackwhiteTimeout"},
TyLogBlackwhiteDone: {reflect.TypeOf(ReceiptBlackwhite{}), "LogBlackwhiteDone"},
TyLogBlackwhiteLoopInfo: {reflect.TypeOf(ReplyLoopResults{}), "LogBlackwhiteLoopInfo"},
TyLogBlackwhiteCreate: {Ty: reflect.TypeOf(ReceiptBlackwhite{}), Name: "LogBlackwhiteCreate"},
TyLogBlackwhitePlay: {Ty: reflect.TypeOf(ReceiptBlackwhite{}), Name: "LogBlackwhitePlay"},
TyLogBlackwhiteShow: {Ty: reflect.TypeOf(ReceiptBlackwhite{}), Name: "LogBlackwhiteShow"},
TyLogBlackwhiteTimeout: {Ty: reflect.TypeOf(ReceiptBlackwhite{}), Name: "LogBlackwhiteTimeout"},
TyLogBlackwhiteDone: {Ty: reflect.TypeOf(ReceiptBlackwhite{}), Name: "LogBlackwhiteDone"},
TyLogBlackwhiteLoopInfo: {Ty: reflect.TypeOf(ReplyLoopResults{}), Name: "LogBlackwhiteLoopInfo"},
}
)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -45,10 +45,10 @@ type GameType struct {
// GetLogMap get log
func (gt *GameType) GetLogMap() map[int64]*types.LogInfo {
return map[int64]*types.LogInfo{
TyLogCreateGame: {reflect.TypeOf(ReceiptGame{}), "LogCreateGame"},
TyLogCancleGame: {reflect.TypeOf(ReceiptGame{}), "LogCancleGame"},
TyLogMatchGame: {reflect.TypeOf(ReceiptGame{}), "LogMatchGame"},
TyLogCloseGame: {reflect.TypeOf(ReceiptGame{}), "LogCloseGame"},
TyLogCreateGame: {Ty: reflect.TypeOf(ReceiptGame{}), Name: "LogCreateGame"},
TyLogCancleGame: {Ty: reflect.TypeOf(ReceiptGame{}), Name: "LogCancleGame"},
TyLogMatchGame: {Ty: reflect.TypeOf(ReceiptGame{}), Name: "LogMatchGame"},
TyLogCloseGame: {Ty: reflect.TypeOf(ReceiptGame{}), Name: "LogCloseGame"},
}
}
......
This diff is collapsed.
......@@ -38,10 +38,10 @@ func NewType() *LotteryType {
// GetLogMap method
func (lottery *LotteryType) GetLogMap() map[int64]*types.LogInfo {
return map[int64]*types.LogInfo{
TyLogLotteryCreate: {reflect.TypeOf(ReceiptLottery{}), "LogLotteryCreate"},
TyLogLotteryBuy: {reflect.TypeOf(ReceiptLottery{}), "LogLotteryBuy"},
TyLogLotteryDraw: {reflect.TypeOf(ReceiptLottery{}), "LogLotteryDraw"},
TyLogLotteryClose: {reflect.TypeOf(ReceiptLottery{}), "LogLotteryClose"},
TyLogLotteryCreate: {Ty: reflect.TypeOf(ReceiptLottery{}), Name: "LogLotteryCreate"},
TyLogLotteryBuy: {Ty: reflect.TypeOf(ReceiptLottery{}), Name: "LogLotteryBuy"},
TyLogLotteryDraw: {Ty: reflect.TypeOf(ReceiptLottery{}), Name: "LogLotteryDraw"},
TyLogLotteryClose: {Ty: reflect.TypeOf(ReceiptLottery{}), Name: "LogLotteryClose"},
}
}
......
This diff is collapsed.
......@@ -53,7 +53,7 @@ func (n *Norm) CheckTx(tx *types.Transaction, index int) error {
}
// Key for norm
func Key(str string) (key []byte) {
func Key(str []byte) (key []byte) {
key = append(key, []byte("mavl-norm-")...)
key = append(key, str...)
return key
......
......@@ -4,7 +4,7 @@ package types;
message Norm {
bytes normId = 1;
int64 createTime = 2;
string key = 3;
bytes key = 3;
bytes value = 4;
}
......@@ -16,10 +16,10 @@ message NormAction {
}
message NormPut {
string key = 1;
bytes key = 1;
bytes value = 2;
}
message NormGetKey {
string key = 1;
bytes key = 1;
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
......@@ -16,25 +16,6 @@ var (
// ParaX paracross exec name
ParaX = "paracross"
glog = log.New("module", ParaX)
/*
logInfo = map[int64]*types.LogInfo{
TyLogParacrossCommit: {reflect.TypeOf(ReceiptParacrossCommit{}), "LogParacrossCommit"},
TyLogParacrossCommitDone: {reflect.TypeOf(ReceiptParacrossDone{}), "LogParacrossDone"},
TyLogParacrossCommitRecord: {reflect.TypeOf(ReceiptParacrossRecord{}), "LogParacrossCommitRecord"},
TyLogParaAssetTransfer: {reflect.TypeOf(types.ReceiptAccountTransfer{}), "LogParacrossAssetTransfer"},
TyLogParaAssetWithdraw: {reflect.TypeOf(types.ReceiptAccountTransfer{}), "LogParacrossAssetWithdraw"},
TyLogParacrossMiner: {reflect.TypeOf(ReceiptParacrossMiner{}), "LogParacrossMiner"},
TyLogParaAssetDeposit: {reflect.TypeOf(types.ReceiptAccountTransfer{}), "LogParacrossAssetDeposit"},
}*/
// init query rpc
/* TODO-TODO
types.RegisterRPCQueryHandle("ParacrossGetTitle", &ParacrossGetTitle{})
types.RegisterRPCQueryHandle("paracrossListTitles", &paracrossListTitles{})
types.RegisterRPCQueryHandle("paracrossGetTitleHeight", &paracrossGetTitleHeight{})
types.RegisterRPCQueryHandle("paracrossGetAssetTxResult", &paracrossGetAssetTxResult{})
*/
)
func init() {
......@@ -64,13 +45,13 @@ func NewType() *ParacrossType {
// GetLogMap get receipt log map
func (p *ParacrossType) GetLogMap() map[int64]*types.LogInfo {
return map[int64]*types.LogInfo{
TyLogParacrossCommit: {reflect.TypeOf(ReceiptParacrossCommit{}), "LogParacrossCommit"},
TyLogParacrossCommitDone: {reflect.TypeOf(ReceiptParacrossDone{}), "LogParacrossCommitDone"},
TyLogParacrossCommitRecord: {reflect.TypeOf(ReceiptParacrossRecord{}), "LogParacrossCommitRecord"},
TyLogParaAssetWithdraw: {reflect.TypeOf(types.ReceiptAccountTransfer{}), "LogParaAssetWithdraw"},
TyLogParaAssetTransfer: {reflect.TypeOf(types.ReceiptAccountTransfer{}), "LogParaAssetTransfer"},
TyLogParaAssetDeposit: {reflect.TypeOf(types.ReceiptAccountTransfer{}), "LogParaAssetDeposit"},
TyLogParacrossMiner: {reflect.TypeOf(ReceiptParacrossMiner{}), "LogParacrossMiner"},
TyLogParacrossCommit: {Ty: reflect.TypeOf(ReceiptParacrossCommit{}), Name: "LogParacrossCommit"},
TyLogParacrossCommitDone: {Ty: reflect.TypeOf(ReceiptParacrossDone{}), Name: "LogParacrossCommitDone"},
TyLogParacrossCommitRecord: {Ty: reflect.TypeOf(ReceiptParacrossRecord{}), Name: "LogParacrossCommitRecord"},
TyLogParaAssetWithdraw: {Ty: reflect.TypeOf(types.ReceiptAccountTransfer{}), Name: "LogParaAssetWithdraw"},
TyLogParaAssetTransfer: {Ty: reflect.TypeOf(types.ReceiptAccountTransfer{}), Name: "LogParaAssetTransfer"},
TyLogParaAssetDeposit: {Ty: reflect.TypeOf(types.ReceiptAccountTransfer{}), Name: "LogParaAssetDeposit"},
TyLogParacrossMiner: {Ty: reflect.TypeOf(ReceiptParacrossMiner{}), Name: "LogParacrossMiner"},
}
}
......
This diff is collapsed.
......@@ -47,9 +47,9 @@ func (t *PokerBullType) GetTypeMap() map[string]int32 {
// GetLogMap 获取日志map
func (t *PokerBullType) GetLogMap() map[int64]*types.LogInfo {
return map[int64]*types.LogInfo{
TyLogPBGameStart: {reflect.TypeOf(ReceiptPBGame{}), "TyLogPBGameStart"},
TyLogPBGameContinue: {reflect.TypeOf(ReceiptPBGame{}), "TyLogPBGameContinue"},
TyLogPBGameQuit: {reflect.TypeOf(ReceiptPBGame{}), "TyLogPBGameQuit"},
TyLogPBGameQuery: {reflect.TypeOf(ReceiptPBGame{}), "TyLogPBGameQuery"},
TyLogPBGameStart: {Ty: reflect.TypeOf(ReceiptPBGame{}), Name: "TyLogPBGameStart"},
TyLogPBGameContinue: {Ty: reflect.TypeOf(ReceiptPBGame{}), Name: "TyLogPBGameContinue"},
TyLogPBGameQuit: {Ty: reflect.TypeOf(ReceiptPBGame{}), Name: "TyLogPBGameQuit"},
TyLogPBGameQuery: {Ty: reflect.TypeOf(ReceiptPBGame{}), Name: "TyLogPBGameQuery"},
}
}
......@@ -105,9 +105,9 @@ func (t *PrivacyType) GetName() string {
// GetLogMap get PrivacyType log map
func (t *PrivacyType) GetLogMap() map[int64]*types.LogInfo {
return map[int64]*types.LogInfo{
TyLogPrivacyFee: {reflect.TypeOf(types.ReceiptExecAccountTransfer{}), "LogPrivacyFee"},
TyLogPrivacyInput: {reflect.TypeOf(PrivacyInput{}), "LogPrivacyInput"},
TyLogPrivacyOutput: {reflect.TypeOf(PrivacyOutput{}), "LogPrivacyOutput"},
TyLogPrivacyFee: {Ty: reflect.TypeOf(types.ReceiptExecAccountTransfer{}), Name: "LogPrivacyFee"},
TyLogPrivacyInput: {Ty: reflect.TypeOf(PrivacyInput{}), Name: "LogPrivacyInput"},
TyLogPrivacyOutput: {Ty: reflect.TypeOf(PrivacyOutput{}), Name: "LogPrivacyOutput"},
}
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -234,7 +234,7 @@ func testStore_listFrozenUTXOs(t *testing.T) {
txs, err = store.listFrozenUTXOs(token, addr)
assert.NoError(t, err)
assert.Equal(t, 1, len(txs))
assert.Equal(t, tx, txs[0])
assert.Equal(t, true, proto.Equal(tx, txs[0]))
}
func testStore_listAvailableUTXOs(t *testing.T) {
......@@ -260,7 +260,7 @@ func testStore_listAvailableUTXOs(t *testing.T) {
utxos, err = store.listAvailableUTXOs(token, addr)
assert.NoError(t, err)
assert.Equal(t, 1, len(utxos))
assert.Equal(t, utxo, utxos[0])
assert.Equal(t, true, proto.Equal(utxo, utxos[0]))
}
func testStore_setWalletAccountPrivacy(t *testing.T) {
......@@ -291,7 +291,7 @@ func testStore_getAccountByAddr(t *testing.T) {
assert.NoError(t, err)
err = store.Set(calcAddrKey(addr), bt)
was, err = store.getAccountByAddr(addr)
assert.Equal(t, was, account)
assert.Equal(t, true, proto.Equal(was, account))
assert.NoError(t, err)
}
......@@ -325,7 +325,7 @@ func testStore_getAccountByPrefix(t *testing.T) {
assert.NoError(t, err)
was, err = store.getAccountByAddr(addr)
assert.NoError(t, err)
assert.Equal(t, was, account)
assert.Equal(t, true, proto.Equal(was, account))
}
func testStore_setVersion(t *testing.T) {
......
......@@ -14,6 +14,7 @@ import (
"github.com/33cn/chain33/common/db/mocks"
"github.com/33cn/chain33/types"
ty "github.com/33cn/plugin/plugin/dapp/relay/types"
"github.com/gogo/protobuf/proto"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/suite"
)
......@@ -1197,8 +1198,10 @@ func (s *suiteSaveBtcHeader) TestSaveBtcHeader_1() {
s.Zero(log.LastBaseHeight)
s.Equal(head2.Height, log.NewHeight)
s.Zero(log.NewBaseHeight)
s.Equal(headers.BtcHeader, log.Headers)
s.Equal(len(headers.BtcHeader), len(log.Headers))
for i, h := range headers.BtcHeader {
s.Equal(true, proto.Equal(h, log.Headers[i]))
}
}
//not continuous
......@@ -1325,8 +1328,10 @@ func (s *suiteSaveBtcHeader) TestSaveBtcHeader_4() {
s.Zero(log.LastBaseHeight)
s.Equal(head5.Height, log.NewHeight)
s.Equal(head4.Height, log.NewBaseHeight)
s.Equal(headers.BtcHeader, log.Headers)
s.Equal(len(headers.BtcHeader), len(log.Headers))
for i, h := range headers.BtcHeader {
s.Equal(true, proto.Equal(h, log.Headers[i]))
}
}
func TestRunSuiteSaveBtcHeader(t *testing.T) {
......
......@@ -86,13 +86,13 @@ func (r *RelayType) GetName() string {
// GetLogMap return receipt log map function
func (r *RelayType) GetLogMap() map[int64]*types.LogInfo {
return map[int64]*types.LogInfo{
TyLogRelayCreate: {reflect.TypeOf(ReceiptRelayLog{}), "LogRelayCreate"},
TyLogRelayRevokeCreate: {reflect.TypeOf(ReceiptRelayLog{}), "LogRelayRevokeCreate"},
TyLogRelayAccept: {reflect.TypeOf(ReceiptRelayLog{}), "LogRelayAccept"},
TyLogRelayRevokeAccept: {reflect.TypeOf(ReceiptRelayLog{}), "LogRelayRevokeAccept"},
TyLogRelayConfirmTx: {reflect.TypeOf(ReceiptRelayLog{}), "LogRelayConfirmTx"},
TyLogRelayFinishTx: {reflect.TypeOf(ReceiptRelayLog{}), "LogRelayFinishTx"},
TyLogRelayRcvBTCHead: {reflect.TypeOf(ReceiptRelayRcvBTCHeaders{}), "LogRelayRcvBTCHead"},
TyLogRelayCreate: {Ty: reflect.TypeOf(ReceiptRelayLog{}), Name: "LogRelayCreate"},
TyLogRelayRevokeCreate: {Ty: reflect.TypeOf(ReceiptRelayLog{}), Name: "LogRelayRevokeCreate"},
TyLogRelayAccept: {Ty: reflect.TypeOf(ReceiptRelayLog{}), Name: "LogRelayAccept"},
TyLogRelayRevokeAccept: {Ty: reflect.TypeOf(ReceiptRelayLog{}), Name: "LogRelayRevokeAccept"},
TyLogRelayConfirmTx: {Ty: reflect.TypeOf(ReceiptRelayLog{}), Name: "LogRelayConfirmTx"},
TyLogRelayFinishTx: {Ty: reflect.TypeOf(ReceiptRelayLog{}), Name: "LogRelayFinishTx"},
TyLogRelayRcvBTCHead: {Ty: reflect.TypeOf(ReceiptRelayRcvBTCHeaders{}), Name: "LogRelayRcvBTCHead"},
}
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -148,7 +148,7 @@ func TestRPC_CallTestNode(t *testing.T) {
var result = ""
err = jsonClient.Call("Chain33.Version", nil, &result)
assert.Nil(t, err)
assert.Equal(t, "5.3.0", result)
assert.Equal(t, "6.0.1", result)
var isSnyc bool
err = jsonClient.Call("Chain33.IsSync", &types.ReqNil{}, &isSnyc)
......
......@@ -82,10 +82,10 @@ func (ticket *TicketType) GetPayload() types.Message {
// GetLogMap get log map
func (ticket *TicketType) GetLogMap() map[int64]*types.LogInfo {
return map[int64]*types.LogInfo{
TyLogNewTicket: {reflect.TypeOf(ReceiptTicket{}), "LogNewTicket"},
TyLogCloseTicket: {reflect.TypeOf(ReceiptTicket{}), "LogCloseTicket"},
TyLogMinerTicket: {reflect.TypeOf(ReceiptTicket{}), "LogMinerTicket"},
TyLogTicketBind: {reflect.TypeOf(ReceiptTicketBind{}), "LogTicketBind"},
TyLogNewTicket: {Ty: reflect.TypeOf(ReceiptTicket{}), Name: "LogNewTicket"},
TyLogCloseTicket: {Ty: reflect.TypeOf(ReceiptTicket{}), Name: "LogCloseTicket"},
TyLogMinerTicket: {Ty: reflect.TypeOf(ReceiptTicket{}), Name: "LogMinerTicket"},
TyLogTicketBind: {Ty: reflect.TypeOf(ReceiptTicketBind{}), Name: "LogTicketBind"},
}
}
......
This diff is collapsed.
......@@ -121,10 +121,8 @@ func TestProtoNewEncodeOldDecode(t *testing.T) {
told := &TicketMinerOld{}
err := types.Decode(data, told)
assert.Nil(t, err)
assert.Equal(t, &TicketMinerOld{
Bits: 1,
Reward: 1,
TicketId: "id",
Modify: []byte("modify"),
}, told)
assert.Equal(t, told.Bits, uint32(1))
assert.Equal(t, told.Reward, int64(1))
assert.Equal(t, told.TicketId, "id")
assert.Equal(t, told.Modify, []byte("modify"))
}
......@@ -73,7 +73,7 @@ func main() {
panic(err)
}
approver := signatory.Signatory{cfg.Privkey}
approver := signatory.Signatory{Privkey: cfg.Privkey}
server := rpc.NewServer()
server.Register(&approver)
......
This diff is collapsed.
......@@ -52,18 +52,18 @@ func (t *TokenType) GetTypeMap() map[string]int32 {
// GetLogMap 获取log的映射对应关系
func (t *TokenType) GetLogMap() map[int64]*types.LogInfo {
return map[int64]*types.LogInfo{
TyLogTokenTransfer: {reflect.TypeOf(types.ReceiptAccountTransfer{}), "LogTokenTransfer"},
TyLogTokenDeposit: {reflect.TypeOf(types.ReceiptAccountTransfer{}), "LogTokenDeposit"},
TyLogTokenExecTransfer: {reflect.TypeOf(types.ReceiptExecAccountTransfer{}), "LogTokenExecTransfer"},
TyLogTokenExecWithdraw: {reflect.TypeOf(types.ReceiptExecAccountTransfer{}), "LogTokenExecWithdraw"},
TyLogTokenExecDeposit: {reflect.TypeOf(types.ReceiptExecAccountTransfer{}), "LogTokenExecDeposit"},
TyLogTokenExecFrozen: {reflect.TypeOf(types.ReceiptExecAccountTransfer{}), "LogTokenExecFrozen"},
TyLogTokenExecActive: {reflect.TypeOf(types.ReceiptExecAccountTransfer{}), "LogTokenExecActive"},
TyLogTokenGenesisTransfer: {reflect.TypeOf(types.ReceiptAccountTransfer{}), "LogTokenGenesisTransfer"},
TyLogTokenGenesisDeposit: {reflect.TypeOf(types.ReceiptExecAccountTransfer{}), "LogTokenGenesisDeposit"},
TyLogPreCreateToken: {reflect.TypeOf(ReceiptToken{}), "LogPreCreateToken"},
TyLogFinishCreateToken: {reflect.TypeOf(ReceiptToken{}), "LogFinishCreateToken"},
TyLogRevokeCreateToken: {reflect.TypeOf(ReceiptToken{}), "LogRevokeCreateToken"},
TyLogTokenTransfer: {Ty: reflect.TypeOf(types.ReceiptAccountTransfer{}), Name: "LogTokenTransfer"},
TyLogTokenDeposit: {Ty: reflect.TypeOf(types.ReceiptAccountTransfer{}), Name: "LogTokenDeposit"},
TyLogTokenExecTransfer: {Ty: reflect.TypeOf(types.ReceiptExecAccountTransfer{}), Name: "LogTokenExecTransfer"},
TyLogTokenExecWithdraw: {Ty: reflect.TypeOf(types.ReceiptExecAccountTransfer{}), Name: "LogTokenExecWithdraw"},
TyLogTokenExecDeposit: {Ty: reflect.TypeOf(types.ReceiptExecAccountTransfer{}), Name: "LogTokenExecDeposit"},
TyLogTokenExecFrozen: {Ty: reflect.TypeOf(types.ReceiptExecAccountTransfer{}), Name: "LogTokenExecFrozen"},
TyLogTokenExecActive: {Ty: reflect.TypeOf(types.ReceiptExecAccountTransfer{}), Name: "LogTokenExecActive"},
TyLogTokenGenesisTransfer: {Ty: reflect.TypeOf(types.ReceiptAccountTransfer{}), Name: "LogTokenGenesisTransfer"},
TyLogTokenGenesisDeposit: {Ty: reflect.TypeOf(types.ReceiptExecAccountTransfer{}), Name: "LogTokenGenesisDeposit"},
TyLogPreCreateToken: {Ty: reflect.TypeOf(ReceiptToken{}), Name: "LogPreCreateToken"},
TyLogFinishCreateToken: {Ty: reflect.TypeOf(ReceiptToken{}), Name: "LogFinishCreateToken"},
TyLogRevokeCreateToken: {Ty: reflect.TypeOf(ReceiptToken{}), Name: "LogRevokeCreateToken"},
}
}
......
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package types
import (
"encoding/json"
)
// RPCReplyTradeOrder : trade order
type RPCReplyTradeOrder struct {
TokenSymbol string `protobuf:"bytes,1,opt,name=tokenSymbol" json:"tokenSymbol"`
Owner string `protobuf:"bytes,2,opt,name=owner" json:"owner"`
AmountPerBoardlot int64 `protobuf:"varint,3,opt,name=amountPerBoardlot" json:"amountPerBoardlot"`
MinBoardlot int64 `protobuf:"varint,4,opt,name=minBoardlot" json:"minBoardlot"`
PricePerBoardlot int64 `protobuf:"varint,5,opt,name=pricePerBoardlot" json:"pricePerBoardlot"`
TotalBoardlot int64 `protobuf:"varint,6,opt,name=totalBoardlot" json:"totalBoardlot"`
TradedBoardlot int64 `protobuf:"varint,7,opt,name=tradedBoardlot" json:"tradedBoardlot"`
BuyID string `protobuf:"bytes,8,opt,name=buyID" json:"buyID"`
Status int32 `protobuf:"varint,9,opt,name=status" json:"status"`
SellID string `protobuf:"bytes,10,opt,name=sellID" json:"sellID"`
TxHash string `protobuf:"bytes,11,opt,name=txHash" json:"txHash"`
Height int64 `protobuf:"varint,12,opt,name=height" json:"height"`
Key string `protobuf:"bytes,13,opt,name=key" json:"key"`
BlockTime int64 `protobuf:"varint,14,opt,name=blockTime" json:"blockTime"`
IsSellOrder bool `protobuf:"varint,15,opt,name=isSellOrder" json:"isSellOrder"`
AssetExec string `protobuf:"bytes,16,opt,name=assetExec" json:"assetExec"`
}
//MarshalJSON :
func (reply *ReplyTradeOrder) MarshalJSON() ([]byte, error) {
r := (*RPCReplyTradeOrder)(reply)
return json.Marshal(r)
}
......@@ -27,12 +27,12 @@ var (
}
logInfo = map[int64]*types.LogInfo{
TyLogTradeSellLimit: {reflect.TypeOf(ReceiptTradeSellLimit{}), "LogTradeSell"},
TyLogTradeBuyMarket: {reflect.TypeOf(ReceiptTradeBuyMarket{}), "LogTradeBuyMarket"},
TyLogTradeSellRevoke: {reflect.TypeOf(ReceiptTradeSellRevoke{}), "LogTradeSellRevoke"},
TyLogTradeSellMarket: {reflect.TypeOf(ReceiptSellMarket{}), "LogTradeSellMarket"},
TyLogTradeBuyLimit: {reflect.TypeOf(ReceiptTradeBuyLimit{}), "LogTradeBuyLimit"},
TyLogTradeBuyRevoke: {reflect.TypeOf(ReceiptTradeBuyRevoke{}), "LogTradeBuyRevoke"},
TyLogTradeSellLimit: {Ty: reflect.TypeOf(ReceiptTradeSellLimit{}), Name: "LogTradeSell"},
TyLogTradeBuyMarket: {Ty: reflect.TypeOf(ReceiptTradeBuyMarket{}), Name: "LogTradeBuyMarket"},
TyLogTradeSellRevoke: {Ty: reflect.TypeOf(ReceiptTradeSellRevoke{}), Name: "LogTradeSellRevoke"},
TyLogTradeSellMarket: {Ty: reflect.TypeOf(ReceiptSellMarket{}), Name: "LogTradeSellMarket"},
TyLogTradeBuyLimit: {Ty: reflect.TypeOf(ReceiptTradeBuyLimit{}), Name: "LogTradeBuyLimit"},
TyLogTradeBuyRevoke: {Ty: reflect.TypeOf(ReceiptTradeBuyRevoke{}), Name: "LogTradeBuyRevoke"},
}
)
......
This diff is collapsed.
This diff is collapsed.
......@@ -3,24 +3,56 @@
package types
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import (
fmt "fmt"
math "math"
proto "github.com/golang/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type ValNode struct {
PubKey []byte `protobuf:"bytes,1,opt,name=pubKey,proto3" json:"pubKey,omitempty"`
Power int64 `protobuf:"varint,2,opt,name=power" json:"power,omitempty"`
Power int64 `protobuf:"varint,2,opt,name=power,proto3" json:"power,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ValNode) Reset() { *m = ValNode{} }
func (m *ValNode) String() string { return proto.CompactTextString(m) }
func (*ValNode) ProtoMessage() {}
func (*ValNode) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{0} }
func (*ValNode) Descriptor() ([]byte, []int) {
return fileDescriptor_38e9a3523ca7e0ea, []int{0}
}
func (m *ValNode) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ValNode.Unmarshal(m, b)
}
func (m *ValNode) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ValNode.Marshal(b, m, deterministic)
}
func (m *ValNode) XXX_Merge(src proto.Message) {
xxx_messageInfo_ValNode.Merge(m, src)
}
func (m *ValNode) XXX_Size() int {
return xxx_messageInfo_ValNode.Size(m)
}
func (m *ValNode) XXX_DiscardUnknown() {
xxx_messageInfo_ValNode.DiscardUnknown(m)
}
var xxx_messageInfo_ValNode proto.InternalMessageInfo
func (m *ValNode) GetPubKey() []byte {
if m != nil {
......@@ -37,13 +69,36 @@ func (m *ValNode) GetPower() int64 {
}
type ValNodes struct {
Nodes []*ValNode `protobuf:"bytes,1,rep,name=nodes" json:"nodes,omitempty"`
Nodes []*ValNode `protobuf:"bytes,1,rep,name=nodes,proto3" json:"nodes,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ValNodes) Reset() { *m = ValNodes{} }
func (m *ValNodes) String() string { return proto.CompactTextString(m) }
func (*ValNodes) ProtoMessage() {}
func (*ValNodes) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{1} }
func (*ValNodes) Descriptor() ([]byte, []int) {
return fileDescriptor_38e9a3523ca7e0ea, []int{1}
}
func (m *ValNodes) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ValNodes.Unmarshal(m, b)
}
func (m *ValNodes) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ValNodes.Marshal(b, m, deterministic)
}
func (m *ValNodes) XXX_Merge(src proto.Message) {
xxx_messageInfo_ValNodes.Merge(m, src)
}
func (m *ValNodes) XXX_Size() int {
return xxx_messageInfo_ValNodes.Size(m)
}
func (m *ValNodes) XXX_DiscardUnknown() {
xxx_messageInfo_ValNodes.DiscardUnknown(m)
}
var xxx_messageInfo_ValNodes proto.InternalMessageInfo
func (m *ValNodes) GetNodes() []*ValNode {
if m != nil {
......@@ -57,26 +112,51 @@ type ValNodeAction struct {
// *ValNodeAction_Node
// *ValNodeAction_BlockInfo
Value isValNodeAction_Value `protobuf_oneof:"value"`
Ty int32 `protobuf:"varint,3,opt,name=Ty" json:"Ty,omitempty"`
Ty int32 `protobuf:"varint,3,opt,name=Ty,proto3" json:"Ty,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ValNodeAction) Reset() { *m = ValNodeAction{} }
func (m *ValNodeAction) String() string { return proto.CompactTextString(m) }
func (*ValNodeAction) ProtoMessage() {}
func (*ValNodeAction) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{2} }
func (*ValNodeAction) Descriptor() ([]byte, []int) {
return fileDescriptor_38e9a3523ca7e0ea, []int{2}
}
func (m *ValNodeAction) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ValNodeAction.Unmarshal(m, b)
}
func (m *ValNodeAction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ValNodeAction.Marshal(b, m, deterministic)
}
func (m *ValNodeAction) XXX_Merge(src proto.Message) {
xxx_messageInfo_ValNodeAction.Merge(m, src)
}
func (m *ValNodeAction) XXX_Size() int {
return xxx_messageInfo_ValNodeAction.Size(m)
}
func (m *ValNodeAction) XXX_DiscardUnknown() {
xxx_messageInfo_ValNodeAction.DiscardUnknown(m)
}
var xxx_messageInfo_ValNodeAction proto.InternalMessageInfo
type isValNodeAction_Value interface {
isValNodeAction_Value()
}
type ValNodeAction_Node struct {
Node *ValNode `protobuf:"bytes,1,opt,name=node,oneof"`
Node *ValNode `protobuf:"bytes,1,opt,name=node,proto3,oneof"`
}
type ValNodeAction_BlockInfo struct {
BlockInfo *TendermintBlockInfo `protobuf:"bytes,2,opt,name=blockInfo,oneof"`
BlockInfo *TendermintBlockInfo `protobuf:"bytes,2,opt,name=blockInfo,proto3,oneof"`
}
func (*ValNodeAction_Node) isValNodeAction_Value() {}
func (*ValNodeAction_BlockInfo) isValNodeAction_Value() {}
func (m *ValNodeAction) GetValue() isValNodeAction_Value {
......@@ -166,12 +246,12 @@ func _ValNodeAction_OneofSizer(msg proto.Message) (n int) {
switch x := m.Value.(type) {
case *ValNodeAction_Node:
s := proto.Size(x.Node)
n += proto.SizeVarint(1<<3 | proto.WireBytes)
n += 1 // tag and wire
n += proto.SizeVarint(uint64(s))
n += s
case *ValNodeAction_BlockInfo:
s := proto.Size(x.BlockInfo)
n += proto.SizeVarint(2<<3 | proto.WireBytes)
n += 1 // tag and wire
n += proto.SizeVarint(uint64(s))
n += s
case nil:
......@@ -182,13 +262,36 @@ func _ValNodeAction_OneofSizer(msg proto.Message) (n int) {
}
type ReqNodeInfo struct {
Height int64 `protobuf:"varint,1,opt,name=height" json:"height,omitempty"`
Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ReqNodeInfo) Reset() { *m = ReqNodeInfo{} }
func (m *ReqNodeInfo) String() string { return proto.CompactTextString(m) }
func (*ReqNodeInfo) ProtoMessage() {}
func (*ReqNodeInfo) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{3} }
func (*ReqNodeInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_38e9a3523ca7e0ea, []int{3}
}
func (m *ReqNodeInfo) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ReqNodeInfo.Unmarshal(m, b)
}
func (m *ReqNodeInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ReqNodeInfo.Marshal(b, m, deterministic)
}
func (m *ReqNodeInfo) XXX_Merge(src proto.Message) {
xxx_messageInfo_ReqNodeInfo.Merge(m, src)
}
func (m *ReqNodeInfo) XXX_Size() int {
return xxx_messageInfo_ReqNodeInfo.Size(m)
}
func (m *ReqNodeInfo) XXX_DiscardUnknown() {
xxx_messageInfo_ReqNodeInfo.DiscardUnknown(m)
}
var xxx_messageInfo_ReqNodeInfo proto.InternalMessageInfo
func (m *ReqNodeInfo) GetHeight() int64 {
if m != nil {
......@@ -198,13 +301,36 @@ func (m *ReqNodeInfo) GetHeight() int64 {
}
type ReqBlockInfo struct {
Height int64 `protobuf:"varint,1,opt,name=height" json:"height,omitempty"`
Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ReqBlockInfo) Reset() { *m = ReqBlockInfo{} }
func (m *ReqBlockInfo) String() string { return proto.CompactTextString(m) }
func (*ReqBlockInfo) ProtoMessage() {}
func (*ReqBlockInfo) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{4} }
func (*ReqBlockInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_38e9a3523ca7e0ea, []int{4}
}
func (m *ReqBlockInfo) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ReqBlockInfo.Unmarshal(m, b)
}
func (m *ReqBlockInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ReqBlockInfo.Marshal(b, m, deterministic)
}
func (m *ReqBlockInfo) XXX_Merge(src proto.Message) {
xxx_messageInfo_ReqBlockInfo.Merge(m, src)
}
func (m *ReqBlockInfo) XXX_Size() int {
return xxx_messageInfo_ReqBlockInfo.Size(m)
}
func (m *ReqBlockInfo) XXX_DiscardUnknown() {
xxx_messageInfo_ReqBlockInfo.DiscardUnknown(m)
}
var xxx_messageInfo_ReqBlockInfo proto.InternalMessageInfo
func (m *ReqBlockInfo) GetHeight() int64 {
if m != nil {
......@@ -221,9 +347,9 @@ func init() {
proto.RegisterType((*ReqBlockInfo)(nil), "types.ReqBlockInfo")
}
func init() { proto.RegisterFile("valnode.proto", fileDescriptor1) }
func init() { proto.RegisterFile("valnode.proto", fileDescriptor_38e9a3523ca7e0ea) }
var fileDescriptor1 = []byte{
var fileDescriptor_38e9a3523ca7e0ea = []byte{
// 261 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x90, 0x41, 0x4b, 0xc3, 0x30,
0x14, 0xc7, 0x97, 0xd6, 0x74, 0xfa, 0xba, 0x0d, 0x09, 0x32, 0xca, 0x4e, 0x25, 0x4c, 0xe9, 0xa9,
......
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