Commit 96ecc075 authored by 张振华's avatar 张振华

update

parent f94e04d5
// 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 main
import (
"io/ioutil"
"os"
"time"
"fmt"
"github.com/33cn/chain33/common"
drivers "github.com/33cn/chain33/system/store"
"github.com/33cn/chain33/types"
kvm "github.com/33cn/plugin/plugin/store/kvmvcc"
)
const MaxKeylenth int = 64
func newStoreCfg(dir string) *types.Store {
return &types.Store{Name: "kvmvcc_test", Driver: "leveldb", DbPath: dir, DbCache: 100}
}
func GetRandomString(length int) string {
return common.GetRandPrintString(20, length)
}
func main() {
dir, _ := ioutil.TempDir("", "kvmvcc")
//defer os.RemoveAll(dir) // clean up
os.RemoveAll(dir) //删除已存在目录
var storeCfg = newStoreCfg(dir)
store := kvm.New(storeCfg, nil).(*kvm.KVMVCCStore)
var kv []*types.KeyValue
var key string
var value string
var keys [][]byte
for i := 0; i < 20; i++ {
key = GetRandomString(MaxKeylenth)
value = fmt.Sprintf("vabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst%d", i)
keys = append(keys, []byte(string(key)))
kv = append(kv, &types.KeyValue{Key: []byte(string(key)), Value: []byte(string(value))})
}
datas := &types.StoreSet{
StateHash: drivers.EmptyRoot[:],
KV: kv,
Height: 0}
var hashes [][]byte
blocks := 50000
times := 10000
start1 := time.Now()
for i := 0; i < blocks; i++ {
datas.Height = int64(i)
value = fmt.Sprintf("vvabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst%d", i)
for j := 0; j < 20; j++ {
datas.KV[j].Value = []byte(value)
}
hash, err := store.MemSet(datas, true)
if err != nil {
fmt.Println("MemSet failed", err)
}
req := &types.ReqHash{
Hash: hash,
}
_, err = store.Commit(req)
if err != nil {
fmt.Println("Commit failed", err)
}
datas.StateHash = hash
if i < times {
hashes = append(hashes, hash)
}
fmt.Println("Block number:", i)
}
end1 := time.Now()
start := time.Now()
getData := &types.StoreGet{
StateHash: hashes[0],
Keys: keys}
for i := 0; i < times; i++ {
getData.StateHash = hashes[i]
store.Get(getData)
fmt.Println("read times:", i, " kv numbers:", i * 20)
}
end := time.Now()
fmt.Println("kvmvcc BenchmarkStoreGetKvsFor100million MemSet&Commit cost time is ", end1.Sub(start1), "blocks is", blocks)
fmt.Println("kvmvcc BenchmarkStoreGetKvsFor100million Get cost time is", end.Sub(start), "num is ", times, ",blocks is ", blocks)
}
// 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 main
import (
"io/ioutil"
"os"
"time"
"fmt"
"github.com/33cn/chain33/common"
drivers "github.com/33cn/chain33/system/store"
"github.com/33cn/chain33/types"
mavl "github.com/33cn/chain33/system/store/mavl"
)
const MaxKeylenth int = 64
func newStoreCfg(dir string) *types.Store {
return &types.Store{Name: "mavl_test", Driver: "leveldb", DbPath: dir, DbCache: 100}
}
func GetRandomString(length int) string {
return common.GetRandPrintString(20, length)
}
func main() {
dir, _ := ioutil.TempDir("", "mavl")
//defer os.RemoveAll(dir) // clean up
os.RemoveAll(dir) //删除已存在目录
var storeCfg = newStoreCfg(dir)
store := mavl.New(storeCfg, nil).(*mavl.Store)
var kv []*types.KeyValue
var key string
var value string
var keys [][]byte
for i := 0; i < 20; i++ {
key = GetRandomString(MaxKeylenth)
value = fmt.Sprintf("vabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst%d", i)
keys = append(keys, []byte(string(key)))
kv = append(kv, &types.KeyValue{Key: []byte(string(key)), Value: []byte(string(value))})
}
datas := &types.StoreSet{
StateHash: drivers.EmptyRoot[:],
KV: kv,
Height: 0}
var hashes [][]byte
blocks := 50000
times := 10000
start1 := time.Now()
for i := 0; i < blocks; i++ {
datas.Height = int64(i)
value = fmt.Sprintf("vvabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst%d", i)
for j := 0; j < 20; j++ {
datas.KV[j].Value = []byte(value)
}
hash, err := store.MemSet(datas, true)
if err != nil {
fmt.Println("MemSet failed", err)
}
req := &types.ReqHash{
Hash: hash,
}
_, err = store.Commit(req)
if err != nil {
fmt.Println("Commit failed", err)
}
datas.StateHash = hash
if i < times {
hashes = append(hashes, hash)
}
fmt.Println("Block number:", i)
}
end1 := time.Now()
start := time.Now()
getData := &types.StoreGet{
StateHash: hashes[0],
Keys: keys}
for i := 0; i < times; i++ {
getData.StateHash = hashes[i]
store.Get(getData)
fmt.Println("read times:", i, " kv numbers:", i * 20)
}
end := time.Now()
fmt.Println("mavl BenchmarkStoreGetKvsFor100million MemSet&Commit cost time is ", end1.Sub(start1), "blocks is", blocks)
fmt.Println("mavl BenchmarkStoreGetKvsFor100million Get cost time is", end.Sub(start), "num is ", times, ",blocks is ", blocks)
}
// 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 main
import (
"io/ioutil"
"os"
"time"
"fmt"
"github.com/33cn/chain33/common"
drivers "github.com/33cn/chain33/system/store"
"github.com/33cn/chain33/types"
mpt "github.com/33cn/plugin/plugin/store/mpt"
)
const MaxKeylenth int = 64
func newStoreCfg(dir string) *types.Store {
return &types.Store{Name: "mpt_test", Driver: "leveldb", DbPath: dir, DbCache: 100}
}
func GetRandomString(length int) string {
return common.GetRandPrintString(20, length)
}
func main() {
dir, _ := ioutil.TempDir("", "mpt")
//defer os.RemoveAll(dir) // clean up
os.RemoveAll(dir) //删除已存在目录
var storeCfg = newStoreCfg(dir)
store := mpt.New(storeCfg, nil).(*mpt.Store)
var kv []*types.KeyValue
var key string
var value string
var keys [][]byte
for i := 0; i < 20; i++ {
key = GetRandomString(MaxKeylenth)
value = fmt.Sprintf("vabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst%d", i)
keys = append(keys, []byte(string(key)))
kv = append(kv, &types.KeyValue{Key: []byte(string(key)), Value: []byte(string(value))})
}
datas := &types.StoreSet{
StateHash: drivers.EmptyRoot[:],
KV: kv,
Height: 0}
var hashes [][]byte
blocks := 50000
times := 10000
start1 := time.Now()
for i := 0; i < blocks; i++ {
datas.Height = int64(i)
value = fmt.Sprintf("vvabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst%d", i)
for j := 0; j < 20; j++ {
datas.KV[j].Value = []byte(value)
}
hash, err := store.MemSet(datas, true)
if err != nil {
fmt.Println("MemSet failed", err)
}
req := &types.ReqHash{
Hash: hash,
}
_, err = store.Commit(req)
if err != nil {
fmt.Println("Commit failed", err)
}
datas.StateHash = hash
if i < times {
hashes = append(hashes, hash)
}
fmt.Println("Block number:", i)
}
end1 := time.Now()
start := time.Now()
getData := &types.StoreGet{
StateHash: hashes[0],
Keys: keys}
for i := 0; i < times; i++ {
getData.StateHash = hashes[i]
store.Get(getData)
fmt.Println("read times:", i, " kv numbers:", i * 20)
}
end := time.Now()
fmt.Println("mpt BenchmarkStoreGetKvsFor100million MemSet&Commit cost time is ", end1.Sub(start1), "blocks is", blocks)
fmt.Println("mpt BenchmarkStoreGetKvsFor100million Get cost time is", end.Sub(start), "num is ", times, ",blocks is ", blocks)
}
......@@ -100,6 +100,7 @@ timeoutWaitNotify=2000
createEmptyBlocks=false
createEmptyBlocksInterval=0
validatorNodes=["127.0.0.1:46656"]
delegateNum=3
blockInterval=3
continueBlockNum=12
isValidator=false
......
......@@ -18,7 +18,7 @@ import (
ttypes "github.com/33cn/plugin/plugin/consensus/dpos/types"
)
const tendermintVersion = "0.1.0"
const dposVersion = "0.1.0"
var (
dposlog = log15.New("module", "dpos")
......@@ -38,6 +38,7 @@ var (
dposCycle = dposDelegateNum * dposBlockInterval * dposContinueBlockNum
dposPeriod = dposBlockInterval * dposContinueBlockNum
zeroHash [32]byte
dposPort string = "36656"
)
func init() {
......@@ -70,9 +71,11 @@ type subConfig struct {
CreateEmptyBlocks bool `json:"createEmptyBlocks"`
CreateEmptyBlocksInterval int32 `json:"createEmptyBlocksInterval"`
ValidatorNodes []string `json:"validatorNodes"`
DelegateNum int64 `json:"delegateNum"`
BlockInterval int64 `json:"blockInterval"`
ContinueBlockNum int64 `json:"continueBlockNum"`
IsValidator bool `json:"isValidator"`
Port string `json:"port"`
}
func (client *Client) applyConfig(sub []byte) {
......@@ -100,9 +103,13 @@ func (client *Client) applyConfig(sub []byte) {
createEmptyBlocksInterval = subcfg.CreateEmptyBlocksInterval
}
if subcfg.DelegateNum > 0 {
dposDelegateNum = subcfg.DelegateNum
}
if len(subcfg.ValidatorNodes) > 0 {
validatorNodes = subcfg.ValidatorNodes
dposDelegateNum = int64(len(subcfg.ValidatorNodes))
//dposDelegateNum = int64(len(subcfg.ValidatorNodes))
}
if subcfg.BlockInterval > 0 {
......@@ -113,6 +120,9 @@ func (client *Client) applyConfig(sub []byte) {
dposContinueBlockNum = subcfg.ContinueBlockNum
}
if subcfg.Port != "" {
dposPort = subcfg.Port
}
dposCycle = dposDelegateNum * dposBlockInterval * dposContinueBlockNum
dposPeriod = dposBlockInterval * dposContinueBlockNum
......@@ -137,7 +147,8 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
//return nil
}
cr, err := crypto.New(types.GetSignName("", types.ED25519))
//为了使用VRF,需要使用SECP256K1体系的公私钥
cr, err := crypto.New(types.GetSignName("", types.SECP256K1))
if err != nil {
dposlog.Error("NewDPosClient", "err", err)
return nil
......@@ -145,7 +156,15 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
ttypes.ConsensusCrypto = cr
priv, err := cr.GenKey()
//安全连接仍然要使用ed25519
cr2, err := crypto.New(types.GetSignName("", types.ED25519))
if err != nil {
dposlog.Error("NewDPosClient", "err", err)
return nil
}
ttypes.SecureConnCrypto = cr2
priv, err := cr2.GenKey()
if err != nil {
dposlog.Error("NewDPosClient", "GenKey err", err)
return nil
......@@ -262,8 +281,8 @@ OuterLoop:
csState.SetPrivValidator(client.privValidator, client.ValidatorIndex())
// Create & add listener
protocol, listeningAddress := "tcp", "0.0.0.0:36656"
node := NewNode(validatorNodes, protocol, listeningAddress, client.privKey, valMgr.ChainID, tendermintVersion, csState)
protocol, listeningAddress := "tcp", "0.0.0.0:" + dposPort
node := NewNode(validatorNodes, protocol, listeningAddress, client.privKey, valMgr.ChainID, dposVersion, csState)
client.node = node
......
......@@ -301,11 +301,11 @@ func shareAuthSignature(sc io.ReadWriter, pubKey crypto.PubKey, signature crypto
//n := int(0) // not used.
//recvMsg = wire.ReadBinary(authSigMessage{}, bytes.NewBuffer(readBuffer), authSigMsgSize, &n, &err2).(authSigMessage)
//secret.Info("shareAuthSignature", "readBuffer", readBuffer)
recvMsg.Key, err2 = types.ConsensusCrypto.PubKeyFromBytes(readBuffer[:32])
recvMsg.Key, err2 = types.SecureConnCrypto.PubKeyFromBytes(readBuffer[:32])
if err2 != nil {
return
}
recvMsg.Sig, err2 = types.ConsensusCrypto.SignatureFromBytes(readBuffer[32:])
recvMsg.Sig, err2 = types.SecureConnCrypto.SignatureFromBytes(readBuffer[32:])
if err2 != nil {
return
}
......
......@@ -252,8 +252,8 @@ func (pv *PrivValidatorImp) save() {
Address: addr,
LastSignature: nil,
}
privValFS.PrivKey = KeyText{Kind: "ed25519", Data: Fmt("%X", pv.PrivKey.Bytes()[:])}
privValFS.PubKey = KeyText{Kind: "ed25519", Data: pv.PubKey.KeyString()}
privValFS.PrivKey = KeyText{Kind: "secp256k1", Data: Fmt("%X", pv.PrivKey.Bytes()[:])}
privValFS.PubKey = KeyText{Kind: "secp256k1", Data: pv.PubKey.KeyString()}
if len(pv.LastSignBytes) != 0 {
tmp := Fmt("%X", pv.LastSignBytes[:])
privValFS.LastSignBytes = tmp
......
......@@ -9,6 +9,7 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/33cn/chain33/common/address"
"io"
"time"
......@@ -30,6 +31,7 @@ var (
votelog = log15.New("module", "tendermint-vote")
ConsensusCrypto crypto.Crypto
SecureConnCrypto crypto.Crypto
)
// Signable is an interface for all signable things.
......@@ -102,7 +104,7 @@ func (vote *Vote) String() string {
// Verify ...
func (vote *Vote) Verify(chainID string, pubKey crypto.PubKey) error {
addr := GenAddressByPubKey(pubKey)
addr := address.PubKeyToAddress(pubKey.Bytes()).Hash160[:]
if !bytes.Equal(addr, vote.VoterNodeAddress) {
return ErrVoteInvalidValidatorAddress
}
......@@ -189,7 +191,7 @@ func (notify *Notify) String() string {
// Verify ...
func (notify *Notify) Verify(chainID string, pubKey crypto.PubKey) error {
addr := GenAddressByPubKey(pubKey)
addr := address.PubKeyToAddress(pubKey.Bytes()).Hash160[:]
if !bytes.Equal(addr, notify.NotifyNodeAddress) {
return ErrNotifyInvalidValidatorAddress
}
......
......@@ -8,6 +8,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/33cn/chain33/common/address"
"math/rand"
ttypes "github.com/33cn/plugin/plugin/consensus/dpos/types"
......@@ -85,7 +86,7 @@ func MakeGenesisValidatorMgr(genDoc *ttypes.GenesisDoc) (ValidatorMgr, error) {
// Make validator
validators[i] = &ttypes.Validator{
Address: ttypes.GenAddressByPubKey(pubKey),
Address: address.PubKeyToAddress(pubKey.Bytes()).Hash160[:],
PubKey: pubKey.Bytes(),
}
}
......
all:
chmod +x ./build.sh
./build.sh $(OUT) $(FLAG)
\ No newline at end of file
#!/usr/bin/env bash
strpwd=$(pwd)
strcmd=${strpwd##*dapp/}
strapp=${strcmd%/cmd*}
OUT_DIR="${1}/$strapp"
#FLAG=$2
mkdir -p "${OUT_DIR}"
cp ./build/* "${OUT_DIR}"
OUT_TESTDIR="${1}/dapptest/$strapp"
mkdir -p "${OUT_TESTDIR}"
chmod +x ./build/test-rpc.sh
cp ./build/test-rpc.sh "${OUT_TESTDIR}"
#!/usr/bin/env bash
# shellcheck disable=SC2128
set -e
set -o pipefail
MAIN_HTTP=""
# shellcheck source=/dev/null
source ../dapp-test-common.sh
MAIN_HTTP=""
CASE_ERR=""
guess_admin_addr=12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
guess_user1_addr=1PUiGcbsccfxW3zuvHXZBJfznziph5miAo
guess_user2_addr=1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX
guess_addr=""
guess_exec=""
eventId=""
txhash=""
#color
RED='\033[1;31m'
GRE='\033[1;32m'
NOC='\033[0m'
guess_game_start() {
echo "========== # guess start tx begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"guess","actionName":"Start", "payload":{"topic":"WorldCup Final","options":"A:France;B:Claodia","category":"football","maxBetsOneTime":10000000000,"maxBetsNumber":100000000000,"devFeeFactor":5,"devFeeAddr":"1D6RFZNp2rh6QdbcZ1d7RWuBUz61We6SD7","platFeeFactor":5,"platFeeAddr":"1PHtChNt3UcfssR7v7trKSk3WJtAWjKjjX"}}]}' ${MAIN_HTTP} | jq -r ".result")
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01" ${MAIN_HTTP}
eventId="${txhash}"
echo "eventId $eventId"
echo "========== # guess start tx end =========="
chain33_BlockWait 1 ${MAIN_HTTP}
}
guess_game_bet() {
local priv=$1
local opt=$2
echo "========== # guess bet tx begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"guess","actionName":"Bet", "payload":{"gameID":"'"${eventId}"'","option":"'"${opt}"'", "betsNum":500000000}}]}' ${MAIN_HTTP} | jq -r ".result")
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "${priv}" ${MAIN_HTTP}
echo "========== # guess bet tx end =========="
chain33_BlockWait 1 ${MAIN_HTTP}
}
guess_game_stop() {
echo "========== # guess stop tx begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"guess","actionName":"StopBet", "payload":{"gameID":"'"${eventId}"'"}}]}' ${MAIN_HTTP} | jq -r ".result")
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01" ${MAIN_HTTP}
echo "========== # guess stop tx end =========="
chain33_BlockWait 1 ${MAIN_HTTP}
}
guess_game_publish() {
echo "========== # guess publish tx begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"guess","actionName":"Publish", "payload":{"gameID":"'"${eventId}"'","result":"A"}}]}' ${MAIN_HTTP} | jq -r ".result")
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01" ${MAIN_HTTP}
echo "========== # guess publish tx end =========="
chain33_BlockWait 1 ${MAIN_HTTP}
}
guess_game_abort() {
echo "========== # guess abort tx begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"guess","actionName":"Abort", "payload":{"gameID":"'"${eventId}"'"}}]}' ${MAIN_HTTP} | jq -r ".result")
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01" ${MAIN_HTTP}
echo "========== # guess abort tx end =========="
chain33_BlockWait 1 ${MAIN_HTTP}
}
guess_QueryGameByID() {
local event_id=$1
local status=$2
echo "========== # guess QueryGameByID begin =========="
local req='"method":"Chain33.Query", "params":[{"execer":"guess","funcName":"QueryGameByID","payload":{"gameID":"'"$event_id"'"}}]'
#echo "#request: $req"
resp=$(curl -ksd "{$req}" ${MAIN_HTTP})
echo "#response: $resp"
ok=$(jq '(.result|has("game")) and (.result.game.status == '"$status"')' <<<"$resp")
[ "$ok" == true ]
rst=$?
echo_rst "$FUNCNAME" "$rst"
echo "========== # guess QueryGameByID end =========="
}
init() {
ispara=$(echo '"'"${MAIN_HTTP}"'"' | jq '.|contains("8901")')
echo "ipara=$ispara"
if [ "$ispara" == true ]; then
guess_addr=$(curl -ksd '{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"user.p.para.guess"}]}' ${MAIN_HTTP} | jq -r ".result")
guess_exec="user.p.para.guess"
else
guess_addr=$(curl -ksd '{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"guess"}]}' ${MAIN_HTTP} | jq -r ".result")
guess_exec="guess"
fi
echo "guess_addr=$guess_addr"
local from="1PUiGcbsccfxW3zuvHXZBJfznziph5miAo"
chain33_SendToAddress "$from" "$guess_addr" 10000000000 ${MAIN_HTTP}
from="1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX"
chain33_SendToAddress "$from" "$guess_addr" 10000000000 ${MAIN_HTTP}
chain33_BlockWait 1 "${MAIN_HTTP}"
}
function run_test() {
#导入地址私钥
chain33_ImportPrivkey "56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138" "1PUiGcbsccfxW3zuvHXZBJfznziph5miAo" "user1" "$MAIN_HTTP"
chain33_ImportPrivkey "2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989" "1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX" "user2" "$MAIN_HTTP"
chain33_ImportPrivkey "4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01" "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv" "admin" "$MAIN_HTTP"
chain33_QueryBalance "${guess_admin_addr}" "$MAIN_HTTP"
chain33_QueryBalance "${guess_user1_addr}" "$MAIN_HTTP"
chain33_QueryBalance "${guess_user2_addr}" "$MAIN_HTTP"
chain33_QueryExecBalance "${guess_user1_addr}" "${guess_exec}" "$MAIN_HTTP"
chain33_QueryExecBalance "${guess_user2_addr}" "${guess_exec}" "$MAIN_HTTP"
#场景1:start -> bet -> bet -> stop -> publish
#管理员创建游戏
guess_game_start
#查询游戏状态
guess_QueryGameByID "$eventId" 11
#用户1下注
guess_game_bet "56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138" "A"
#查询游戏状态
guess_QueryGameByID "$eventId" 12
#用户2下注
guess_game_bet "2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989" "B"
#查询游戏状态
guess_QueryGameByID "$eventId" 12
#管理员停止下注
guess_game_stop
#查询游戏状态
guess_QueryGameByID "$eventId" 13
#管理员发布结果
guess_game_publish
#查询游戏状态
guess_QueryGameByID "$eventId" 15
#查询余额
chain33_QueryExecBalance "${guess_user1_addr}" "${guess_exec}" "$MAIN_HTTP"
chain33_QueryExecBalance "${guess_user2_addr}" "${guess_exec}" "$MAIN_HTTP"
#场景2:start->stop->abort
guess_game_start
#查询游戏状态
guess_QueryGameByID "$eventId" 11
#管理员停止下注
guess_game_stop
#查询游戏状态
guess_QueryGameByID "$eventId" 13
#管理员发布结果
guess_game_abort
#查询游戏状态
guess_QueryGameByID "$eventId" 14
#场景3:start->abort
guess_game_start
#查询游戏状态
guess_QueryGameByID "$eventId" 11
#管理员发布结果
guess_game_abort
#查询游戏状态
guess_QueryGameByID "$eventId" 14
#场景4:start->bet->abort
#管理员创建游戏
guess_game_start
#查询游戏状态
guess_QueryGameByID "$eventId" 11
#用户1下注
guess_game_bet "56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138" "A"
#查询游戏状态
guess_QueryGameByID "$eventId" 12
#用户2下注
guess_game_bet "2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989" "B"
#查询游戏状态
guess_QueryGameByID "$eventId" 12
#管理员发布结果
guess_game_abort
#查询游戏状态
guess_QueryGameByID "$eventId" 14
#场景5:start->bet->stop->abort
#管理员创建游戏
guess_game_start
#查询游戏状态
guess_QueryGameByID "$eventId" 11
#用户1下注
guess_game_bet "56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138" "A"
#查询游戏状态
guess_QueryGameByID "$eventId" 12
#用户2下注
guess_game_bet "2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989" "B"
#查询游戏状态
guess_QueryGameByID "$eventId" 12
#管理员停止下注
guess_game_stop
#查询游戏状态
guess_QueryGameByID "$eventId" 13
#管理员发布结果
guess_game_abort
#查询游戏状态
guess_QueryGameByID "$eventId" 14
#查询余额
chain33_QueryExecBalance "${guess_user1_addr}" "${guess_exec}" "$MAIN_HTTP"
chain33_QueryExecBalance "${guess_user2_addr}" "${guess_exec}" "$MAIN_HTTP"
}
function main() {
MAIN_HTTP="$1"
echo "main_ip=$MAIN_HTTP"
init
echo "=========== # guess rpc test start============="
run_test
if [ -n "$CASE_ERR" ]; then
echo -e "${RED}=============Guess Rpc Test Fail=============${NOC}"
exit 1
else
echo -e "${GRE}=============Guess Rpc Test Pass==============${NOC}"
fi
echo "=========== # guess rpc test end============="
}
main "$1"
// 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 commands
import (
"fmt"
"strings"
"time"
jsonrpc "github.com/33cn/chain33/rpc/jsonclient"
rpctypes "github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types"
dty "github.com/33cn/plugin/plugin/dapp/dposvote/types"
"github.com/spf13/cobra"
)
//DPosCmd DPosVote合约命令行
func DPosCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "dpos",
Short: "dpos vote management",
Args: cobra.MinimumNArgs(1),
}
cmd.AddCommand(
DPosRegistCmd(),
DPosCancelRegistCmd(),
DPosVoteCmd(),
DPosReRegistCmd(),
DPosVoteCancelCmd(),
DPosCandidatorQueryCmd(),
DPosVoteQueryCmd(),
DPosVrfMRegistCmd(),
DPosVrfRPRegistCmd(),
DPosVrfQueryCmd(),
)
return cmd
}
//DPosRegistCmd 构造候选节点注册的命令行
func DPosRegistCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "regist",
Short: "regist a new candidator",
Run: regist,
}
addRegistFlags(cmd)
return cmd
}
func addRegistFlags(cmd *cobra.Command) {
cmd.Flags().StringP("pubkey", "k", "", "pubkey")
cmd.MarkFlagRequired("pubkey")
cmd.Flags().StringP("address", "a", "", "address")
cmd.MarkFlagRequired("address")
cmd.Flags().StringP("ip", "i", "", "ip")
cmd.MarkFlagRequired("address")
}
func regist(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
pubkey, _ := cmd.Flags().GetString("pubkey")
address, _ := cmd.Flags().GetString("address")
ip, _ := cmd.Flags().GetString("ip")
payload := fmt.Sprintf("{\"pubkey\":\"%s\", \"address\":\"%s\", \"ip\":\"%s\"}", pubkey, address, ip)
params := &rpctypes.CreateTxIn{
Execer: types.ExecName(dty.DPosX),
ActionName: dty.CreateRegistTx,
Payload: []byte(payload),
}
var res string
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.CreateTransaction", params, &res)
ctx.RunWithoutMarshal()
}
//DPosCancelRegistCmd 构造候选节点去注册的命令行
func DPosCancelRegistCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "cancelRegist",
Short: "cancel regist for a candidator",
Run: cancelRegist,
}
addCancelRegistFlags(cmd)
return cmd
}
func addCancelRegistFlags(cmd *cobra.Command) {
cmd.Flags().StringP("pubkey", "k", "", "pubkey")
cmd.MarkFlagRequired("pubkey")
cmd.Flags().StringP("address", "a", "", "address")
cmd.MarkFlagRequired("address")
}
func cancelRegist(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
pubkey, _ := cmd.Flags().GetString("pubkey")
address, _ := cmd.Flags().GetString("address")
payload := fmt.Sprintf("{\"pubkey\":\"%s\", \"address\":\"%s\"}", pubkey, address)
params := &rpctypes.CreateTxIn{
Execer: types.ExecName(dty.DPosX),
ActionName: dty.CreateCancelRegistTx,
Payload: []byte(payload),
}
var res string
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.CreateTransaction", params, &res)
ctx.RunWithoutMarshal()
}
//DPosVoteCmd 构造为候选节点投票的命令行
func DPosVoteCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "vote",
Short: "vote for one candidator",
Run: vote,
}
addVoteFlags(cmd)
return cmd
}
func addVoteFlags(cmd *cobra.Command) {
cmd.Flags().StringP("pubkey", "k", "", "pubkey of a candidator")
cmd.MarkFlagRequired("pubkey")
cmd.Flags().Int64P("votes", "v", 0, "votes")
cmd.MarkFlagRequired("votes")
}
func vote(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
pubkey, _ := cmd.Flags().GetString("pubkey")
votes, _ := cmd.Flags().GetInt64("votes")
payload := fmt.Sprintf("{\"pubkey\":\"%s\", \"votes\":\"%d\"}", pubkey, votes)
params := &rpctypes.CreateTxIn{
Execer: types.ExecName(dty.DPosX),
ActionName: dty.CreateVoteTx,
Payload: []byte(payload),
}
var res string
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.CreateTransaction", params, &res)
ctx.RunWithoutMarshal()
}
//DPosVoteCancelCmd 构造撤销对候选节点投票的命令行
func DPosVoteCancelCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "cancelVote",
Short: "cancel votes to a candidator",
Run: cancelVote,
}
addCancelVoteFlags(cmd)
return cmd
}
func addCancelVoteFlags(cmd *cobra.Command) {
cmd.Flags().StringP("pubkey", "k", "", "pubkey of a candidator")
cmd.MarkFlagRequired("pubkey")
cmd.Flags().Int64P("votes", "v", 0, "votes")
cmd.MarkFlagRequired("votes")
}
func cancelVote(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
pubkey, _ := cmd.Flags().GetString("pubkey")
votes, _ := cmd.Flags().GetInt64("votes")
payload := fmt.Sprintf("{\"pubkey\":\"%s\", \"votes\":\"%d\"}", pubkey, votes)
params := &rpctypes.CreateTxIn{
Execer: types.ExecName(dty.DPosX),
ActionName: dty.CreateCancelVoteTx,
Payload: []byte(payload),
}
var res string
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.CreateTransaction", params, &res)
ctx.RunWithoutMarshal()
}
//DPosReRegistCmd 构造重新注册候选节点的命令行
func DPosReRegistCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "reRegist",
Short: "re regist a canceled candidator",
Run: reRegist,
}
addReRegistFlags(cmd)
return cmd
}
func addReRegistFlags(cmd *cobra.Command) {
cmd.Flags().StringP("pubkey", "k", "", "pubkey")
cmd.MarkFlagRequired("pubkey")
cmd.Flags().StringP("address", "a", "", "address")
cmd.MarkFlagRequired("address")
cmd.Flags().StringP("ip", "i", "", "ip")
cmd.MarkFlagRequired("address")
}
func reRegist(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
pubkey, _ := cmd.Flags().GetString("pubkey")
address, _ := cmd.Flags().GetString("address")
ip, _ := cmd.Flags().GetString("ip")
payload := fmt.Sprintf("{\"pubkey\":\"%s\", \"address\":\"%s\", \"ip\":\"%s\"}", pubkey, address, ip)
params := &rpctypes.CreateTxIn{
Execer: types.ExecName(dty.DPosX),
ActionName: dty.CreateReRegistTx,
Payload: []byte(payload),
}
var res string
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.CreateTransaction", params, &res)
ctx.RunWithoutMarshal()
}
//DPosCandidatorQueryCmd 构造查询候选节点信息的命令行
func DPosCandidatorQueryCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "candidatorQuery",
Short: "query candidator info",
Run: candidatorQuery,
}
addCandidatorQueryFlags(cmd)
return cmd
}
func addCandidatorQueryFlags(cmd *cobra.Command) {
cmd.Flags().StringP("type", "t", "", "topN/pubkeys")
cmd.Flags().Int64P("top", "n", 0, "top N by votes")
cmd.Flags().StringP("pubkeys", "k", "", "pubkeys")
}
func candidatorQuery(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
ty, _ := cmd.Flags().GetString("type")
pubkeys, _ := cmd.Flags().GetString("pubkeys")
topN, _ := cmd.Flags().GetInt64("top")
var params rpctypes.Query4Jrpc
params.Execer = dty.DPosX
switch ty {
case "topN":
req := &dty.CandidatorQuery{
TopN: int32(topN),
}
params.FuncName = dty.FuncNameQueryCandidatorByTopN
params.Payload = types.MustPBToJSON(req)
var res dty.CandidatorReply
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.Run()
case "pubkeys":
keys := strings.Split(pubkeys, ";")
req := &dty.CandidatorQuery{
}
for _, key := range keys {
req.Pubkeys = append(req.Pubkeys, key)
}
params.FuncName = dty.FuncNameQueryCandidatorByPubkeys
params.Payload = types.MustPBToJSON(req)
var res dty.CandidatorReply
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.Run()
}
}
//DPosVoteQueryCmd 构造投票信息查询的命令行
func DPosVoteQueryCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "voteQuery",
Short: "query vote info",
Run: voteQuery,
}
addVoteQueryFlags(cmd)
return cmd
}
func addVoteQueryFlags(cmd *cobra.Command) {
cmd.Flags().StringP("pubkeys", "k", "", "pubkeys")
cmd.Flags().StringP("address", "a", "", "address")
}
func voteQuery(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
pubkeys, _ := cmd.Flags().GetString("pubkeys")
addr, _ := cmd.Flags().GetString("address")
var params rpctypes.Query4Jrpc
params.Execer = dty.DPosX
req := &dty.DposVoteQuery{
Addr: addr,
}
keys := strings.Split(pubkeys, ";")
for _, key := range keys {
req.Pubkeys = append(req.Pubkeys, key)
}
params.FuncName = dty.FuncNameQueryVote
params.Payload = types.MustPBToJSON(req)
var res dty.DposVoteReply
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.Run()
}
//DPosVrfMRegistCmd 构造注册VRF M信息(输入信息)的命令行
func DPosVrfMRegistCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "vrfMRegist",
Short: "regist m of vrf",
Run: vrfM,
}
addVrfMFlags(cmd)
return cmd
}
func addVrfMFlags(cmd *cobra.Command) {
cmd.Flags().StringP("pubkey", "k", "", "pubkey")
cmd.MarkFlagRequired("pubkey")
cmd.Flags().Int64P("cycle", "c", 0, "cycle no. of dpos consensus")
cmd.MarkFlagRequired("cycle")
cmd.Flags().StringP("m", "m", "", "input of vrf")
cmd.MarkFlagRequired("m")
}
func vrfM(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
pubkey, _ := cmd.Flags().GetString("pubkey")
cycle, _ := cmd.Flags().GetInt64("cycle")
m, _ := cmd.Flags().GetString("m")
payload := fmt.Sprintf("{\"pubkey\":\"%s\", \"cycle\":\"%d\", \"m\":\"%X\"}", pubkey, cycle, m)
params := &rpctypes.CreateTxIn{
Execer: types.ExecName(dty.DPosX),
ActionName: dty.CreateRegistVrfMTx,
Payload: []byte(payload),
}
var res string
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.CreateTransaction", params, &res)
ctx.RunWithoutMarshal()
}
//DPosVrfRPRegistCmd 构造VRF R/P(hash及proof)注册的命令行
func DPosVrfRPRegistCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "vrfRPRegist",
Short: "regist r,p of vrf",
Run: vrfRP,
}
addVrfRPRegistFlags(cmd)
return cmd
}
func addVrfRPRegistFlags(cmd *cobra.Command) {
cmd.Flags().StringP("pubkey", "k", "", "pubkey")
cmd.MarkFlagRequired("pubkey")
cmd.Flags().Int64P("cycle", "c", 0, "cycle no. of dpos consensus")
cmd.MarkFlagRequired("cycle")
cmd.Flags().StringP("hash", "r", "", "hash of vrf")
cmd.MarkFlagRequired("hash")
cmd.Flags().StringP("proof", "p", "", "proof of vrf")
cmd.MarkFlagRequired("proof")
}
func vrfRP(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
pubkey, _ := cmd.Flags().GetString("pubkey")
cycle, _ := cmd.Flags().GetInt64("cycle")
r, _ := cmd.Flags().GetString("r")
p, _ := cmd.Flags().GetString("p")
payload := fmt.Sprintf("{\"pubkey\":\"%s\", \"cycle\":\"%d\", \"r\":\"%s\", \"p\":\"%s\"}", pubkey, cycle, r, p)
params := &rpctypes.CreateTxIn{
Execer: types.ExecName(dty.DPosX),
ActionName: dty.CreateRegistVrfRPTx,
Payload: []byte(payload),
}
var res string
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.CreateTransaction", params, &res)
ctx.RunWithoutMarshal()
}
//DPosVrfQueryCmd 构造VRF相关信息查询的命令行
func DPosVrfQueryCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "vrfQuery",
Short: "query vrf info",
Run: vrfQuery,
}
addVrfQueryFlags(cmd)
return cmd
}
func addVrfQueryFlags(cmd *cobra.Command) {
cmd.Flags().StringP("type", "t", "", "query type")
cmd.MarkFlagRequired("type")
cmd.Flags().StringP("time", "d", "", "time like 2019-06-18")
cmd.Flags().Int64P("timestamp", "s", 0, "time stamp from 1970-1-1")
cmd.Flags().Int64P("cycle", "c", 0, "cycle,one time point belongs to a cycle")
}
func vrfQuery(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
ty, _ := cmd.Flags().GetString("type")
dtime, _ := cmd.Flags().GetString("time")
timestamp, _ := cmd.Flags().GetInt64("timestamp")
cycle, _ := cmd.Flags().GetInt64("cycle")
var params rpctypes.Query4Jrpc
params.Execer = dty.DPosX
switch ty {
case "dtime":
t, err := time.Parse("2006-01-02 15:04:05", dtime)
if err != nil {
fmt.Println("err time format:", dtime)
return
}
req := &dty.DposVrfQuery{
Ty: dty.QueryVrfByTime,
Timestamp: t.Unix(),
}
params.FuncName = dty.FuncNameQueryVrfByTime
params.Payload = types.MustPBToJSON(req)
var res dty.DposVrfReply
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.Run()
case "timestamp":
if timestamp <= 0 {
fmt.Println("err timestamp:", timestamp)
return
}
req := &dty.DposVrfQuery{
Ty: dty.QueryVrfByTime,
Timestamp: timestamp,
}
params.FuncName = dty.FuncNameQueryVrfByTime
params.Payload = types.MustPBToJSON(req)
var res dty.DposVrfReply
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.Run()
case "cycle":
if cycle <= 0 {
fmt.Println("err cycle:", cycle)
return
}
req := &dty.DposVrfQuery{
Ty: dty.QueryVrfByCycle,
Cycle: cycle,
}
params.FuncName = dty.FuncNameQueryVrfByCycle
params.Payload = types.MustPBToJSON(req)
var res dty.DposVrfReply
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.Run()
}
}
\ No newline at end of file
// 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 executor
/*
该合约主要是配合Dpos共识,完成(1)候选节点的注册、去注册、投票及查询管理。(2)Dpos共识运行过程中,得票数TopN(N为约定的受托节点数量)受托节点的VRF相关信息的分阶段发布管理。
(1)系统初始运行时,会有默认的几个受托节点进行共识运行。
(2)系统运行后,可以重新选举受托节点,各个候选节点需要抵押10000个币(暂未实现),注册成为候选节点。
(3)候选节点可以在社区宣传,让大家为自己投票。
(4)用户可以为自己支持的候选节点投票。投票后,资金会冻结,3天以后才可以撤销投票。
(5)系统运行过程中,每到固定区块高度时(比如10万个区块),重新获取当前投票数据,并确定下一个时间段的受托节点。
(6)受托节点进行共识出块,每个cycle(一个cycle中,各个受托节点轮番出块,直到都轮一遍)分两个阶段进行VRF信息发布:
第一个阶段,各个受托节点发布自己的VRF的M信息
第二个阶段,各个受托节点发布自己的VRF的R、P信息
上述VRF的M、R、P可以验证。
(7)新的cycle中,使用上述VRF信息进行受托节点的出块顺序的重新洗牌,按洗牌结果决定各受托节点出块的顺序
*/
// 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 executor
import (
log "github.com/33cn/chain33/common/log/log15"
drivers "github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
dty "github.com/33cn/plugin/plugin/dapp/dposvote/types"
)
var logger = log.New("module", "execs.dposvote")
var driverName = dty.DPosX
var (
dposDelegateNum int64 = 3 //委托节点个数,从配置读取,以后可以根据投票结果来定
dposBlockInterval int64 = 3 //出块间隔,当前按3s
dposContinueBlockNum int64 = 6 //一个委托节点当选后,一次性持续出块数量
dposCycle = dposDelegateNum * dposBlockInterval * dposContinueBlockNum
dposPeriod = dposBlockInterval * dposContinueBlockNum
)
type CycleInfo struct {
cycle int64
cycleStart int64
cycleStop int64
}
func calcCycleByTime(now int64) *CycleInfo {
cycle := now / dposCycle
cycleStart := now - now % dposCycle
cycleStop := cycleStart + dposCycle - 1
return &CycleInfo{
cycle: cycle,
cycleStart: cycleStart,
cycleStop: cycleStop,
}
}
func init() {
ety := types.LoadExecutorType(driverName)
ety.InitFuncList(types.ListMethod(&DPos{}))
}
// Init DPos Executor
func Init(name string, sub []byte) {
driverName := GetName()
if name != driverName {
panic("system dapp can't be rename")
}
drivers.Register(driverName, newDposVote, types.GetDappFork(driverName, "Enable"))
//读取一下配置项,用于和共识模块一致计算cycle
dposDelegateNum = types.Conf("config.consensus.sub.dpos").GInt("delegateNum")
dposBlockInterval = types.Conf("config.consensus.sub.dpos").GInt("blockInterval")
dposContinueBlockNum = types.Conf("config.consensus.sub.dpos").GInt("continueBlockNum")
dposCycle = dposDelegateNum * dposBlockInterval * dposContinueBlockNum
dposPeriod = dposBlockInterval * dposContinueBlockNum
}
//DPos 执行器,用于Dpos候选节点注册、投票,VRF信息注册管理等功能
type DPos struct {
drivers.DriverBase
}
func newDposVote() drivers.Driver {
t := &DPos{}
t.SetChild(t)
t.SetExecutorType(types.LoadExecutorType(driverName))
return t
}
//GetName 获取DPos执行器的名称
func GetName() string {
return newDposVote().GetName()
}
//ExecutorOrder Exec 的时候 同时执行 ExecLocal
func (g *DPos) ExecutorOrder() int64 {
return drivers.ExecLocalSameTime
}
//GetDriverName 获取DPos执行器的名称
func (g *DPos) GetDriverName() string {
return dty.DPosX
}
// CheckReceiptExecOk return true to check if receipt ty is ok
func (g *DPos) CheckReceiptExecOk() bool {
return true
}
// 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 executor
import (
"bytes"
"encoding/hex"
"fmt"
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/db"
dbm "github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
dty "github.com/33cn/plugin/plugin/dapp/dposvote/types"
"sort"
"strings"
)
const (
//ListDESC 表示记录降序排列
ListDESC = int32(0)
//ListASC 表示记录升序排列
ListASC = int32(1)
//DefaultCount 默认一次获取的记录数
DefaultCount = int32(10)
)
//Action 具体动作执行
type Action struct {
coinsAccount *account.DB
db dbm.KV
txhash []byte
fromaddr string
blocktime int64
height int64
execaddr string
localDB dbm.KVDB
index int
mainHeight int64
}
//NewAction 生成Action对象
func NewAction(dpos *DPos, tx *types.Transaction, index int) *Action {
hash := tx.Hash()
fromAddr := tx.From()
return &Action{
coinsAccount: dpos.GetCoinsAccount(),
db: dpos.GetStateDB(),
txhash: hash,
fromaddr: fromAddr,
blocktime: dpos.GetBlockTime(),
height: dpos.GetHeight(),
execaddr: dapp.ExecAddress(string(tx.Execer)),
localDB: dpos.GetLocalDB(),
index: index,
mainHeight: dpos.GetMainHeight(),
}
}
//CheckExecAccountBalance 检查地址在Dpos合约中的余额是否足够
func (action *Action) CheckExecAccountBalance(fromAddr string, ToFrozen, ToActive int64) bool {
acc := action.coinsAccount.LoadExecAccount(fromAddr, action.execaddr)
if acc.GetBalance() >= ToFrozen && acc.GetFrozen() >= ToActive {
return true
}
return false
}
//Key State数据库中存储记录的Key值格式转换
func Key(id string) (key []byte) {
//key = append(key, []byte("mavl-"+types.ExecName(pkt.GuessX)+"-")...)
key = append(key, []byte("mavl-"+dty.DPosX+"-")...)
key = append(key, []byte(id)...)
return key
}
//queryVrfByTime 根据时间信息,查询TopN的受托节点的VRF信息
func queryVrfByTime(kvdb db.KVDB, req *dty.DposVrfQuery) (types.Message, error) {
if req.Ty != dty.QueryVrfByTime{
return nil, types.ErrInvalidParam
}
cycleInfo := calcCycleByTime(req.Timestamp)
req.Ty = dty.QueryVrfByTime
req.Cycle = cycleInfo.cycle
return queryVrfByCycle(kvdb, req)
}
//queryVrfByCycle 根据Cycle信息,查询TopN的受托节点的VRF信息
func queryVrfByCycle(kvdb db.KVDB, req *dty.DposVrfQuery) (types.Message, error) {
if req.Ty != dty.QueryVrfByCycle {
return nil, types.ErrInvalidParam
}
topNReq := &dty.CandidatorQuery{
TopN: int32(dposDelegateNum),
}
reply, err := queryTopNCands(kvdb, topNReq)
res := reply.(*dty.CandidatorReply)
if err != nil || len(res.Candidators) < int(dposDelegateNum){
logger.Error("queryVrf failed", "Candidators", len(res.Candidators), "need Candidators", dposDelegateNum)
return nil, dty.ErrCandidatorNotEnough
}
VrfRPTable := dty.NewDposVrfRPTable(kvdb)
query := VrfRPTable.GetQuery(kvdb)
var tempCands [] *dty.Candidator
var vrfs [] *dty.VrfInfo
for i := 0; i < len(res.Candidators); i ++ {
rows, err := query.ListIndex("pubkey_cycle", []byte(fmt.Sprintf("%X:%018d", res.Candidators[i].Pubkey, req.Cycle)), nil, 1, 0)
if err != nil {
logger.Error("queryVrf RP failed", "pubkey", fmt.Sprintf("%X", res.Candidators[i].Pubkey), "cycle", req.Cycle)
tempCands = append(tempCands, res.Candidators[i])
continue
}
vrfRP := rows[0].Data.(*dty.DposVrfRP)
vrf := &dty.VrfInfo{
Index: vrfRP.Index,
Pubkey: vrfRP.Pubkey,
Cycle: vrfRP.Cycle,
Height: vrfRP.Height,
M: vrfRP.M,
R: vrfRP.R,
P: vrfRP.P,
Time: vrfRP.Time,
}
vrfs = append(vrfs, vrf)
}
if tempCands == nil || len(tempCands) == 0 {
return &dty.DposVrfReply{Vrf: vrfs}, nil
}
vrfMTable := dty.NewDposVrfMTable(kvdb)
query = vrfMTable.GetQuery(kvdb)
for i := 0; i < len(tempCands); i++ {
rows, err := query.ListIndex("pubkey_cycle", []byte(fmt.Sprintf("%X:%018d", tempCands[i].Pubkey, req.Cycle)), nil, 1, 0)
if err != nil {
logger.Error("queryVrf M failed", "pubkey", fmt.Sprintf("%X", res.Candidators[i].Pubkey), "cycle", req.Cycle)
continue
}
vrfM := rows[0].Data.(*dty.DposVrfM)
vrf := &dty.VrfInfo{
Index: vrfM.Index,
Pubkey: vrfM.Pubkey,
Cycle: vrfM.Cycle,
Height: vrfM.Height,
M: vrfM.M,
Time: vrfM.Time,
}
vrfs = append(vrfs, vrf)
}
return &dty.DposVrfReply{Vrf: vrfs}, nil
}
//queryCands 根据候选节点的Pubkey下旬候选节点信息,得票数、状态等
func queryCands(kvdb db.KVDB, req *dty.CandidatorQuery) (types.Message, error) {
var cands []*dty.Candidator
candTable := dty.NewDposCandidatorTable(kvdb)
query := candTable.GetQuery(kvdb)
for i := 0; i < len(req.Pubkeys); i++ {
bPubkey, _ := hex.DecodeString(req.Pubkeys[i])
rows, err := query.ListIndex("pubkey", bPubkey, nil, 1, 0)
if err != nil {
return nil, err
}
candInfo := rows[0].Data.(*dty.CandidatorInfo)
cand := &dty.Candidator{
Pubkey: candInfo.Pubkey,
Address: candInfo.Address,
Ip: candInfo.Ip,
Votes: candInfo.Votes,
Status: candInfo.Status,
}
cands = append(cands, cand)
}
return &dty.CandidatorReply{Candidators: cands}, nil
}
//queryTopNCands 查询得票数TopN的候选节点信息,包括得票数,状态等
func queryTopNCands(kvdb db.KVDB, req *dty.CandidatorQuery) (types.Message, error) {
var cands []*dty.Candidator
candTable := dty.NewDposCandidatorTable(kvdb)
query := candTable.GetQuery(kvdb)
rows, err := query.ListIndex("status", []byte(fmt.Sprintf("%2d", dty.CandidatorStatusVoted)), nil, 0, 0)
if err != nil {
return nil, err
}
number := int32(0)
for index := 0; index < len(rows); index++ {
candInfo := rows[index].Data.(*dty.CandidatorInfo)
cand := &dty.Candidator{
Pubkey: candInfo.Pubkey,
Address: candInfo.Address,
Ip: candInfo.Ip,
Votes: candInfo.Votes,
Status: candInfo.Status,
}
cands = append(cands, cand)
number ++
}
sort.Slice(cands, func(i, j int) bool {
return cands[i].Votes > cands[j].Votes
})
if number < req.TopN {
rows, err = query.ListIndex("status", []byte(fmt.Sprintf("%2d", dty.CandidatorStatusRegist)), nil, req.TopN - number, 0)
if err != nil {
return nil, err
}
for index := 0; index < len(rows); index++ {
candInfo := rows[index].Data.(*dty.CandidatorInfo)
cand := &dty.Candidator{
Pubkey: candInfo.Pubkey,
Address: candInfo.Address,
Ip: candInfo.Ip,
Votes: candInfo.Votes,
Status: candInfo.Status,
}
cands = append(cands, cand)
number ++
if number == req.TopN {
break
}
}
} else {
cands = cands[0:req.TopN]
}
return &dty.CandidatorReply{Candidators: cands}, nil
}
//isValidPubkey 判断一个公钥是否属于一个公钥集合
func isValidPubkey(pubkeys []string, pubkey string) bool{
if len(pubkeys) == 0 || len(pubkey) == 0 {
return false
}
for i := 0 ; i < len(pubkeys); i++ {
if strings.EqualFold(pubkeys[i], pubkey) {
return true
}
}
return false
}
//queryVote 根据用户地址信息查询用户的投票情况
func queryVote(kvdb db.KVDB, req *dty.DposVoteQuery) (types.Message, error) {
var voters []*dty.DposVoter
voteTable := dty.NewDposVoteTable(kvdb)
query := voteTable.GetQuery(kvdb)
rows, err := query.ListIndex("addr", []byte(req.Addr), nil, 0, 0)
if err != nil {
return nil, err
}
for index := 0; index < len(rows); index++ {
voter := rows[index].Data.(*dty.DposVoter)
voters = append(voters, voter)
}
//如果不指定pubkeys,则返回所有;否则,需要判断pubkey是否为指定的值之一。
if len(req.Pubkeys) == 0 {
return &dty.DposVoteReply{Votes: voters}, nil
}
reply := &dty.DposVoteReply{}
for index := 0; index < len(voters); index ++ {
strPubkey := hex.EncodeToString(voters[index].Pubkey)
if isValidPubkey(req.Pubkeys, strPubkey) {
reply.Votes = append(reply.Votes, voters[index])
}
}
return reply, nil
}
func (action *Action) saveCandicator(candInfo *dty.CandidatorInfo) (kvset []*types.KeyValue) {
value := types.Encode(candInfo)
pubkey := hex.EncodeToString(candInfo.GetPubkey())
err := action.db.Set(Key(pubkey), value)
if err != nil {
logger.Error("saveCandicator have err:", err.Error())
}
kvset = append(kvset, &types.KeyValue{Key: Key(pubkey), Value: value})
return kvset
}
func (action *Action) getIndex() int64 {
return action.height*types.MaxTxsPerBlock + int64(action.index)
}
//getReceiptLog 根据候选节点信息及投票信息生成收据信息
func (action *Action) getReceiptLog(candInfo *dty.CandidatorInfo, statusChange bool, voted bool, vote *dty.DposVote) *types.ReceiptLog {
log := &types.ReceiptLog{}
r := &dty.ReceiptCandicator{}
//r.StartIndex = can.StartIndex
if candInfo.Status == dty.CandidatorStatusRegist {
log.Ty = dty.TyLogCandicatorRegist
} else if candInfo.Status == dty.CandidatorStatusVoted {
log.Ty = dty.TyLogCandicatorVoted
} else if candInfo.Status == dty.CandidatorStatusCancelRegist {
log.Ty = dty.TyLogCandicatorCancelRegist
}
r.Index = action.getIndex()
r.Time = action.blocktime
r.StatusChange = statusChange
r.Status = candInfo.Status
r.PreStatus = candInfo.PreStatus
r.Address = candInfo.Address
r.Pubkey = candInfo.Pubkey
r.Voted = voted
if voted {
r.Votes = vote.Votes
r.FromAddr = vote.FromAddr
}
r.CandInfo = candInfo
log.Log = types.Encode(r)
return log
}
//readCandicatorInfo 根据候选节点的公钥查询候选节点信息
func (action *Action) readCandicatorInfo(pubkey []byte) (*dty.CandidatorInfo, error) {
strPubkey := hex.EncodeToString(pubkey)
data, err := action.db.Get(Key(strPubkey))
if err != nil {
logger.Error("readCandicator have err:", err.Error())
return nil, err
}
var cand dty.CandidatorInfo
//decode
err = types.Decode(data, &cand)
if err != nil {
logger.Error("decode candicator have err:", err.Error())
return nil, err
}
return &cand, nil
}
// newCandicatorInfo 新建候选节点信息对象
func (action *Action) newCandicatorInfo(regist *dty.DposCandidatorRegist) *dty.CandidatorInfo {
bPubkey, _ := hex.DecodeString(regist.Pubkey)
candInfo := &dty.CandidatorInfo{
Pubkey: bPubkey,
Address: regist.Address,
Ip: regist.Ip,
}
return candInfo
}
//Regist 注册候选节点
func (action *Action) Regist(regist *dty.DposCandidatorRegist) (*types.Receipt, error) {
var logs []*types.ReceiptLog
var kv []*types.KeyValue
bPubkey, err := hex.DecodeString(regist.Pubkey)
if err != nil {
logger.Info("Regist", "addr", action.fromaddr, "execaddr", action.execaddr, "pubkey is not correct",
regist.Pubkey)
return nil, types.ErrInvalidParam
}
candInfo, err := action.readCandicatorInfo(bPubkey)
if err == nil && candInfo != nil {
logger.Info("Regist", "addr", action.fromaddr, "execaddr", action.execaddr, "candicator is exist",
candInfo.String())
return nil, dty.ErrCandidatorExist
}
if !action.CheckExecAccountBalance(action.fromaddr, dty.RegistFrozenCoins, 0) {
logger.Error("Regist failed", "addr", action.fromaddr, "execaddr", action.execaddr, "err", types.ErrNoBalance)
return nil, types.ErrNoBalance
}
receipt, err := action.coinsAccount.ExecFrozen(action.fromaddr, action.execaddr, dty.RegistFrozenCoins)
if err != nil {
logger.Error("ExecFrozen failed", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", dty.RegistFrozenCoins, "err", err.Error())
return nil, err
}
logs = append(logs, receipt.Logs...)
kv = append(kv, receipt.KV...)
logger.Info("Regist", "addr", action.fromaddr, "execaddr", action.execaddr, "new candicator", regist.String())
candInfo = action.newCandicatorInfo(regist)
candInfo.Status = dty.CandidatorStatusRegist
candInfo.StartTime = action.blocktime
candInfo.StartHeight = action.mainHeight
candInfo.StartIndex = action.getIndex()
candInfo.Index = candInfo.StartIndex
candInfo.StartTxHash = common.ToHex(action.txhash)
candInfo.PreIndex = 0
receiptLog := action.getReceiptLog(candInfo, false, false, nil)
logs = append(logs, receiptLog)
kv = append(kv, action.saveCandicator(candInfo)...)
return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil
}
//ReRegist 重新注册一个注销的候选节点
func (action *Action) ReRegist(regist *dty.DposCandidatorRegist) (*types.Receipt, error) {
var logs []*types.ReceiptLog
var kv []*types.KeyValue
bPubkey, err := hex.DecodeString(regist.Pubkey)
if err != nil {
logger.Info("ReRegist", "addr", action.fromaddr, "execaddr", action.execaddr, "pubkey is not correct",
regist.Pubkey)
return nil, types.ErrInvalidParam
}
candInfo, err := action.readCandicatorInfo(bPubkey)
if err != nil || candInfo == nil {
logger.Info("ReRegist", "addr", action.fromaddr, "execaddr", action.execaddr, "candicator is not exist",
candInfo.String())
return nil, dty.ErrCandidatorExist
}
if candInfo.Status != dty.CandidatorStatusCancelRegist {
logger.Info("ReRegist", "addr", action.fromaddr, "execaddr", action.execaddr, "candicator status is not correct",
candInfo.String())
return nil, dty.ErrCandidatorInvalidStatus
}
if !action.CheckExecAccountBalance(action.fromaddr, dty.RegistFrozenCoins, 0) {
logger.Error("Regist failed", "addr", action.fromaddr, "execaddr", action.execaddr, "err", types.ErrNoBalance)
return nil, types.ErrNoBalance
}
receipt, err := action.coinsAccount.ExecFrozen(action.fromaddr, action.execaddr, dty.RegistFrozenCoins)
if err != nil {
logger.Error("ExecFrozen failed", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", dty.RegistFrozenCoins, "err", err.Error())
return nil, err
}
logs = append(logs, receipt.Logs...)
kv = append(kv, receipt.KV...)
logger.Info("Regist", "addr", action.fromaddr, "execaddr", action.execaddr, "new candicator",
regist.String())
candInfo = action.newCandicatorInfo(regist)
candInfo.Status = dty.CandidatorStatusRegist
candInfo.StartTime = action.blocktime
candInfo.StartHeight = action.mainHeight
candInfo.StartIndex = action.getIndex()
candInfo.Index = candInfo.StartIndex
candInfo.StartTxHash = common.ToHex(action.txhash)
candInfo.PreIndex = 0
receiptLog := action.getReceiptLog(candInfo, false, false, nil)
logs = append(logs, receiptLog)
kv = append(kv, action.saveCandicator(candInfo)...)
return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil
}
//CancelRegist 撤销一个候选节点的注册
func (action *Action) CancelRegist(req *dty.DposCandidatorCancelRegist) (*types.Receipt, error) {
var logs []*types.ReceiptLog
var kv []*types.KeyValue
bPubkey, err := hex.DecodeString(req.Pubkey)
if err != nil {
logger.Info("CancelRegist", "addr", action.fromaddr, "execaddr", action.execaddr, "pubkey is not correct",
req.Pubkey)
return nil, types.ErrInvalidParam
}
candInfo, err := action.readCandicatorInfo(bPubkey)
if err != nil || candInfo == nil{
logger.Error("Cancel Regist", "addr", action.fromaddr, "execaddr", action.execaddr, "candicator is not exist",
candInfo.String())
return nil, dty.ErrCandidatorNotExist
}
if candInfo.Status == dty.CandidatorStatusCancelRegist {
logger.Error("Cancel Regist", "addr", action.fromaddr, "execaddr", action.execaddr, "candicator is already canceled.",
candInfo.String())
return nil, types.ErrInvalidParam
}
if action.fromaddr != candInfo.GetAddress() {
logger.Error("Cancel Regist", "addr", action.fromaddr, "execaddr", action.execaddr, "from addr is not candicator address.",
candInfo.String())
return nil, types.ErrInvalidParam
}
logger.Info("Cancel Regist", "addr", action.fromaddr, "execaddr", action.execaddr, "candicator",
candInfo.String())
if candInfo.Status == dty.CandidatorStatusVoted {
for _, voter := range candInfo.Voters{
receipt, err := action.coinsAccount.ExecActive(voter.FromAddr, action.execaddr, voter.Votes)
if err != nil {
//action.coinsAccount.ExecFrozen(game.AdminAddr, action.execaddr, devFee) // rollback
logger.Error("Cancel Regist active votes", "addr", voter.FromAddr, "execaddr", action.execaddr,
"amount", voter.Votes, "err", err)
return nil, err
}
logs = append(logs, receipt.Logs...)
kv = append(kv, receipt.KV...)
}
}
candInfo.PreStatus = candInfo.Status
candInfo.Status = dty.CandidatorStatusCancelRegist
candInfo.PreIndex = candInfo.Index
candInfo.Index = action.getIndex()
candInfo.Voters = nil
receiptLog := action.getReceiptLog(candInfo, true, false, nil)
logs = append(logs, receiptLog)
kv = append(kv, action.saveCandicator(candInfo)...)
return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil
}
//Vote 为某一个候选节点投票
func (action *Action) Vote(vote *dty.DposVote) (*types.Receipt, error) {
var logs []*types.ReceiptLog
var kv []*types.KeyValue
bPubkey, err := hex.DecodeString(vote.Pubkey)
if err != nil {
logger.Info("Vote", "addr", action.fromaddr, "execaddr", action.execaddr, "pubkey is not correct",
vote.Pubkey)
return nil, types.ErrInvalidParam
}
candInfo, err := action.readCandicatorInfo(bPubkey)
if err != nil || candInfo == nil{
logger.Error("Vote failed", "addr", action.fromaddr, "execaddr", action.execaddr, "candicator is not exist",
candInfo.String())
return nil, dty.ErrCandidatorNotExist
}
if candInfo.Status == dty.CandidatorStatusCancelRegist {
logger.Error("Vote failed", "addr", action.fromaddr, "execaddr", action.execaddr, "candicator is already canceled.",
candInfo.String())
return nil, types.ErrInvalidParam
}
logger.Info("vote", "addr", action.fromaddr, "execaddr", action.execaddr, "candicator",
candInfo.String())
statusChange := false
if candInfo.Status == dty.CandidatorStatusRegist {
candInfo.PreStatus = candInfo.Status
candInfo.Status = dty.CandidatorStatusVoted
statusChange = true
}
checkValue := vote.Votes
if !action.CheckExecAccountBalance(action.fromaddr, checkValue, 0) {
logger.Error("Vote failed", "addr", action.fromaddr, "execaddr", action.execaddr, "err", types.ErrNoBalance)
return nil, types.ErrNoBalance
}
receipt, err := action.coinsAccount.ExecFrozen(action.fromaddr, action.execaddr, checkValue)
if err != nil {
logger.Error("ExecFrozen failed", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", checkValue, "err", err.Error())
return nil, err
}
logs = append(logs, receipt.Logs...)
kv = append(kv, receipt.KV...)
voter := &dty.DposVoter{
FromAddr: vote.FromAddr,
Pubkey: bPubkey,
Votes: vote.Votes,
Index: action.getIndex(),
Time: action.blocktime,
}
candInfo.Voters = append(candInfo.Voters, voter)
candInfo.Votes += vote.Votes
candInfo.PreIndex = candInfo.Index
candInfo.Index = action.getIndex()
receiptLog := action.getReceiptLog(candInfo, statusChange, true, vote)
logs = append(logs, receiptLog)
kv = append(kv, action.saveCandicator(candInfo)...)
return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil
}
//CancelVote 撤销对某个候选节点的投票
func (action *Action) CancelVote(vote *dty.DposCancelVote) (*types.Receipt, error) {
var logs []*types.ReceiptLog
var kv []*types.KeyValue
bPubkey, err := hex.DecodeString(vote.Pubkey)
if err != nil {
logger.Info("CancelVote", "addr", action.fromaddr, "execaddr", action.execaddr, "pubkey is not correct",
vote.Pubkey)
return nil, types.ErrInvalidParam
}
candInfo, err := action.readCandicatorInfo(bPubkey)
if err != nil || candInfo == nil{
logger.Error("CancelVote failed", "addr", action.fromaddr, "execaddr", action.execaddr, "candicator is not exist",
candInfo.String())
return nil, dty.ErrCandidatorNotExist
}
if candInfo.Status != dty.CandidatorStatusVoted {
logger.Error("CancelVote failed", "addr", action.fromaddr, "execaddr", action.execaddr, "candicator is already canceled.",
candInfo.String())
return nil, types.ErrInvalidParam
}
logger.Info("CancelVote", "addr", action.fromaddr, "execaddr", action.execaddr, "candicator",
candInfo.String())
votes := vote.Votes
availVotes := int64(0)
enoughVotes := false
for _, voter := range candInfo.Voters {
if voter.FromAddr == action.fromaddr && bytes.Equal(voter.Pubkey, bPubkey){
if action.blocktime - voter.Time >= dty.VoteFrozenTime {
availVotes += voter.Votes
if availVotes >= votes {
enoughVotes = true
break
}
}
}
}
if !enoughVotes {
logger.Error("RevokeVote failed", "addr", action.fromaddr, "execaddr", action.execaddr, "not enough avail votes",
availVotes, "revoke votes", vote.Votes)
return nil, dty.ErrNotEnoughVotes
}
for index, voter := range candInfo.Voters {
if voter.FromAddr == action.fromaddr && bytes.Equal(voter.Pubkey, bPubkey){
if action.blocktime - voter.Time >= 3 * 24 * 3600 {
if voter.Votes > votes {
voter.Votes -= votes
break
} else if voter.Votes == votes {
candInfo.Voters = append(candInfo.Voters[:index], candInfo.Voters[index+1:]...)
break
} else {
candInfo.Voters = append(candInfo.Voters[:index], candInfo.Voters[index+1:]...)
votes = votes - voter.Votes
}
}
}
}
checkValue := vote.Votes
receipt, err := action.coinsAccount.ExecActive(action.fromaddr, action.execaddr, checkValue)
if err != nil {
logger.Error("ExecActive failed", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", checkValue, "err", err.Error())
return nil, err
}
logs = append(logs, receipt.Logs...)
kv = append(kv, receipt.KV...)
candInfo.Votes -= vote.Votes
vote2 := &dty.DposVote{
FromAddr: action.fromaddr,
Pubkey: vote.Pubkey,
Votes: (-1) * vote.Votes,
}
candInfo.PreIndex = candInfo.Index
candInfo.Index = action.getIndex()
receiptLog := action.getReceiptLog(candInfo, false, true, vote2)
logs = append(logs, receiptLog)
kv = append(kv, action.saveCandicator(candInfo)...)
return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil
}
//RegistVrfM 注册受托节点的Vrf M信息(输入信息)
func (action *Action) RegistVrfM(vrfMReg *dty.DposVrfMRegist) (*types.Receipt, error) {
var logs []*types.ReceiptLog
var kv []*types.KeyValue
bPubkey, err := hex.DecodeString(vrfMReg.Pubkey)
if err != nil {
logger.Info("RegistVrfM", "addr", action.fromaddr, "execaddr", action.execaddr, "pubkey is not correct",
vrfMReg.Pubkey)
return nil, types.ErrInvalidParam
}
bM, err := hex.DecodeString(vrfMReg.M)
if err != nil {
logger.Info("RegistVrfM", "addr", action.fromaddr, "execaddr", action.execaddr, "M is not correct",
vrfMReg.M)
return nil, types.ErrInvalidParam
}
req := &dty.CandidatorQuery{
TopN: int32(dposDelegateNum),
}
reply, err := queryTopNCands(action.localDB, req)
res := reply.(*dty.CandidatorReply)
if err != nil || len(res.Candidators) < int(dposDelegateNum){
logger.Error("RegistVrfM failed", "addr", action.fromaddr, "execaddr", action.execaddr, "not enough Candidators",
dposDelegateNum)
return nil, dty.ErrCandidatorNotEnough
}
legalCand := false
for i := 0; i < len(res.Candidators); i++ {
if bytes.Equal(bPubkey, res.Candidators[i].Pubkey) && action.fromaddr == res.Candidators[i].Address {
legalCand = true
}
}
if !legalCand {
logger.Error("RegistVrfM failed", "addr", action.fromaddr, "execaddr", action.execaddr, "not legal Candidators",
res.String())
return nil, dty.ErrCandidatorNotLegal
}
cycleInfo := calcCycleByTime(action.blocktime)
if vrfMReg.Cycle != cycleInfo.cycle {
logger.Error("RegistVrfM failed", "addr", action.fromaddr, "execaddr", action.execaddr, "cycle is not the same with current blocktime",
vrfMReg.String())
return nil, types.ErrInvalidParam
}
//todo 还需要检查是否针对这个cycle已经有注册过M了,如果注册过了,也需要提示失败
vrfMTable := dty.NewDposVrfMTable(action.localDB)
query := vrfMTable.GetQuery(action.localDB)
_, err = query.ListIndex("pubkey_cycle", []byte(fmt.Sprintf("%X:%018d", bPubkey, vrfMReg.Cycle)), nil, 1, 0)
if err == nil {
logger.Error("RegistVrfM failed", "addr", action.fromaddr, "execaddr", action.execaddr, "VrfM already is registed",
vrfMReg.String())
return nil, dty.ErrVrfMAlreadyRegisted
}
log := &types.ReceiptLog{}
r := &dty.ReceiptVrf{}
r.Index = action.getIndex()
r.Pubkey = bPubkey
r.Status = dty.VrfStatusMRegist
r.Cycle = cycleInfo.cycle
r.Height = action.mainHeight
r.M = bM
r.Time = action.blocktime
log.Ty = dty.TyLogVrfMRegist
log.Log = types.Encode(r)
logs = append(logs, log)
return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil
}
//RegistVrfRP 注册受托节点的Vrf R/P信息
func (action *Action) RegistVrfRP(vrfRPReg *dty.DposVrfRPRegist) (*types.Receipt, error) {
var logs []*types.ReceiptLog
var kv []*types.KeyValue
bPubkey, err := hex.DecodeString(vrfRPReg.Pubkey)
if err != nil {
logger.Info("RegistVrfM", "addr", action.fromaddr, "execaddr", action.execaddr, "pubkey is not correct",
vrfRPReg.Pubkey)
return nil, types.ErrInvalidParam
}
bR, err := hex.DecodeString(vrfRPReg.R)
if err != nil {
logger.Info("RegistVrfM", "addr", action.fromaddr, "execaddr", action.execaddr, "M is not correct",
vrfRPReg.R)
return nil, types.ErrInvalidParam
}
bP, err := hex.DecodeString(vrfRPReg.P)
if err != nil {
logger.Info("RegistVrfM", "addr", action.fromaddr, "execaddr", action.execaddr, "M is not correct",
vrfRPReg.P)
return nil, types.ErrInvalidParam
}
//todo 从localdb中查找对应的pubkey:cycle的信息,如果没找到,说明对应的M没有发布出来,则也不允许发布R,P。
vrfMTable := dty.NewDposVrfMTable(action.localDB)
query := vrfMTable.GetQuery(action.localDB)
rows, err := query.ListIndex("pubkey_cycle", []byte(fmt.Sprintf("%X:%018d", bPubkey, vrfRPReg.Cycle)), nil, 1, 0)
if err != nil {
logger.Error("RegistVrfRP failed", "addr", action.fromaddr, "execaddr", action.execaddr, "VrfM is not exist",
vrfRPReg.String())
return nil, dty.ErrVrfMNotRegisted
}
//对于可以注册的R、P,则允许。
cycleInfo := calcCycleByTime(action.blocktime)
//对于cycle不一致的情况,则不允许注册
if vrfRPReg.Cycle != cycleInfo.cycle {
logger.Error("RegistVrfRP failed", "addr", action.fromaddr, "execaddr", action.execaddr, "cycle is not the same with current blocktime",
vrfRPReg.String())
return nil, types.ErrInvalidParam
}
//todo 还需要检查是否针对这个cycle已经有注册过R、P了,如果注册过了,也需要提示失败
VrfRPTable := dty.NewDposVrfRPTable(action.localDB)
query = VrfRPTable.GetQuery(action.localDB)
_,err = query.ListIndex("pubkey_cycle", []byte(fmt.Sprintf("%X:%018d", bPubkey, vrfRPReg.Cycle)), nil, 1, 0)
if err == nil {
logger.Error("RegistVrfRP failed", "addr", action.fromaddr, "execaddr", action.execaddr, "RegistVrfRP is already resisted.",
vrfRPReg.String())
return nil, dty.ErrVrfRPAlreadyRegisted
}
log := &types.ReceiptLog{}
r := &dty.ReceiptVrf{}
r.Index = action.getIndex()
r.Pubkey = bPubkey
r.Status = dty.VrfStatusRPRegist
r.Cycle = cycleInfo.cycle
r.Height = action.mainHeight
r.R = bR
r.P = bP
r.M = rows[0].Data.(*dty.DposVrfM).M
r.Time = action.blocktime
log.Ty = dty.TyLogVrfRPRegist
log.Log = types.Encode(r)
logs = append(logs, log)
return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil
}
// 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 executor
import (
"github.com/33cn/chain33/types"
dty "github.com/33cn/plugin/plugin/dapp/dposvote/types"
)
//Exec_Regist DPos执行器注册候选节点
func (d *DPos) Exec_Regist(payload *dty.DposCandidatorRegist, tx *types.Transaction, index int) (*types.Receipt, error) {
action := NewAction(d, tx, index)
return action.Regist(payload)
}
//Exec_CancelRegist DPos执行器取消注册候选节点
func (d *DPos) Exec_CancelRegist(payload *dty.DposCandidatorCancelRegist, tx *types.Transaction, index int) (*types.Receipt, error) {
action := NewAction(d, tx, index)
return action.CancelRegist(payload)
}
//Exec_ReRegist DPos执行器重新注册候选节点
func (d *DPos) Exec_ReRegist(payload *dty.DposCandidatorRegist, tx *types.Transaction, index int) (*types.Receipt, error) {
action := NewAction(d, tx, index)
return action.ReRegist(payload)
}
//Exec_Vote DPos执行器为候选节点投票
func (d *DPos) Exec_Vote(payload *dty.DposVote, tx *types.Transaction, index int) (*types.Receipt, error) {
action := NewAction(d, tx, index)
return action.Vote(payload)
}
//Exec_CancelVote DPos执行器撤销对一个候选节点的投票
func (d *DPos) Exec_CancelVote(payload *dty.DposCancelVote, tx *types.Transaction, index int) (*types.Receipt, error) {
action := NewAction(d, tx, index)
return action.CancelVote(payload)
}
//Exec_RegistVrfM DPos执行器注册一个受托节点的Vrf M信息
func (d *DPos) Exec_RegistVrfM(payload *dty.DposVrfMRegist, tx *types.Transaction, index int) (*types.Receipt, error) {
action := NewAction(d, tx, index)
return action.RegistVrfM(payload)
}
//Exec_RegistVrfRP DPos执行器注册一个受托节点的Vrf R/P信息
func (d *DPos) Exec_RegistVrfRP(payload *dty.DposVrfRPRegist, tx *types.Transaction, index int) (*types.Receipt, error) {
action := NewAction(d, tx, index)
return action.RegistVrfRP(payload)
}
// 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 executor
import (
"fmt"
"github.com/33cn/chain33/types"
dty "github.com/33cn/plugin/plugin/dapp/dposvote/types"
)
func (d *DPos) rollbackCand(cand *dty.CandidatorInfo, log *dty.ReceiptCandicator) {
if cand == nil || log == nil {
return
}
//如果状态发生了变化,则需要将状态恢复到前一状态
if log.StatusChange {
cand.Status = log.PreStatus
cand.Index = cand.PreIndex
}
//如果投票了,则需要把投票回滚
if log.Voted {
cand.Votes -= log.Votes
if log.Votes > 0 {
//如果是投票,则回滚时将投票删除。
cand.Voters = cand.Voters[:len(cand.Voters)-1]
} else {
//如果是撤销投票,则回滚时,将删除的投票还回来
voter := &dty.DposVoter{
FromAddr: log.FromAddr,
Pubkey: log.Pubkey,
Votes: -log.Votes,
Index: log.Index,
Time: log.Time - dty.VoteFrozenTime,
}
cand.Voters = append(cand.Voters, voter)
}
}
}
func (d *DPos) rollbackCandVote(log *dty.ReceiptCandicator) (kvs []*types.KeyValue, err error) {
voterTable := dty.NewDposVoteTable(d.GetLocalDB())
candTable := dty.NewDposCandidatorTable(d.GetLocalDB())
if err != nil {
return nil, err
}
if log.Status == dty.CandidatorStatusRegist {
//注册回滚,cand表删除记录
err = candTable.Del(log.Pubkey)
if err != nil {
return nil, err
}
kvs, err = candTable.Save()
return kvs, err
} else if log.Status == dty.CandidatorStatusVoted {
//投票阶段回滚,回滚状态,回滚投票
candInfo := log.CandInfo
log.CandInfo = nil
//先回滚候选节点信息
d.rollbackCand(candInfo, log)
err = candTable.Replace(candInfo)
if err != nil {
return nil, err
}
kvs1, err := candTable.Save()
if err != nil {
return nil, err
}
//删除投票信息
err = voterTable.Del([]byte(fmt.Sprintf("%018d", log.Index)))
if err != nil {
return nil, err
}
kvs2, err := voterTable.Save()
if err != nil {
return nil, err
}
kvs = append(kvs1, kvs2...)
} else if log.Status == dty.CandidatorStatusCancelVoted {
//撤销投票回滚,需要将撤销的投票还回来
candInfo := log.CandInfo
log.CandInfo = nil
//先回滚候选节点信息
d.rollbackCand(candInfo, log)
err = candTable.Replace(candInfo)
if err != nil {
return nil, err
}
kvs1, err := candTable.Save()
if err != nil {
return nil, err
}
//删除投票信息
err = voterTable.Del([]byte(fmt.Sprintf("%018d", log.Index)))
if err != nil {
return nil, err
}
kvs2, err := voterTable.Save()
if err != nil {
return nil, err
}
kvs = append(kvs1, kvs2...)
}
return kvs, nil
}
func (d *DPos) rollbackVrf(log *dty.ReceiptVrf) (kvs []*types.KeyValue, err error) {
if log.Status == dty.VrfStatusMRegist {
vrfMTable := dty.NewDposVrfMTable(d.GetLocalDB())
//注册回滚,cand表删除记录
err = vrfMTable.Del([]byte(fmt.Sprintf("%018d", log.Index)))
if err != nil {
return nil, err
}
kvs, err = vrfMTable.Save()
return kvs, err
} else if log.Status == dty.VrfStatusRPRegist {
VrfRPTable := dty.NewDposVrfRPTable(d.GetLocalDB())
err = VrfRPTable.Del([]byte(fmt.Sprintf("%018d", log.Index)))
if err != nil {
return nil, err
}
kvs, err = VrfRPTable.Save()
return kvs, err
}
return nil, nil
}
func (d *DPos) execDelLocal(receipt *types.ReceiptData) (*types.LocalDBSet, error) {
dbSet := &types.LocalDBSet{}
if receipt.GetTy() != types.ExecOk {
return dbSet, nil
}
for _, log := range receipt.Logs {
switch log.GetTy() {
case dty.CandidatorStatusRegist, dty.CandidatorStatusVoted, dty.CandidatorStatusCancelVoted, dty.CandidatorStatusCancelRegist:
receiptLog := &dty.ReceiptCandicator{}
if err := types.Decode(log.Log, receiptLog); err != nil {
return nil, err
}
kv, err := d.rollbackCandVote(receiptLog)
if err != nil {
return nil, err
}
dbSet.KV = append(dbSet.KV, kv...)
case dty.VrfStatusMRegist, dty.VrfStatusRPRegist:
receiptLog := &dty.ReceiptVrf{}
if err := types.Decode(log.Log, receiptLog); err != nil {
return nil, err
}
kv, err := d.rollbackVrf(receiptLog)
if err != nil {
return nil, err
}
dbSet.KV = append(dbSet.KV, kv...)
}
}
return dbSet, nil
}
//ExecDelLocal_Regist method
func (d *DPos) ExecDelLocal_Regist(payload *dty.DposCandidatorRegist, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return d.execDelLocal(receiptData)
}
//ExecDelLocal_CancelRegist method
func (d *DPos) ExecDelLocal_CancelRegist(payload *dty.DposCandidatorCancelRegist, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return d.execDelLocal(receiptData)
}
//ExecDelLocal_ReRegist method
func (d *DPos) ExecDelLocal_ReRegist(payload *dty.DposCandidatorRegist, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return d.execDelLocal(receiptData)
}
//ExecDelLocal_Vote method
func (d *DPos) ExecDelLocal_Vote(payload *dty.DposVote, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return d.execDelLocal(receiptData)
}
//ExecDelLocal_CancelVote method
func (d *DPos) ExecDelLocal_CancelVote(payload *dty.DposCancelVote, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return d.execDelLocal(receiptData)
}
//ExecDelLocal_VrfMRegist method
func (d *DPos) ExecDelLocal_VrfMRegist(payload *dty.DposVrfMRegist, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return d.execDelLocal(receiptData)
}
//ExecDelLocal_VrfRPRegist method
func (d *DPos) ExecDelLocal_VrfRPRegist(payload *dty.DposVrfRPRegist, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return d.execDelLocal(receiptData)
}
\ No newline at end of file
// 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 executor
import (
"github.com/33cn/chain33/types"
dty "github.com/33cn/plugin/plugin/dapp/dposvote/types"
)
func (d *DPos) updateCandVote(log *dty.ReceiptCandicator) (kvs []*types.KeyValue, err error) {
voteTable := dty.NewDposVoteTable(d.GetLocalDB())
canTable := dty.NewDposCandidatorTable(d.GetLocalDB())
if log.Status == dty.CandidatorStatusRegist {
candInfo := log.CandInfo
log.CandInfo = nil
err = canTable.Add(candInfo)
if err != nil {
return nil, err
}
kvs, err = canTable.Save()
if err != nil {
return nil, err
}
} else if log.Status == dty.CandidatorStatusVoted {
candInfo := log.CandInfo
log.CandInfo = nil
voter := candInfo.Voters[len(candInfo.Voters)-1]
err = canTable.Replace(candInfo)
if err != nil {
return nil, err
}
kvs1, err := canTable.Save()
if err != nil {
return nil, err
}
err = voteTable.Add(voter)
if err != nil {
return nil, err
}
kvs2, err := voteTable.Save()
if err != nil {
return nil, err
}
kvs = append(kvs1, kvs2...)
} else if log.Status == dty.CandidatorStatusCancelVoted {
candInfo := log.CandInfo
log.CandInfo = nil
voter := &dty.DposVoter{
FromAddr: log.FromAddr,
Pubkey: log.Pubkey,
Votes: log.Votes,
Index: log.Index,
Time: log.Time,
}
err = canTable.Replace(candInfo)
if err != nil {
return nil, err
}
kvs1, err := canTable.Save()
if err != nil {
return nil, err
}
err = voteTable.Add(voter)
if err != nil {
return nil, err
}
kvs2, err := voteTable.Save()
if err != nil {
return nil, err
}
kvs = append(kvs1, kvs2...)
}
return kvs, nil
}
func (d *DPos) updateVrf(log *dty.ReceiptVrf) (kvs []*types.KeyValue, err error) {
if log.Status == dty.VrfStatusMRegist {
vrfMTable := dty.NewDposVrfMTable(d.GetLocalDB())
vrfM := &dty.DposVrfM{
Index: log.Index,
Pubkey: log.Pubkey,
Cycle: log.Cycle,
Height: log.Height,
M: log.M,
Time: log.Time,
}
err = vrfMTable.Add(vrfM)
if err != nil {
return nil, err
}
kvs, err = vrfMTable.Save()
if err != nil {
return nil, err
}
} else if log.Status == dty.VrfStatusRPRegist {
VrfRPTable := dty.NewDposVrfRPTable(d.GetLocalDB())
vrfRP := &dty.DposVrfRP{
Index: log.Index,
Pubkey: log.Pubkey,
Cycle: log.Cycle,
Height: log.Height,
R: log.R,
P: log.P,
M: log.M,
Time: log.Time,
}
err = VrfRPTable.Add(vrfRP)
if err != nil {
return nil, err
}
kvs, err = VrfRPTable.Save()
if err != nil {
return nil, err
}
}
return kvs, nil
}
func (d *DPos) execLocal(receipt *types.ReceiptData) (*types.LocalDBSet, error) {
dbSet := &types.LocalDBSet{}
if receipt.GetTy() != types.ExecOk {
return dbSet, nil
}
for _, item := range receipt.Logs {
if item.Ty >= dty.CandidatorStatusRegist && item.Ty <= dty.CandidatorStatusCancelRegist {
var candLog dty.ReceiptCandicator
err := types.Decode(item.Log, &candLog)
if err != nil {
return nil, err
}
kvs, err := d.updateCandVote(&candLog)
if err != nil {
return nil, err
}
dbSet.KV = append(dbSet.KV, kvs...)
} else if item.Ty >= dty.VrfStatusMRegist && item.Ty <= dty.VrfStatusRPRegist {
var vrfLog dty.ReceiptVrf
err := types.Decode(item.Log, &vrfLog)
if err != nil {
return nil, err
}
kvs, err := d.updateVrf(&vrfLog)
if err != nil {
return nil, err
}
dbSet.KV = append(dbSet.KV, kvs...)
}
}
return dbSet, nil
}
//ExecLocal_Regist method
func (d *DPos) ExecLocal_Regist(payload *dty.DposCandidatorRegist, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return d.execLocal(receiptData)
}
//ExecLocal_CancelRegist method
func (d *DPos) ExecLocal_CancelRegist(payload *dty.DposCandidatorCancelRegist, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return d.execLocal(receiptData)
}
//ExecLocal_ReRegist method
func (d *DPos) ExecLocal_ReRegist(payload *dty.DposCandidatorRegist, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return d.execLocal(receiptData)
}
//ExecLocal_Vote method
func (d *DPos) ExecLocal_Vote(payload *dty.DposVote, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return d.execLocal(receiptData)
}
//ExecLocal_CancelVote method
func (d *DPos) ExecLocal_CancelVote(payload *dty.DposCancelVote, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return d.execLocal(receiptData)
}
//ExecLocal_VrfMRegist method
func (d *DPos) ExecLocal_VrfMRegist(payload *dty.DposVrfMRegist, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return d.execLocal(receiptData)
}
//ExecLocal_VrfRPRegist method
func (d *DPos) ExecLocal_VrfRPRegist(payload *dty.DposVrfRPRegist, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return d.execLocal(receiptData)
}
\ No newline at end of file
// 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 executor
import (
"github.com/33cn/chain33/types"
dty "github.com/33cn/plugin/plugin/dapp/dposvote/types"
)
//Query_QueryCandidatorByPubkeys method
func (d *DPos) Query_QueryCandidatorByPubkeys(in *dty.CandidatorQuery) (types.Message, error) {
return queryCands(d.GetLocalDB(), in)
}
//Query_QueryCandidatorByTopN method
func (d *DPos) Query_QueryCandidatorByTopN(in *dty.CandidatorQuery) (types.Message, error) {
return queryTopNCands(d.GetLocalDB(), in)
}
//Query_QueryVote method
func (d *DPos) Query_QueryVote(in *dty.DposVoteQuery) (types.Message, error) {
return queryVote(d.GetLocalDB(), in)
}
//Query_QueryVrfByTime method
func (d *DPos) Query_QueryVrfByTime(in *dty.DposVrfQuery) (types.Message, error) {
return queryVrfByTime(d.GetLocalDB(), in)
}
//Query_QueryVrfByCycle method
func (d *DPos) Query_QueryVrfByCycle(in *dty.DposVrfQuery) (types.Message, error) {
return queryVrfByCycle(d.GetLocalDB(), in)
}
// 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 dposvote
import (
"github.com/33cn/chain33/pluginmgr"
"github.com/33cn/plugin/plugin/dapp/dposvote/commands"
"github.com/33cn/plugin/plugin/dapp/dposvote/executor"
"github.com/33cn/plugin/plugin/dapp/dposvote/types"
)
func init() {
pluginmgr.Register(&pluginmgr.PluginBase{
Name: types.DPosX,
ExecName: executor.GetName(),
Exec: executor.Init,
Cmd: commands.DPosCmd,
})
}
all:
sh ./create_protobuf.sh
#!/bin/sh
protoc --go_out=plugins=grpc:../types ./*.proto --proto_path=. --proto_path="../../../../vendor/github.com/33cn/chain33/types/proto/"
syntax = "proto3";
package types;
//CandidatorInfo 候选节点信息
message CandidatorInfo {
bytes pubkey = 1; //候选节点的公钥
string address = 2; //后续节点的地址
string ip = 3; //候选节点的运行IP
int64 votes = 4; //候选节点的投票数
int64 status = 5; //候选节点的状态,0:注册,1:当选,2:取消注册
int64 preStatus = 6;
int64 startTime = 7; //创建候选者的时间
int64 startHeight = 8; //创建候选者的时间
string startTxHash = 9; //创建候选者的交易hash
int64 startIndex = 10; //创建候选者的交易index
int64 index = 11;
int64 preIndex = 12;
repeated DposVoter voters = 13;
}
message DposVoter{
string fromAddr = 1;
bytes pubkey = 2; //候选节点的公钥
int64 votes = 3; //投给候选节点的票数,不能超过锁在合约中的未使用票数
int64 index = 4;
int64 time = 5;
}
//Candidator 候选节点信息
message Candidator {
bytes pubkey = 1; //候选节点的公钥
string address = 2; //后续节点的地址
string ip = 3; //候选节点的运行IP
int64 votes = 4; //候选节点的投票数
int64 status = 5; //候选节点的状态,0:注册,1:当选,2:取消注册
}
//DposCandidatorRegist 注册Dpos候选节点,必须抵押一定数量的币,比如:10000个币
message DposCandidatorRegist{
string pubkey = 1; //候选节点的公钥
string address = 2; //候选节点的地址
string ip = 3; //候选节点的共识IP地址
}
//DposCandidatorCancelRegist 注销Dpos候选节点,解冻抵押的币
message DposCandidatorCancelRegist{
string pubkey = 1; //候选节点的公钥
string address = 2; //候选节点的地址
}
//DposVote 为Dpos候选节点投票
message DposVote{
string fromAddr = 1;
string pubkey = 2; //候选节点的公钥
int64 votes = 3; //投给候选节点的票数,不能超过锁在合约中的未使用票数
}
//DposCancelVote 撤销为Dpos候选节点投票
message DposCancelVote{
string pubkey = 1; //候选节点的公钥
int64 votes = 2; //撤销投给候选节点的票数,不超过之前投给该候选节点的总票数,投票3天之后才可以撤销投票
}
//DposVoteAction DposVote动作
message DposVoteAction {
oneof value {
DposCandidatorRegist regist = 1;
DposCandidatorCancelRegist cancelRegist = 2;
DposCandidatorRegist reRegist = 3;
DposVote vote = 4;
DposCancelVote cancelVote = 5;
CandidatorQuery candidatorQuery = 6;
DposVoteQuery voteQuery = 7;
DposVrfMRegist registVrfM = 8;
DposVrfRPRegist registVrfRP = 9;
DposVrfQuery vrfQuery = 10;
}
int32 ty = 11;
}
message CandidatorQuery{
repeated string pubkeys = 1; //候选节点公钥集合
int32 topN = 2; //topN
int32 ty = 3; //1:按公钥集合查询,2:按topN票数查询
}
message CandidatorReply{
repeated Candidator candidators = 1; //候选节点
}
message DposVoteQuery{
repeated string pubkeys = 1; //候选节点的公钥,如果为空,则查询所有,否则,查询该地址给具体候选节点的投票
string addr = 2; //要查询的地址
}
message DposVoteReply{
repeated DposVoter votes = 1; //某地址对具体候选节点的投票情况
}
//ReceiptCandicator 候选者收据信息
message ReceiptCandicator {
int64 Index = 1;
bytes pubkey = 2;
string address = 3;
int64 status = 4;
int64 preStatus = 5;
bool statusChange = 6;
bool voted = 7;
int64 votes = 8;
string fromAddr = 9;
CandidatorInfo candInfo = 10;
int64 time = 11;
}
message DposVrfM{
int64 Index = 1;
bytes pubkey = 2;
int64 cycle = 3;
int64 height = 4;
bytes m = 5; //vrf的输入
int64 time = 6;
}
message DposVrfRP{
int64 Index = 1;
bytes pubkey = 2;
int64 cycle = 3;
int64 height = 4;
bytes m = 5; //vrf的输入
bytes r = 6; //vrf的hash
bytes p = 7; //vrf的hash的proof
int64 time = 8;
}
message DposVrfMRegist{
string pubkey = 1;
int64 cycle = 2;
string m = 3; //vrf的输入
}
message DposVrfRPRegist{
string pubkey = 1;
int64 cycle = 2;
string r = 3; //vrf的hash
string p = 4; //vrf的hash的proof
}
//ReceiptVrf vrf收据信息
message ReceiptVrf {
int64 Index = 1;
bytes pubkey = 2;
int64 status = 3;
int64 cycle = 4;
int64 height = 5;
bytes m = 6;
bytes r = 7;
bytes p = 8;
int64 time = 9;
}
message VrfInfo {
int64 Index = 1;
bytes pubkey = 2;
int64 cycle = 4;
int64 height = 5;
bytes m = 6;
bytes r = 7;
bytes p = 8;
int64 time = 9;
}
message DposVrfQuery{
int64 ty = 1;
int64 timestamp = 2;
int64 cycle = 3;
}
message DposVrfReply{
repeated VrfInfo vrf = 1;
}
\ No newline at end of file
// 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 rpc_test
import (
"fmt"
"testing"
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/guess/types"
"github.com/stretchr/testify/assert"
_ "github.com/33cn/chain33/system"
_ "github.com/33cn/plugin/plugin"
)
func init() {
commonlog.SetLogLevel("error")
}
func TestJRPCChannel(t *testing.T) {
// 启动RPCmocker
mocker := testnode.New("--notset--", nil)
defer func() {
mocker.Close()
}()
mocker.Listen()
jrpcClient := mocker.GetJSONC()
assert.NotNil(t, jrpcClient)
testCases := []struct {
fn func(*testing.T, *jsonclient.JSONClient) error
}{
{fn: testStartRawTxCmd},
{fn: testBetRawTxCmd},
{fn: testStopBetRawTxCmd},
{fn: testPublishRawTxCmd},
{fn: testAbortRawTxCmd},
}
for _, testCase := range testCases {
err := testCase.fn(t, jrpcClient)
assert.Nil(t, err)
}
testCases = []struct {
fn func(*testing.T, *jsonclient.JSONClient) error
}{
{fn: testQueryGameByID},
{fn: testQueryGamesByAddr},
{fn: testQueryGamesByStatus},
{fn: testQueryGamesByAdminAddr},
{fn: testQueryGamesByAddrStatus},
{fn: testQueryGamesByAdminStatus},
{fn: testQueryGamesByCategoryStatus},
}
for index, testCase := range testCases {
err := testCase.fn(t, jrpcClient)
assert.Equal(t, err, types.ErrNotFound, fmt.Sprint(index))
}
testCases = []struct {
fn func(*testing.T, *jsonclient.JSONClient) error
}{
{fn: testQueryGamesByIDs},
}
for index, testCase := range testCases {
err := testCase.fn(t, jrpcClient)
assert.Equal(t, err, nil, fmt.Sprint(index))
}
}
func testStartRawTxCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
payload := &pty.GuessGameStart{Topic: "WorldCup Final", Options: "A:France;B:Claodia", Category: "football", MaxBetsOneTime: 100e8, MaxBetsNumber: 1000e8, DevFeeFactor: 5, DevFeeAddr: "1D6RFZNp2rh6QdbcZ1d7RWuBUz61We6SD7", PlatFeeFactor: 5, PlatFeeAddr: "1PHtChNt3UcfssR7v7trKSk3WJtAWjKjjX"}
params := &rpctypes.CreateTxIn{
Execer: types.ExecName(pty.GuessX),
ActionName: pty.CreateStartTx,
Payload: types.MustPBToJSON(payload),
}
var res string
return jrpc.Call("Chain33.CreateTransaction", params, &res)
}
func testBetRawTxCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
payload := &pty.GuessGameBet{GameID: "0x76dae82fcbe554d4b8df5ed1460d71dcac86a50864649a0df43e0c50b245f004", Option: "A", BetsNum: 5e8}
params := &rpctypes.CreateTxIn{
Execer: types.ExecName(pty.GuessX),
ActionName: pty.CreateBetTx,
Payload: types.MustPBToJSON(payload),
}
var res string
return jrpc.Call("Chain33.CreateTransaction", params, &res)
}
func testStopBetRawTxCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
payload := &pty.GuessGameStopBet{GameID: "0x76dae82fcbe554d4b8df5ed1460d71dcac86a50864649a0df43e0c50b245f004"}
params := &rpctypes.CreateTxIn{
Execer: types.ExecName(pty.GuessX),
ActionName: pty.CreateStopBetTx,
Payload: types.MustPBToJSON(payload),
}
var res string
return jrpc.Call("Chain33.CreateTransaction", params, &res)
}
func testPublishRawTxCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
payload := &pty.GuessGamePublish{GameID: "0x76dae82fcbe554d4b8df5ed1460d71dcac86a50864649a0df43e0c50b245f004", Result: "A"}
params := &rpctypes.CreateTxIn{
Execer: types.ExecName(pty.GuessX),
ActionName: pty.CreatePublishTx,
Payload: types.MustPBToJSON(payload),
}
var res string
return jrpc.Call("Chain33.CreateTransaction", params, &res)
}
func testAbortRawTxCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
payload := &pty.GuessGameAbort{GameID: "0x76dae82fcbe554d4b8df5ed1460d71dcac86a50864649a0df43e0c50b245f004"}
params := &rpctypes.CreateTxIn{
Execer: types.ExecName(pty.GuessX),
ActionName: pty.CreateAbortTx,
Payload: types.MustPBToJSON(payload),
}
var res string
return jrpc.Call("Chain33.CreateTransaction", params, &res)
}
func testQueryGameByID(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{}
var params rpctypes.Query4Jrpc
req := &pty.QueryGuessGameInfo{}
params.Execer = pty.GuessX
params.FuncName = pty.FuncNameQueryGameByID
params.Payload = types.MustPBToJSON(req)
rep = &pty.ReplyGuessGameInfo{}
return jrpc.Call("Chain33.Query", params, rep)
}
func testQueryGamesByAddr(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{}
var params rpctypes.Query4Jrpc
req := &pty.QueryGuessGameInfo{}
params.Execer = pty.GuessX
params.FuncName = pty.FuncNameQueryGameByAddr
params.Payload = types.MustPBToJSON(req)
rep = &pty.GuessGameRecords{}
return jrpc.Call("Chain33.Query", params, rep)
}
func testQueryGamesByIDs(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{}
var params rpctypes.Query4Jrpc
req := &pty.QueryGuessGameInfos{}
params.Execer = pty.GuessX
params.FuncName = pty.FuncNameQueryGamesByIDs
params.Payload = types.MustPBToJSON(req)
rep = &pty.ReplyGuessGameInfos{}
return jrpc.Call("Chain33.Query", params, rep)
}
func testQueryGamesByStatus(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{}
var params rpctypes.Query4Jrpc
req := &pty.QueryGuessGameInfo{}
params.Execer = pty.GuessX
params.FuncName = pty.FuncNameQueryGameByStatus
params.Payload = types.MustPBToJSON(req)
rep = &pty.GuessGameRecords{}
return jrpc.Call("Chain33.Query", params, rep)
}
func testQueryGamesByAdminAddr(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{}
var params rpctypes.Query4Jrpc
req := &pty.QueryGuessGameInfo{}
params.Execer = pty.GuessX
params.FuncName = pty.FuncNameQueryGameByAdminAddr
params.Payload = types.MustPBToJSON(req)
rep = &pty.GuessGameRecords{}
return jrpc.Call("Chain33.Query", params, rep)
}
func testQueryGamesByAddrStatus(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{}
var params rpctypes.Query4Jrpc
req := &pty.QueryGuessGameInfo{}
params.Execer = pty.GuessX
params.FuncName = pty.FuncNameQueryGameByAddrStatus
params.Payload = types.MustPBToJSON(req)
rep = &pty.GuessGameRecords{}
return jrpc.Call("Chain33.Query", params, rep)
}
func testQueryGamesByAdminStatus(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{}
var params rpctypes.Query4Jrpc
req := &pty.QueryGuessGameInfo{}
params.Execer = pty.GuessX
params.FuncName = pty.FuncNameQueryGameByAdminStatus
params.Payload = types.MustPBToJSON(req)
rep = &pty.GuessGameRecords{}
return jrpc.Call("Chain33.Query", params, rep)
}
func testQueryGamesByCategoryStatus(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{}
var params rpctypes.Query4Jrpc
req := &pty.QueryGuessGameInfo{}
params.Execer = pty.GuessX
params.FuncName = pty.FuncNameQueryGameByCategoryStatus
params.Payload = types.MustPBToJSON(req)
rep = &pty.GuessGameRecords{}
return jrpc.Call("Chain33.Query", params, rep)
}
// 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
//dpos action ty
const (
DposVoteActionRegist = iota + 1
DposVoteActionCancelRegist
DposVoteActionReRegist
DposVoteActionVote
DposVoteActionCancelVote
DposVoteActionRegistVrfM
DposVoteActionRegistVrfRP
CandidatorStatusRegist = iota + 1
CandidatorStatusVoted
CandidatorStatusCancelVoted
CandidatorStatusCancelRegist
VrfStatusMRegist = iota + 1
VrfStatusRPRegist
)
//log ty
const (
TyLogCandicatorRegist = 1001
TyLogCandicatorVoted = 1002
TyLogCandicatorCancelRegist = 1003
TyLogCandicatorReRegist = 1004
TyLogVrfMRegist = 1005
TyLogVrfRPRegist = 1006
)
const (
VoteFrozenTime = 3 * 24 * 3600
RegistFrozenCoins = 1000000000000
)
//包的名字可以通过配置文件来配置
//建议用github的组织名称,或者用户名字开头, 再加上自己的插件的名字
//如果发生重名,可以通过配置文件修改这些名字
var (
DPosX = "dpos"
ExecerDposVote = []byte(DPosX)
)
const (
//FuncNameQueryCandidatorByPubkeys func name
FuncNameQueryCandidatorByPubkeys = "QueryCandidatorByPubkeys"
//FuncNameQueryCandidatorByTopN func name
FuncNameQueryCandidatorByTopN = "QueryCandidatorByTopN"
//FuncNameQueryVrfByTime func name
FuncNameQueryVrfByTime = "QueryVrfByTime"
//FuncNameQueryVrfByCycle func name
FuncNameQueryVrfByCycle = "QueryVrfByCycle"
//FuncNameQueryVote func name
FuncNameQueryVote = "QueryVote"
//CreateRegistTx 创建注册候选节点交易
CreateRegistTx = "Regist"
//CreateCancelRegistTx 创建取消候选节点的交易
CreateCancelRegistTx = "CancelRegist"
//CreateReRegistTx 创建重新注册候选节点的交易
CreateReRegistTx = "ReRegist"
//CreateVoteTx 创建为候选节点投票的交易
CreateVoteTx = "Vote"
//CreateCancelVoteTx 创建取消对候选节点投票的交易
CreateCancelVoteTx = "CancelVote"
//CreateRegistVrfMTx 创建注册Vrf的M信息的交易
CreateRegistVrfMTx = "RegistVrfM"
//CreateRegistVrfRPTx 创建注册Vrf的R/P信息的交易
CreateRegistVrfRPTx = "RegistVrfRP"
//QueryVrfByTime 创建根据time查询Vrf信息查询
QueryVrfByTime = 1
//QueryVrfByCycle 创建根据cycle查询Vrf信息查询
QueryVrfByCycle = 2
)
// 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 "errors"
// Errors for Dpos
var (
ErrNotEnoughVotes = errors.New("ErrNotEnoughVotes")
ErrCandidatorExist = errors.New("ErrCandidatorExist")
ErrCandidatorInvalidStatus = errors.New("ErrCandidatorInvalidStatus")
ErrCandidatorNotExist = errors.New("ErrCandidatorNotExist")
ErrCandidatorNotEnough = errors.New("ErrCandidatorNotEnough")
ErrCandidatorNotLegal = errors.New("ErrCandidatorNotLegal")
ErrVrfMNotRegisted = errors.New("ErrVrfMNotRegisted")
ErrVrfMAlreadyRegisted = errors.New("ErrVrfMAlreadyRegisted")
ErrVrfRPAlreadyRegisted = errors.New("ErrVrfRPAlreadyRegisted")
ErrNoPrivilege = errors.New("ErrNoPrivilege")
ErrParamStatusInvalid = errors.New("ErrParamStatusInvalid")
ErrParamAddressMustnotEmpty = errors.New("ErrParamAddressMustnotEmpty")
ErrSaveTable = errors.New("ErrSaveTable")
)
package types
import (
"fmt"
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/common/db/table"
"github.com/33cn/chain33/types"
)
/*
table struct
data: voter
index: FromAddr,Pubkey,Votes,Index,Time
*/
var opt_dpos_voter = &table.Option{
Prefix: "LODB-dpos",
Name: "voter",
Primary: "index",
Index: []string{"addr", "pubkey"},
}
//NewDposVoteTable 新建表
func NewDposVoteTable(kvdb db.KV) *table.Table {
rowmeta := NewDposVoterRow()
table, err := table.NewTable(rowmeta, kvdb, opt_dpos_voter)
if err != nil {
panic(err)
}
return table
}
//DposVoterRow table meta 结构
type DposVoterRow struct {
*DposVoter
}
//NewDposVoterRow 新建一个meta 结构
func NewDposVoterRow() *DposVoterRow {
return &DposVoterRow{DposVoter: &DposVoter{}}
}
//CreateRow 新建数据行
func (tx *DposVoterRow) CreateRow() *table.Row {
return &table.Row{Data: &DposVoter{}}
}
//SetPayload 设置数据
func (tx *DposVoterRow) SetPayload(data types.Message) error {
if txdata, ok := data.(*DposVoter); ok {
tx.DposVoter = txdata
return nil
}
return types.ErrTypeAsset
}
//Get 按照indexName 查询 indexValue
func (tx *DposVoterRow) Get(key string) ([]byte, error) {
if key == "index" {
return []byte(fmt.Sprintf("%018d", tx.Index)), nil
} else if key == "addr" {
return []byte(tx.FromAddr), nil
} else if key == "pubkey" {
return tx.Pubkey, nil
}
return nil, types.ErrNotFound
}
var opt_dpos_candidator = &table.Option{
Prefix: "LODB-dpos",
Name: "candidator",
Primary: "pubkey",
Index: []string{"status"},
}
//NewDposCandidatorTable 新建表
func NewDposCandidatorTable(kvdb db.KV) *table.Table {
rowmeta := NewDposCandidatorRow()
table, err := table.NewTable(rowmeta, kvdb, opt_dpos_candidator)
if err != nil {
panic(err)
}
return table
}
//DposCandidatorRow table meta 结构
type DposCandidatorRow struct {
*CandidatorInfo
}
//NewDposCandidatorRow 新建一个meta 结构
func NewDposCandidatorRow() *DposCandidatorRow {
return &DposCandidatorRow{CandidatorInfo: &CandidatorInfo{}}
}
//CreateRow 新建数据行
func (tx *DposCandidatorRow) CreateRow() *table.Row {
return &table.Row{Data: &CandidatorInfo{}}
}
//SetPayload 设置数据
func (tx *DposCandidatorRow) SetPayload(data types.Message) error {
if txdata, ok := data.(*CandidatorInfo); ok {
tx.CandidatorInfo = txdata
return nil
}
return types.ErrTypeAsset
}
//Get 按照indexName 查询 indexValue
func (tx *DposCandidatorRow) Get(key string) ([]byte, error) {
if key == "pubkey" {
return tx.Pubkey, nil
} else if key == "status" {
return []byte(fmt.Sprintf("%2d", tx.Status)), nil
}
return nil, types.ErrNotFound
}
var opt_dpos_vrfm = &table.Option{
Prefix: "LODB-dpos",
Name: "vrfm",
Primary: "index",
Index: []string{"pubkey_cycle"},
}
//NewDposVrfMTable 新建表
func NewDposVrfMTable(kvdb db.KV) *table.Table {
rowmeta := NewDposVrfMRow()
table, err := table.NewTable(rowmeta, kvdb, opt_dpos_vrfm)
if err != nil {
panic(err)
}
return table
}
//DposVrfMRow table meta 结构
type DposVrfMRow struct {
*DposVrfM
}
//NewDposVrfMRow 新建一个meta 结构
func NewDposVrfMRow() *DposVrfMRow {
return &DposVrfMRow{DposVrfM: &DposVrfM{}}
}
//CreateRow 新建数据行
func (tx *DposVrfMRow) CreateRow() *table.Row {
return &table.Row{Data: &DposVrfM{}}
}
//SetPayload 设置数据
func (tx *DposVrfMRow) SetPayload(data types.Message) error {
if txdata, ok := data.(*DposVrfM); ok {
tx.DposVrfM = txdata
return nil
}
return types.ErrTypeAsset
}
//Get 按照indexName 查询 indexValue
func (tx *DposVrfMRow) Get(key string) ([]byte, error) {
if key == "index" {
return []byte(fmt.Sprintf("%018d", tx.Index)), nil
} else if key == "pubkey_cycle" {
return []byte(fmt.Sprintf("%X:%018d", tx.Pubkey, tx.Cycle)), nil
}
return nil, types.ErrNotFound
}
var opt_dpos_vrfrp = &table.Option{
Prefix: "LODB-dpos",
Name: "vrfrp",
Primary: "index",
Index: []string{"pubkey_cycle"},
}
//NewDposVrfRPTable 新建表
func NewDposVrfRPTable(kvdb db.KV) *table.Table {
rowmeta := NewDposVrfRPRow()
table, err := table.NewTable(rowmeta, kvdb, opt_dpos_vrfrp)
if err != nil {
panic(err)
}
return table
}
//DposVrfRPRow table meta 结构
type DposVrfRPRow struct {
*DposVrfRP
}
//NewDposVrfRPRow 新建一个meta 结构
func NewDposVrfRPRow() *DposVrfRPRow {
return &DposVrfRPRow{DposVrfRP: &DposVrfRP{}}
}
//CreateRow 新建数据行
func (tx *DposVrfRPRow) CreateRow() *table.Row {
return &table.Row{Data: &DposVrfRP{}}
}
//SetPayload 设置数据
func (tx *DposVrfRPRow) SetPayload(data types.Message) error {
if txdata, ok := data.(*DposVrfRP); ok {
tx.DposVrfRP = txdata
return nil
}
return types.ErrTypeAsset
}
//Get 按照indexName 查询 indexValue
func (tx *DposVrfRPRow) Get(key string) ([]byte, error) {
if key == "index" {
return []byte(fmt.Sprintf("%018d", tx.Index)), nil
} else if key == "pubkey_cycle" {
return []byte(fmt.Sprintf("%X:%018d", tx.Pubkey, tx.Cycle)), nil
}
return nil, types.ErrNotFound
}
// 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 (
"reflect"
"github.com/33cn/chain33/types"
)
func init() {
// init executor type
types.RegistorExecutor(DPosX, NewType())
types.AllowUserExec = append(types.AllowUserExec, ExecerDposVote)
types.RegisterDappFork(DPosX, "Enable", 0)
}
// GuessType struct
type DPosType struct {
types.ExecTypeBase
}
// NewType method
func NewType() *DPosType {
c := &DPosType{}
c.SetChild(c)
return c
}
// GetPayload method
func (t *DPosType) GetPayload() types.Message {
return &DposVoteAction{}
}
// GetTypeMap method
func (t *DPosType) GetTypeMap() map[string]int32 {
return map[string]int32{
"Regist": DposVoteActionRegist,
"CancelRegist": DposVoteActionCancelRegist,
"ReRegist": DposVoteActionReRegist,
"Vote": DposVoteActionVote,
"CancelVote": DposVoteActionCancelVote,
"RegistVrfM": DposVoteActionRegistVrfM,
"RegistVrfRP": DposVoteActionRegistVrfRP,
}
}
// GetLogMap method
func (t *DPosType) GetLogMap() map[int64]*types.LogInfo {
return map[int64]*types.LogInfo{
TyLogCandicatorRegist: {Ty: reflect.TypeOf(ReceiptCandicator{}), Name: "TyLogCandicatorRegist"},
TyLogCandicatorVoted: {Ty: reflect.TypeOf(ReceiptCandicator{}), Name: "TyLogCandicatorVoted"},
TyLogCandicatorCancelRegist: {Ty: reflect.TypeOf(ReceiptCandicator{}), Name: "TyLogCandicatorCancelRegist"},
TyLogVrfMRegist: {Ty: reflect.TypeOf(ReceiptVrf{}), Name: "TyLogVrfMRegist"},
TyLogVrfRPRegist: {Ty: reflect.TypeOf(ReceiptVrf{}), Name: "TyLogVrfRPRegist"},
}
}
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: guess.proto
/*
Package types is a generated protocol buffer package.
It is generated from these files:
guess.proto
It has these top-level messages:
GuessGame
GuessPlayer
GuessBet
GuessBetStat
GuessBetStatItem
GuessGameAction
GuessGameStart
GuessGameBet
GuessGameStopBet
GuessGameAbort
GuessGamePublish
GuessGameQuery
QueryGuessGameInfo
ReplyGuessGameInfo
QueryGuessGameInfos
ReplyGuessGameInfos
ReceiptGuessGame
UserBet
GuessStartTxReq
GuessBetTxReq
GuessStopBetTxReq
GuessAbortTxReq
GuessPublishTxReq
GuessGameRecord
GuessGameRecords
*/
package types
import (
context "context"
fmt "fmt"
math "math"
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import types2 "github.com/33cn/chain33/types"
types "github.com/33cn/chain33/types"
proto "github.com/golang/protobuf/proto"
import (
context "golang.org/x/net/context"
grpc "google.golang.org/grpc"
)
......@@ -24,63 +57,40 @@ var _ = math.Inf
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
//GuessGame 竞猜游戏详情
// GuessGame 竞猜游戏详情
type GuessGame struct {
GameID string `protobuf:"bytes,1,opt,name=gameID,proto3" json:"gameID,omitempty"`
Status int32 `protobuf:"varint,2,opt,name=status,proto3" json:"status,omitempty"`
PreStatus int32 `protobuf:"varint,3,opt,name=preStatus,proto3" json:"preStatus,omitempty"`
StartTime int64 `protobuf:"varint,4,opt,name=startTime,proto3" json:"startTime,omitempty"`
StartHeight int64 `protobuf:"varint,5,opt,name=startHeight,proto3" json:"startHeight,omitempty"`
StartTxHash string `protobuf:"bytes,6,opt,name=startTxHash,proto3" json:"startTxHash,omitempty"`
StartIndex int64 `protobuf:"varint,7,opt,name=startIndex,proto3" json:"startIndex,omitempty"`
Topic string `protobuf:"bytes,8,opt,name=topic,proto3" json:"topic,omitempty"`
Category string `protobuf:"bytes,9,opt,name=category,proto3" json:"category,omitempty"`
Options string `protobuf:"bytes,10,opt,name=options,proto3" json:"options,omitempty"`
MaxBetHeight int64 `protobuf:"varint,11,opt,name=maxBetHeight,proto3" json:"maxBetHeight,omitempty"`
MaxBetsOneTime int64 `protobuf:"varint,12,opt,name=maxBetsOneTime,proto3" json:"maxBetsOneTime,omitempty"`
MaxBetsNumber int64 `protobuf:"varint,13,opt,name=maxBetsNumber,proto3" json:"maxBetsNumber,omitempty"`
DevFeeFactor int64 `protobuf:"varint,14,opt,name=devFeeFactor,proto3" json:"devFeeFactor,omitempty"`
DevFeeAddr string `protobuf:"bytes,15,opt,name=devFeeAddr,proto3" json:"devFeeAddr,omitempty"`
PlatFeeFactor int64 `protobuf:"varint,16,opt,name=platFeeFactor,proto3" json:"platFeeFactor,omitempty"`
PlatFeeAddr string `protobuf:"bytes,17,opt,name=platFeeAddr,proto3" json:"platFeeAddr,omitempty"`
ExpireHeight int64 `protobuf:"varint,18,opt,name=expireHeight,proto3" json:"expireHeight,omitempty"`
AdminAddr string `protobuf:"bytes,19,opt,name=adminAddr,proto3" json:"adminAddr,omitempty"`
BetsNumber int64 `protobuf:"varint,20,opt,name=betsNumber,proto3" json:"betsNumber,omitempty"`
Plays []*GuessPlayer `protobuf:"bytes,21,rep,name=plays,proto3" json:"plays,omitempty"`
Result string `protobuf:"bytes,22,opt,name=result,proto3" json:"result,omitempty"`
BetStat *GuessBetStat `protobuf:"bytes,23,opt,name=betStat,proto3" json:"betStat,omitempty"`
Index int64 `protobuf:"varint,24,opt,name=index,proto3" json:"index,omitempty"`
PreIndex int64 `protobuf:"varint,25,opt,name=preIndex,proto3" json:"preIndex,omitempty"`
DrivenByAdmin bool `protobuf:"varint,26,opt,name=drivenByAdmin,proto3" json:"drivenByAdmin,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GuessGame) Reset() { *m = GuessGame{} }
func (m *GuessGame) String() string { return proto.CompactTextString(m) }
func (*GuessGame) ProtoMessage() {}
func (*GuessGame) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{0}
}
func (m *GuessGame) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GuessGame.Unmarshal(m, b)
}
func (m *GuessGame) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GuessGame.Marshal(b, m, deterministic)
}
func (m *GuessGame) XXX_Merge(src proto.Message) {
xxx_messageInfo_GuessGame.Merge(m, src)
}
func (m *GuessGame) XXX_Size() int {
return xxx_messageInfo_GuessGame.Size(m)
}
func (m *GuessGame) XXX_DiscardUnknown() {
xxx_messageInfo_GuessGame.DiscardUnknown(m)
}
var xxx_messageInfo_GuessGame proto.InternalMessageInfo
GameID string `protobuf:"bytes,1,opt,name=gameID" json:"gameID,omitempty"`
Status int32 `protobuf:"varint,2,opt,name=status" json:"status,omitempty"`
PreStatus int32 `protobuf:"varint,3,opt,name=preStatus" json:"preStatus,omitempty"`
StartTime int64 `protobuf:"varint,4,opt,name=startTime" json:"startTime,omitempty"`
StartHeight int64 `protobuf:"varint,5,opt,name=startHeight" json:"startHeight,omitempty"`
StartTxHash string `protobuf:"bytes,6,opt,name=startTxHash" json:"startTxHash,omitempty"`
StartIndex int64 `protobuf:"varint,7,opt,name=startIndex" json:"startIndex,omitempty"`
Topic string `protobuf:"bytes,8,opt,name=topic" json:"topic,omitempty"`
Category string `protobuf:"bytes,9,opt,name=category" json:"category,omitempty"`
Options string `protobuf:"bytes,10,opt,name=options" json:"options,omitempty"`
MaxBetHeight int64 `protobuf:"varint,11,opt,name=maxBetHeight" json:"maxBetHeight,omitempty"`
MaxBetsOneTime int64 `protobuf:"varint,12,opt,name=maxBetsOneTime" json:"maxBetsOneTime,omitempty"`
MaxBetsNumber int64 `protobuf:"varint,13,opt,name=maxBetsNumber" json:"maxBetsNumber,omitempty"`
DevFeeFactor int64 `protobuf:"varint,14,opt,name=devFeeFactor" json:"devFeeFactor,omitempty"`
DevFeeAddr string `protobuf:"bytes,15,opt,name=devFeeAddr" json:"devFeeAddr,omitempty"`
PlatFeeFactor int64 `protobuf:"varint,16,opt,name=platFeeFactor" json:"platFeeFactor,omitempty"`
PlatFeeAddr string `protobuf:"bytes,17,opt,name=platFeeAddr" json:"platFeeAddr,omitempty"`
ExpireHeight int64 `protobuf:"varint,18,opt,name=expireHeight" json:"expireHeight,omitempty"`
AdminAddr string `protobuf:"bytes,19,opt,name=adminAddr" json:"adminAddr,omitempty"`
BetsNumber int64 `protobuf:"varint,20,opt,name=betsNumber" json:"betsNumber,omitempty"`
Plays []*GuessPlayer `protobuf:"bytes,21,rep,name=plays" json:"plays,omitempty"`
Result string `protobuf:"bytes,22,opt,name=result" json:"result,omitempty"`
BetStat *GuessBetStat `protobuf:"bytes,23,opt,name=betStat" json:"betStat,omitempty"`
Index int64 `protobuf:"varint,24,opt,name=index" json:"index,omitempty"`
PreIndex int64 `protobuf:"varint,25,opt,name=preIndex" json:"preIndex,omitempty"`
DrivenByAdmin bool `protobuf:"varint,26,opt,name=drivenByAdmin" json:"drivenByAdmin,omitempty"`
}
func (m *GuessGame) Reset() { *m = GuessGame{} }
func (m *GuessGame) String() string { return proto.CompactTextString(m) }
func (*GuessGame) ProtoMessage() {}
func (*GuessGame) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *GuessGame) GetGameID() string {
if m != nil {
......@@ -264,39 +274,16 @@ func (m *GuessGame) GetDrivenByAdmin() bool {
return false
}
//GuessPlayer 竞猜玩家信息
// GuessPlayer 竞猜玩家信息
type GuessPlayer struct {
Addr string `protobuf:"bytes,1,opt,name=addr,proto3" json:"addr,omitempty"`
Bet *GuessBet `protobuf:"bytes,2,opt,name=bet,proto3" json:"bet,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
Addr string `protobuf:"bytes,1,opt,name=addr" json:"addr,omitempty"`
Bet *GuessBet `protobuf:"bytes,2,opt,name=bet" json:"bet,omitempty"`
}
func (m *GuessPlayer) Reset() { *m = GuessPlayer{} }
func (m *GuessPlayer) String() string { return proto.CompactTextString(m) }
func (*GuessPlayer) ProtoMessage() {}
func (*GuessPlayer) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{1}
}
func (m *GuessPlayer) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GuessPlayer.Unmarshal(m, b)
}
func (m *GuessPlayer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GuessPlayer.Marshal(b, m, deterministic)
}
func (m *GuessPlayer) XXX_Merge(src proto.Message) {
xxx_messageInfo_GuessPlayer.Merge(m, src)
}
func (m *GuessPlayer) XXX_Size() int {
return xxx_messageInfo_GuessPlayer.Size(m)
}
func (m *GuessPlayer) XXX_DiscardUnknown() {
xxx_messageInfo_GuessPlayer.DiscardUnknown(m)
}
var xxx_messageInfo_GuessPlayer proto.InternalMessageInfo
func (m *GuessPlayer) Reset() { *m = GuessPlayer{} }
func (m *GuessPlayer) String() string { return proto.CompactTextString(m) }
func (*GuessPlayer) ProtoMessage() {}
func (*GuessPlayer) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
func (m *GuessPlayer) GetAddr() string {
if m != nil {
......@@ -312,43 +299,20 @@ func (m *GuessPlayer) GetBet() *GuessBet {
return nil
}
//GuessBet 竞猜下注信息
// GuessBet 竞猜下注信息
type GuessBet struct {
Option string `protobuf:"bytes,1,opt,name=option,proto3" json:"option,omitempty"`
BetsNumber int64 `protobuf:"varint,2,opt,name=betsNumber,proto3" json:"betsNumber,omitempty"`
IsWinner bool `protobuf:"varint,3,opt,name=isWinner,proto3" json:"isWinner,omitempty"`
Profit int64 `protobuf:"varint,4,opt,name=profit,proto3" json:"profit,omitempty"`
Index int64 `protobuf:"varint,5,opt,name=index,proto3" json:"index,omitempty"`
PreIndex int64 `protobuf:"varint,6,opt,name=preIndex,proto3" json:"preIndex,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
Option string `protobuf:"bytes,1,opt,name=option" json:"option,omitempty"`
BetsNumber int64 `protobuf:"varint,2,opt,name=betsNumber" json:"betsNumber,omitempty"`
IsWinner bool `protobuf:"varint,3,opt,name=isWinner" json:"isWinner,omitempty"`
Profit int64 `protobuf:"varint,4,opt,name=profit" json:"profit,omitempty"`
Index int64 `protobuf:"varint,5,opt,name=index" json:"index,omitempty"`
PreIndex int64 `protobuf:"varint,6,opt,name=preIndex" json:"preIndex,omitempty"`
}
func (m *GuessBet) Reset() { *m = GuessBet{} }
func (m *GuessBet) String() string { return proto.CompactTextString(m) }
func (*GuessBet) ProtoMessage() {}
func (*GuessBet) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{2}
}
func (m *GuessBet) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GuessBet.Unmarshal(m, b)
}
func (m *GuessBet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GuessBet.Marshal(b, m, deterministic)
}
func (m *GuessBet) XXX_Merge(src proto.Message) {
xxx_messageInfo_GuessBet.Merge(m, src)
}
func (m *GuessBet) XXX_Size() int {
return xxx_messageInfo_GuessBet.Size(m)
}
func (m *GuessBet) XXX_DiscardUnknown() {
xxx_messageInfo_GuessBet.DiscardUnknown(m)
}
var xxx_messageInfo_GuessBet proto.InternalMessageInfo
func (m *GuessBet) Reset() { *m = GuessBet{} }
func (m *GuessBet) String() string { return proto.CompactTextString(m) }
func (*GuessBet) ProtoMessage() {}
func (*GuessBet) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
func (m *GuessBet) GetOption() string {
if m != nil {
......@@ -392,40 +356,17 @@ func (m *GuessBet) GetPreIndex() int64 {
return 0
}
//GuessBetStat 竞猜下注统计信息
// GuessBetStat 竞猜下注统计信息
type GuessBetStat struct {
TotalBetTimes int64 `protobuf:"varint,1,opt,name=totalBetTimes,proto3" json:"totalBetTimes,omitempty"`
TotalBetsNumber int64 `protobuf:"varint,2,opt,name=totalBetsNumber,proto3" json:"totalBetsNumber,omitempty"`
Items []*GuessBetStatItem `protobuf:"bytes,3,rep,name=items,proto3" json:"items,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GuessBetStat) Reset() { *m = GuessBetStat{} }
func (m *GuessBetStat) String() string { return proto.CompactTextString(m) }
func (*GuessBetStat) ProtoMessage() {}
func (*GuessBetStat) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{3}
TotalBetTimes int64 `protobuf:"varint,1,opt,name=totalBetTimes" json:"totalBetTimes,omitempty"`
TotalBetsNumber int64 `protobuf:"varint,2,opt,name=totalBetsNumber" json:"totalBetsNumber,omitempty"`
Items []*GuessBetStatItem `protobuf:"bytes,3,rep,name=items" json:"items,omitempty"`
}
func (m *GuessBetStat) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GuessBetStat.Unmarshal(m, b)
}
func (m *GuessBetStat) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GuessBetStat.Marshal(b, m, deterministic)
}
func (m *GuessBetStat) XXX_Merge(src proto.Message) {
xxx_messageInfo_GuessBetStat.Merge(m, src)
}
func (m *GuessBetStat) XXX_Size() int {
return xxx_messageInfo_GuessBetStat.Size(m)
}
func (m *GuessBetStat) XXX_DiscardUnknown() {
xxx_messageInfo_GuessBetStat.DiscardUnknown(m)
}
var xxx_messageInfo_GuessBetStat proto.InternalMessageInfo
func (m *GuessBetStat) Reset() { *m = GuessBetStat{} }
func (m *GuessBetStat) String() string { return proto.CompactTextString(m) }
func (*GuessBetStat) ProtoMessage() {}
func (*GuessBetStat) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
func (m *GuessBetStat) GetTotalBetTimes() int64 {
if m != nil {
......@@ -448,40 +389,17 @@ func (m *GuessBetStat) GetItems() []*GuessBetStatItem {
return nil
}
//GuessBetStat 竞猜下注子选项统计信息
// GuessBetStat 竞猜下注子选项统计信息
type GuessBetStatItem struct {
Option string `protobuf:"bytes,1,opt,name=option,proto3" json:"option,omitempty"`
BetsNumber int64 `protobuf:"varint,2,opt,name=betsNumber,proto3" json:"betsNumber,omitempty"`
BetsTimes int64 `protobuf:"varint,3,opt,name=betsTimes,proto3" json:"betsTimes,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GuessBetStatItem) Reset() { *m = GuessBetStatItem{} }
func (m *GuessBetStatItem) String() string { return proto.CompactTextString(m) }
func (*GuessBetStatItem) ProtoMessage() {}
func (*GuessBetStatItem) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{4}
}
func (m *GuessBetStatItem) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GuessBetStatItem.Unmarshal(m, b)
}
func (m *GuessBetStatItem) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GuessBetStatItem.Marshal(b, m, deterministic)
}
func (m *GuessBetStatItem) XXX_Merge(src proto.Message) {
xxx_messageInfo_GuessBetStatItem.Merge(m, src)
}
func (m *GuessBetStatItem) XXX_Size() int {
return xxx_messageInfo_GuessBetStatItem.Size(m)
}
func (m *GuessBetStatItem) XXX_DiscardUnknown() {
xxx_messageInfo_GuessBetStatItem.DiscardUnknown(m)
Option string `protobuf:"bytes,1,opt,name=option" json:"option,omitempty"`
BetsNumber int64 `protobuf:"varint,2,opt,name=betsNumber" json:"betsNumber,omitempty"`
BetsTimes int64 `protobuf:"varint,3,opt,name=betsTimes" json:"betsTimes,omitempty"`
}
var xxx_messageInfo_GuessBetStatItem proto.InternalMessageInfo
func (m *GuessBetStatItem) Reset() { *m = GuessBetStatItem{} }
func (m *GuessBetStatItem) String() string { return proto.CompactTextString(m) }
func (*GuessBetStatItem) ProtoMessage() {}
func (*GuessBetStatItem) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
func (m *GuessBetStatItem) GetOption() string {
if m != nil {
......@@ -504,7 +422,7 @@ func (m *GuessBetStatItem) GetBetsTimes() int64 {
return 0
}
//GuessGameAction 竞猜游戏动作
// GuessGameAction 竞猜游戏动作
type GuessGameAction struct {
// Types that are valid to be assigned to Value:
// *GuessGameAction_Start
......@@ -513,77 +431,44 @@ type GuessGameAction struct {
// *GuessGameAction_Abort
// *GuessGameAction_Publish
// *GuessGameAction_Query
Value isGuessGameAction_Value `protobuf_oneof:"value"`
Ty int32 `protobuf:"varint,7,opt,name=ty,proto3" json:"ty,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GuessGameAction) Reset() { *m = GuessGameAction{} }
func (m *GuessGameAction) String() string { return proto.CompactTextString(m) }
func (*GuessGameAction) ProtoMessage() {}
func (*GuessGameAction) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{5}
}
func (m *GuessGameAction) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GuessGameAction.Unmarshal(m, b)
}
func (m *GuessGameAction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GuessGameAction.Marshal(b, m, deterministic)
}
func (m *GuessGameAction) XXX_Merge(src proto.Message) {
xxx_messageInfo_GuessGameAction.Merge(m, src)
}
func (m *GuessGameAction) XXX_Size() int {
return xxx_messageInfo_GuessGameAction.Size(m)
}
func (m *GuessGameAction) XXX_DiscardUnknown() {
xxx_messageInfo_GuessGameAction.DiscardUnknown(m)
Value isGuessGameAction_Value `protobuf_oneof:"value"`
Ty int32 `protobuf:"varint,7,opt,name=ty" json:"ty,omitempty"`
}
var xxx_messageInfo_GuessGameAction proto.InternalMessageInfo
func (m *GuessGameAction) Reset() { *m = GuessGameAction{} }
func (m *GuessGameAction) String() string { return proto.CompactTextString(m) }
func (*GuessGameAction) ProtoMessage() {}
func (*GuessGameAction) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} }
type isGuessGameAction_Value interface {
isGuessGameAction_Value()
}
type GuessGameAction_Start struct {
Start *GuessGameStart `protobuf:"bytes,1,opt,name=start,proto3,oneof"`
Start *GuessGameStart `protobuf:"bytes,1,opt,name=start,oneof"`
}
type GuessGameAction_Bet struct {
Bet *GuessGameBet `protobuf:"bytes,2,opt,name=bet,proto3,oneof"`
Bet *GuessGameBet `protobuf:"bytes,2,opt,name=bet,oneof"`
}
type GuessGameAction_StopBet struct {
StopBet *GuessGameStopBet `protobuf:"bytes,3,opt,name=stopBet,proto3,oneof"`
StopBet *GuessGameStopBet `protobuf:"bytes,3,opt,name=stopBet,oneof"`
}
type GuessGameAction_Abort struct {
Abort *GuessGameAbort `protobuf:"bytes,4,opt,name=abort,proto3,oneof"`
Abort *GuessGameAbort `protobuf:"bytes,4,opt,name=abort,oneof"`
}
type GuessGameAction_Publish struct {
Publish *GuessGamePublish `protobuf:"bytes,5,opt,name=publish,proto3,oneof"`
Publish *GuessGamePublish `protobuf:"bytes,5,opt,name=publish,oneof"`
}
type GuessGameAction_Query struct {
Query *GuessGameQuery `protobuf:"bytes,6,opt,name=query,proto3,oneof"`
Query *GuessGameQuery `protobuf:"bytes,6,opt,name=query,oneof"`
}
func (*GuessGameAction_Start) isGuessGameAction_Value() {}
func (*GuessGameAction_Bet) isGuessGameAction_Value() {}
func (*GuessGameAction_Start) isGuessGameAction_Value() {}
func (*GuessGameAction_Bet) isGuessGameAction_Value() {}
func (*GuessGameAction_StopBet) isGuessGameAction_Value() {}
func (*GuessGameAction_Abort) isGuessGameAction_Value() {}
func (*GuessGameAction_Abort) isGuessGameAction_Value() {}
func (*GuessGameAction_Publish) isGuessGameAction_Value() {}
func (*GuessGameAction_Query) isGuessGameAction_Value() {}
func (*GuessGameAction_Query) isGuessGameAction_Value() {}
func (m *GuessGameAction) GetValue() isGuessGameAction_Value {
if m != nil {
......@@ -756,32 +641,32 @@ func _GuessGameAction_OneofSizer(msg proto.Message) (n int) {
switch x := m.Value.(type) {
case *GuessGameAction_Start:
s := proto.Size(x.Start)
n += 1 // tag and wire
n += proto.SizeVarint(1<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *GuessGameAction_Bet:
s := proto.Size(x.Bet)
n += 1 // tag and wire
n += proto.SizeVarint(2<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *GuessGameAction_StopBet:
s := proto.Size(x.StopBet)
n += 1 // tag and wire
n += proto.SizeVarint(3<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *GuessGameAction_Abort:
s := proto.Size(x.Abort)
n += 1 // tag and wire
n += proto.SizeVarint(4<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *GuessGameAction_Publish:
s := proto.Size(x.Publish)
n += 1 // tag and wire
n += proto.SizeVarint(5<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *GuessGameAction_Query:
s := proto.Size(x.Query)
n += 1 // tag and wire
n += proto.SizeVarint(6<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case nil:
......@@ -791,49 +676,26 @@ func _GuessGameAction_OneofSizer(msg proto.Message) (n int) {
return n
}
//GuessGameStart 游戏创建
// GuessGameStart 游戏创建
type GuessGameStart struct {
Topic string `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"`
Options string `protobuf:"bytes,2,opt,name=options,proto3" json:"options,omitempty"`
Category string `protobuf:"bytes,3,opt,name=category,proto3" json:"category,omitempty"`
MaxBetHeight int64 `protobuf:"varint,4,opt,name=maxBetHeight,proto3" json:"maxBetHeight,omitempty"`
MaxBetsOneTime int64 `protobuf:"varint,5,opt,name=maxBetsOneTime,proto3" json:"maxBetsOneTime,omitempty"`
MaxBetsNumber int64 `protobuf:"varint,6,opt,name=maxBetsNumber,proto3" json:"maxBetsNumber,omitempty"`
DevFeeFactor int64 `protobuf:"varint,7,opt,name=devFeeFactor,proto3" json:"devFeeFactor,omitempty"`
DevFeeAddr string `protobuf:"bytes,8,opt,name=devFeeAddr,proto3" json:"devFeeAddr,omitempty"`
PlatFeeFactor int64 `protobuf:"varint,9,opt,name=platFeeFactor,proto3" json:"platFeeFactor,omitempty"`
PlatFeeAddr string `protobuf:"bytes,10,opt,name=platFeeAddr,proto3" json:"platFeeAddr,omitempty"`
ExpireHeight int64 `protobuf:"varint,11,opt,name=expireHeight,proto3" json:"expireHeight,omitempty"`
DrivenByAdmin bool `protobuf:"varint,12,opt,name=drivenByAdmin,proto3" json:"drivenByAdmin,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GuessGameStart) Reset() { *m = GuessGameStart{} }
func (m *GuessGameStart) String() string { return proto.CompactTextString(m) }
func (*GuessGameStart) ProtoMessage() {}
func (*GuessGameStart) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{6}
}
func (m *GuessGameStart) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GuessGameStart.Unmarshal(m, b)
}
func (m *GuessGameStart) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GuessGameStart.Marshal(b, m, deterministic)
}
func (m *GuessGameStart) XXX_Merge(src proto.Message) {
xxx_messageInfo_GuessGameStart.Merge(m, src)
}
func (m *GuessGameStart) XXX_Size() int {
return xxx_messageInfo_GuessGameStart.Size(m)
}
func (m *GuessGameStart) XXX_DiscardUnknown() {
xxx_messageInfo_GuessGameStart.DiscardUnknown(m)
}
var xxx_messageInfo_GuessGameStart proto.InternalMessageInfo
Topic string `protobuf:"bytes,1,opt,name=topic" json:"topic,omitempty"`
Options string `protobuf:"bytes,2,opt,name=options" json:"options,omitempty"`
Category string `protobuf:"bytes,3,opt,name=category" json:"category,omitempty"`
MaxBetHeight int64 `protobuf:"varint,4,opt,name=maxBetHeight" json:"maxBetHeight,omitempty"`
MaxBetsOneTime int64 `protobuf:"varint,5,opt,name=maxBetsOneTime" json:"maxBetsOneTime,omitempty"`
MaxBetsNumber int64 `protobuf:"varint,6,opt,name=maxBetsNumber" json:"maxBetsNumber,omitempty"`
DevFeeFactor int64 `protobuf:"varint,7,opt,name=devFeeFactor" json:"devFeeFactor,omitempty"`
DevFeeAddr string `protobuf:"bytes,8,opt,name=devFeeAddr" json:"devFeeAddr,omitempty"`
PlatFeeFactor int64 `protobuf:"varint,9,opt,name=platFeeFactor" json:"platFeeFactor,omitempty"`
PlatFeeAddr string `protobuf:"bytes,10,opt,name=platFeeAddr" json:"platFeeAddr,omitempty"`
ExpireHeight int64 `protobuf:"varint,11,opt,name=expireHeight" json:"expireHeight,omitempty"`
DrivenByAdmin bool `protobuf:"varint,12,opt,name=drivenByAdmin" json:"drivenByAdmin,omitempty"`
}
func (m *GuessGameStart) Reset() { *m = GuessGameStart{} }
func (m *GuessGameStart) String() string { return proto.CompactTextString(m) }
func (*GuessGameStart) ProtoMessage() {}
func (*GuessGameStart) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} }
func (m *GuessGameStart) GetTopic() string {
if m != nil {
......@@ -919,40 +781,17 @@ func (m *GuessGameStart) GetDrivenByAdmin() bool {
return false
}
//GuessGameBet 参与游戏下注
// GuessGameBet 参与游戏下注
type GuessGameBet struct {
GameID string `protobuf:"bytes,1,opt,name=gameID,proto3" json:"gameID,omitempty"`
Option string `protobuf:"bytes,2,opt,name=option,proto3" json:"option,omitempty"`
BetsNum int64 `protobuf:"varint,3,opt,name=betsNum,proto3" json:"betsNum,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
GameID string `protobuf:"bytes,1,opt,name=gameID" json:"gameID,omitempty"`
Option string `protobuf:"bytes,2,opt,name=option" json:"option,omitempty"`
BetsNum int64 `protobuf:"varint,3,opt,name=betsNum" json:"betsNum,omitempty"`
}
func (m *GuessGameBet) Reset() { *m = GuessGameBet{} }
func (m *GuessGameBet) String() string { return proto.CompactTextString(m) }
func (*GuessGameBet) ProtoMessage() {}
func (*GuessGameBet) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{7}
}
func (m *GuessGameBet) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GuessGameBet.Unmarshal(m, b)
}
func (m *GuessGameBet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GuessGameBet.Marshal(b, m, deterministic)
}
func (m *GuessGameBet) XXX_Merge(src proto.Message) {
xxx_messageInfo_GuessGameBet.Merge(m, src)
}
func (m *GuessGameBet) XXX_Size() int {
return xxx_messageInfo_GuessGameBet.Size(m)
}
func (m *GuessGameBet) XXX_DiscardUnknown() {
xxx_messageInfo_GuessGameBet.DiscardUnknown(m)
}
var xxx_messageInfo_GuessGameBet proto.InternalMessageInfo
func (m *GuessGameBet) Reset() { *m = GuessGameBet{} }
func (m *GuessGameBet) String() string { return proto.CompactTextString(m) }
func (*GuessGameBet) ProtoMessage() {}
func (*GuessGameBet) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} }
func (m *GuessGameBet) GetGameID() string {
if m != nil {
......@@ -975,38 +814,15 @@ func (m *GuessGameBet) GetBetsNum() int64 {
return 0
}
//GuessGameStopBet 游戏停止下注
// GuessGameStopBet 游戏停止下注
type GuessGameStopBet struct {
GameID string `protobuf:"bytes,1,opt,name=gameID,proto3" json:"gameID,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
GameID string `protobuf:"bytes,1,opt,name=gameID" json:"gameID,omitempty"`
}
func (m *GuessGameStopBet) Reset() { *m = GuessGameStopBet{} }
func (m *GuessGameStopBet) String() string { return proto.CompactTextString(m) }
func (*GuessGameStopBet) ProtoMessage() {}
func (*GuessGameStopBet) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{8}
}
func (m *GuessGameStopBet) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GuessGameStopBet.Unmarshal(m, b)
}
func (m *GuessGameStopBet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GuessGameStopBet.Marshal(b, m, deterministic)
}
func (m *GuessGameStopBet) XXX_Merge(src proto.Message) {
xxx_messageInfo_GuessGameStopBet.Merge(m, src)
}
func (m *GuessGameStopBet) XXX_Size() int {
return xxx_messageInfo_GuessGameStopBet.Size(m)
}
func (m *GuessGameStopBet) XXX_DiscardUnknown() {
xxx_messageInfo_GuessGameStopBet.DiscardUnknown(m)
}
var xxx_messageInfo_GuessGameStopBet proto.InternalMessageInfo
func (m *GuessGameStopBet) Reset() { *m = GuessGameStopBet{} }
func (m *GuessGameStopBet) String() string { return proto.CompactTextString(m) }
func (*GuessGameStopBet) ProtoMessage() {}
func (*GuessGameStopBet) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} }
func (m *GuessGameStopBet) GetGameID() string {
if m != nil {
......@@ -1015,38 +831,15 @@ func (m *GuessGameStopBet) GetGameID() string {
return ""
}
//GuessGameAbort 游戏异常终止,退还下注
// GuessGameAbort 游戏异常终止,退还下注
type GuessGameAbort struct {
GameID string `protobuf:"bytes,1,opt,name=gameID,proto3" json:"gameID,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GuessGameAbort) Reset() { *m = GuessGameAbort{} }
func (m *GuessGameAbort) String() string { return proto.CompactTextString(m) }
func (*GuessGameAbort) ProtoMessage() {}
func (*GuessGameAbort) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{9}
}
func (m *GuessGameAbort) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GuessGameAbort.Unmarshal(m, b)
}
func (m *GuessGameAbort) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GuessGameAbort.Marshal(b, m, deterministic)
}
func (m *GuessGameAbort) XXX_Merge(src proto.Message) {
xxx_messageInfo_GuessGameAbort.Merge(m, src)
}
func (m *GuessGameAbort) XXX_Size() int {
return xxx_messageInfo_GuessGameAbort.Size(m)
}
func (m *GuessGameAbort) XXX_DiscardUnknown() {
xxx_messageInfo_GuessGameAbort.DiscardUnknown(m)
GameID string `protobuf:"bytes,1,opt,name=gameID" json:"gameID,omitempty"`
}
var xxx_messageInfo_GuessGameAbort proto.InternalMessageInfo
func (m *GuessGameAbort) Reset() { *m = GuessGameAbort{} }
func (m *GuessGameAbort) String() string { return proto.CompactTextString(m) }
func (*GuessGameAbort) ProtoMessage() {}
func (*GuessGameAbort) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} }
func (m *GuessGameAbort) GetGameID() string {
if m != nil {
......@@ -1055,39 +848,16 @@ func (m *GuessGameAbort) GetGameID() string {
return ""
}
//GuessGamePublish 游戏结果揭晓
// GuessGamePublish 游戏结果揭晓
type GuessGamePublish struct {
GameID string `protobuf:"bytes,1,opt,name=gameID,proto3" json:"gameID,omitempty"`
Result string `protobuf:"bytes,2,opt,name=result,proto3" json:"result,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
GameID string `protobuf:"bytes,1,opt,name=gameID" json:"gameID,omitempty"`
Result string `protobuf:"bytes,2,opt,name=result" json:"result,omitempty"`
}
func (m *GuessGamePublish) Reset() { *m = GuessGamePublish{} }
func (m *GuessGamePublish) String() string { return proto.CompactTextString(m) }
func (*GuessGamePublish) ProtoMessage() {}
func (*GuessGamePublish) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{10}
}
func (m *GuessGamePublish) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GuessGamePublish.Unmarshal(m, b)
}
func (m *GuessGamePublish) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GuessGamePublish.Marshal(b, m, deterministic)
}
func (m *GuessGamePublish) XXX_Merge(src proto.Message) {
xxx_messageInfo_GuessGamePublish.Merge(m, src)
}
func (m *GuessGamePublish) XXX_Size() int {
return xxx_messageInfo_GuessGamePublish.Size(m)
}
func (m *GuessGamePublish) XXX_DiscardUnknown() {
xxx_messageInfo_GuessGamePublish.DiscardUnknown(m)
}
var xxx_messageInfo_GuessGamePublish proto.InternalMessageInfo
func (m *GuessGamePublish) Reset() { *m = GuessGamePublish{} }
func (m *GuessGamePublish) String() string { return proto.CompactTextString(m) }
func (*GuessGamePublish) ProtoMessage() {}
func (*GuessGamePublish) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} }
func (m *GuessGamePublish) GetGameID() string {
if m != nil {
......@@ -1103,39 +873,16 @@ func (m *GuessGamePublish) GetResult() string {
return ""
}
//GuessGameQuery 查询游戏结果
// GuessGameQuery 查询游戏结果
type GuessGameQuery struct {
GameID string `protobuf:"bytes,1,opt,name=gameID,proto3" json:"gameID,omitempty"`
Ty uint32 `protobuf:"varint,2,opt,name=ty,proto3" json:"ty,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GuessGameQuery) Reset() { *m = GuessGameQuery{} }
func (m *GuessGameQuery) String() string { return proto.CompactTextString(m) }
func (*GuessGameQuery) ProtoMessage() {}
func (*GuessGameQuery) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{11}
}
func (m *GuessGameQuery) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GuessGameQuery.Unmarshal(m, b)
}
func (m *GuessGameQuery) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GuessGameQuery.Marshal(b, m, deterministic)
}
func (m *GuessGameQuery) XXX_Merge(src proto.Message) {
xxx_messageInfo_GuessGameQuery.Merge(m, src)
}
func (m *GuessGameQuery) XXX_Size() int {
return xxx_messageInfo_GuessGameQuery.Size(m)
}
func (m *GuessGameQuery) XXX_DiscardUnknown() {
xxx_messageInfo_GuessGameQuery.DiscardUnknown(m)
GameID string `protobuf:"bytes,1,opt,name=gameID" json:"gameID,omitempty"`
Ty uint32 `protobuf:"varint,2,opt,name=ty" json:"ty,omitempty"`
}
var xxx_messageInfo_GuessGameQuery proto.InternalMessageInfo
func (m *GuessGameQuery) Reset() { *m = GuessGameQuery{} }
func (m *GuessGameQuery) String() string { return proto.CompactTextString(m) }
func (*GuessGameQuery) ProtoMessage() {}
func (*GuessGameQuery) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} }
func (m *GuessGameQuery) GetGameID() string {
if m != nil {
......@@ -1151,44 +898,21 @@ func (m *GuessGameQuery) GetTy() uint32 {
return 0
}
//QueryGuessGameInfo 游戏信息查询消息
// QueryGuessGameInfo 游戏信息查询消息
type QueryGuessGameInfo struct {
GameID string `protobuf:"bytes,1,opt,name=gameID,proto3" json:"gameID,omitempty"`
Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"`
Status int32 `protobuf:"varint,3,opt,name=status,proto3" json:"status,omitempty"`
Index int64 `protobuf:"varint,4,opt,name=index,proto3" json:"index,omitempty"`
AdminAddr string `protobuf:"bytes,5,opt,name=adminAddr,proto3" json:"adminAddr,omitempty"`
Category string `protobuf:"bytes,6,opt,name=category,proto3" json:"category,omitempty"`
PrimaryKey string `protobuf:"bytes,7,opt,name=primaryKey,proto3" json:"primaryKey,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
GameID string `protobuf:"bytes,1,opt,name=gameID" json:"gameID,omitempty"`
Addr string `protobuf:"bytes,2,opt,name=addr" json:"addr,omitempty"`
Status int32 `protobuf:"varint,3,opt,name=status" json:"status,omitempty"`
Index int64 `protobuf:"varint,4,opt,name=index" json:"index,omitempty"`
AdminAddr string `protobuf:"bytes,5,opt,name=adminAddr" json:"adminAddr,omitempty"`
Category string `protobuf:"bytes,6,opt,name=category" json:"category,omitempty"`
PrimaryKey string `protobuf:"bytes,7,opt,name=primaryKey" json:"primaryKey,omitempty"`
}
func (m *QueryGuessGameInfo) Reset() { *m = QueryGuessGameInfo{} }
func (m *QueryGuessGameInfo) String() string { return proto.CompactTextString(m) }
func (*QueryGuessGameInfo) ProtoMessage() {}
func (*QueryGuessGameInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{12}
}
func (m *QueryGuessGameInfo) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_QueryGuessGameInfo.Unmarshal(m, b)
}
func (m *QueryGuessGameInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_QueryGuessGameInfo.Marshal(b, m, deterministic)
}
func (m *QueryGuessGameInfo) XXX_Merge(src proto.Message) {
xxx_messageInfo_QueryGuessGameInfo.Merge(m, src)
}
func (m *QueryGuessGameInfo) XXX_Size() int {
return xxx_messageInfo_QueryGuessGameInfo.Size(m)
}
func (m *QueryGuessGameInfo) XXX_DiscardUnknown() {
xxx_messageInfo_QueryGuessGameInfo.DiscardUnknown(m)
}
var xxx_messageInfo_QueryGuessGameInfo proto.InternalMessageInfo
func (m *QueryGuessGameInfo) Reset() { *m = QueryGuessGameInfo{} }
func (m *QueryGuessGameInfo) String() string { return proto.CompactTextString(m) }
func (*QueryGuessGameInfo) ProtoMessage() {}
func (*QueryGuessGameInfo) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{12} }
func (m *QueryGuessGameInfo) GetGameID() string {
if m != nil {
......@@ -1239,38 +963,15 @@ func (m *QueryGuessGameInfo) GetPrimaryKey() string {
return ""
}
//ReplyGuessGameInfo 游戏信息查询响应消息
// ReplyGuessGameInfo 游戏信息查询响应消息
type ReplyGuessGameInfo struct {
Game *GuessGame `protobuf:"bytes,1,opt,name=game,proto3" json:"game,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
Game *GuessGame `protobuf:"bytes,1,opt,name=game" json:"game,omitempty"`
}
func (m *ReplyGuessGameInfo) Reset() { *m = ReplyGuessGameInfo{} }
func (m *ReplyGuessGameInfo) String() string { return proto.CompactTextString(m) }
func (*ReplyGuessGameInfo) ProtoMessage() {}
func (*ReplyGuessGameInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{13}
}
func (m *ReplyGuessGameInfo) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ReplyGuessGameInfo.Unmarshal(m, b)
}
func (m *ReplyGuessGameInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ReplyGuessGameInfo.Marshal(b, m, deterministic)
}
func (m *ReplyGuessGameInfo) XXX_Merge(src proto.Message) {
xxx_messageInfo_ReplyGuessGameInfo.Merge(m, src)
}
func (m *ReplyGuessGameInfo) XXX_Size() int {
return xxx_messageInfo_ReplyGuessGameInfo.Size(m)
}
func (m *ReplyGuessGameInfo) XXX_DiscardUnknown() {
xxx_messageInfo_ReplyGuessGameInfo.DiscardUnknown(m)
}
var xxx_messageInfo_ReplyGuessGameInfo proto.InternalMessageInfo
func (m *ReplyGuessGameInfo) Reset() { *m = ReplyGuessGameInfo{} }
func (m *ReplyGuessGameInfo) String() string { return proto.CompactTextString(m) }
func (*ReplyGuessGameInfo) ProtoMessage() {}
func (*ReplyGuessGameInfo) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{13} }
func (m *ReplyGuessGameInfo) GetGame() *GuessGame {
if m != nil {
......@@ -1279,38 +980,15 @@ func (m *ReplyGuessGameInfo) GetGame() *GuessGame {
return nil
}
//QueryGuessGameInfos 游戏信息列表查询消息
// QueryGuessGameInfos 游戏信息列表查询消息
type QueryGuessGameInfos struct {
GameIDs []string `protobuf:"bytes,1,rep,name=gameIDs,proto3" json:"gameIDs,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
GameIDs []string `protobuf:"bytes,1,rep,name=gameIDs" json:"gameIDs,omitempty"`
}
func (m *QueryGuessGameInfos) Reset() { *m = QueryGuessGameInfos{} }
func (m *QueryGuessGameInfos) String() string { return proto.CompactTextString(m) }
func (*QueryGuessGameInfos) ProtoMessage() {}
func (*QueryGuessGameInfos) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{14}
}
func (m *QueryGuessGameInfos) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_QueryGuessGameInfos.Unmarshal(m, b)
}
func (m *QueryGuessGameInfos) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_QueryGuessGameInfos.Marshal(b, m, deterministic)
}
func (m *QueryGuessGameInfos) XXX_Merge(src proto.Message) {
xxx_messageInfo_QueryGuessGameInfos.Merge(m, src)
}
func (m *QueryGuessGameInfos) XXX_Size() int {
return xxx_messageInfo_QueryGuessGameInfos.Size(m)
}
func (m *QueryGuessGameInfos) XXX_DiscardUnknown() {
xxx_messageInfo_QueryGuessGameInfos.DiscardUnknown(m)
}
var xxx_messageInfo_QueryGuessGameInfos proto.InternalMessageInfo
func (m *QueryGuessGameInfos) Reset() { *m = QueryGuessGameInfos{} }
func (m *QueryGuessGameInfos) String() string { return proto.CompactTextString(m) }
func (*QueryGuessGameInfos) ProtoMessage() {}
func (*QueryGuessGameInfos) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{14} }
func (m *QueryGuessGameInfos) GetGameIDs() []string {
if m != nil {
......@@ -1319,38 +997,15 @@ func (m *QueryGuessGameInfos) GetGameIDs() []string {
return nil
}
//ReplyGuessGameInfos 游戏信息列表查询响应消息
// ReplyGuessGameInfos 游戏信息列表查询响应消息
type ReplyGuessGameInfos struct {
Games []*GuessGame `protobuf:"bytes,1,rep,name=games,proto3" json:"games,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ReplyGuessGameInfos) Reset() { *m = ReplyGuessGameInfos{} }
func (m *ReplyGuessGameInfos) String() string { return proto.CompactTextString(m) }
func (*ReplyGuessGameInfos) ProtoMessage() {}
func (*ReplyGuessGameInfos) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{15}
}
func (m *ReplyGuessGameInfos) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ReplyGuessGameInfos.Unmarshal(m, b)
}
func (m *ReplyGuessGameInfos) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ReplyGuessGameInfos.Marshal(b, m, deterministic)
}
func (m *ReplyGuessGameInfos) XXX_Merge(src proto.Message) {
xxx_messageInfo_ReplyGuessGameInfos.Merge(m, src)
}
func (m *ReplyGuessGameInfos) XXX_Size() int {
return xxx_messageInfo_ReplyGuessGameInfos.Size(m)
}
func (m *ReplyGuessGameInfos) XXX_DiscardUnknown() {
xxx_messageInfo_ReplyGuessGameInfos.DiscardUnknown(m)
Games []*GuessGame `protobuf:"bytes,1,rep,name=games" json:"games,omitempty"`
}
var xxx_messageInfo_ReplyGuessGameInfos proto.InternalMessageInfo
func (m *ReplyGuessGameInfos) Reset() { *m = ReplyGuessGameInfos{} }
func (m *ReplyGuessGameInfos) String() string { return proto.CompactTextString(m) }
func (*ReplyGuessGameInfos) ProtoMessage() {}
func (*ReplyGuessGameInfos) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{15} }
func (m *ReplyGuessGameInfos) GetGames() []*GuessGame {
if m != nil {
......@@ -1359,51 +1014,28 @@ func (m *ReplyGuessGameInfos) GetGames() []*GuessGame {
return nil
}
//ReceiptGuessGame 竞猜游戏收据信息
// ReceiptGuessGame 竞猜游戏收据信息
type ReceiptGuessGame struct {
StartIndex int64 `protobuf:"varint,1,opt,name=startIndex,proto3" json:"startIndex,omitempty"`
GameID string `protobuf:"bytes,2,opt,name=gameID,proto3" json:"gameID,omitempty"`
PreStatus int32 `protobuf:"varint,3,opt,name=preStatus,proto3" json:"preStatus,omitempty"`
Status int32 `protobuf:"varint,4,opt,name=status,proto3" json:"status,omitempty"`
Addr string `protobuf:"bytes,5,opt,name=addr,proto3" json:"addr,omitempty"`
AdminAddr string `protobuf:"bytes,6,opt,name=adminAddr,proto3" json:"adminAddr,omitempty"`
PreIndex int64 `protobuf:"varint,7,opt,name=preIndex,proto3" json:"preIndex,omitempty"`
Index int64 `protobuf:"varint,8,opt,name=index,proto3" json:"index,omitempty"`
Category string `protobuf:"bytes,9,opt,name=category,proto3" json:"category,omitempty"`
StatusChange bool `protobuf:"varint,10,opt,name=statusChange,proto3" json:"statusChange,omitempty"`
Bet bool `protobuf:"varint,11,opt,name=bet,proto3" json:"bet,omitempty"`
Option string `protobuf:"bytes,12,opt,name=option,proto3" json:"option,omitempty"`
BetsNumber int64 `protobuf:"varint,13,opt,name=betsNumber,proto3" json:"betsNumber,omitempty"`
Game *GuessGame `protobuf:"bytes,14,opt,name=game,proto3" json:"game,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ReceiptGuessGame) Reset() { *m = ReceiptGuessGame{} }
func (m *ReceiptGuessGame) String() string { return proto.CompactTextString(m) }
func (*ReceiptGuessGame) ProtoMessage() {}
func (*ReceiptGuessGame) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{16}
}
func (m *ReceiptGuessGame) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ReceiptGuessGame.Unmarshal(m, b)
}
func (m *ReceiptGuessGame) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ReceiptGuessGame.Marshal(b, m, deterministic)
}
func (m *ReceiptGuessGame) XXX_Merge(src proto.Message) {
xxx_messageInfo_ReceiptGuessGame.Merge(m, src)
}
func (m *ReceiptGuessGame) XXX_Size() int {
return xxx_messageInfo_ReceiptGuessGame.Size(m)
}
func (m *ReceiptGuessGame) XXX_DiscardUnknown() {
xxx_messageInfo_ReceiptGuessGame.DiscardUnknown(m)
}
var xxx_messageInfo_ReceiptGuessGame proto.InternalMessageInfo
StartIndex int64 `protobuf:"varint,1,opt,name=startIndex" json:"startIndex,omitempty"`
GameID string `protobuf:"bytes,2,opt,name=gameID" json:"gameID,omitempty"`
PreStatus int32 `protobuf:"varint,3,opt,name=preStatus" json:"preStatus,omitempty"`
Status int32 `protobuf:"varint,4,opt,name=status" json:"status,omitempty"`
Addr string `protobuf:"bytes,5,opt,name=addr" json:"addr,omitempty"`
AdminAddr string `protobuf:"bytes,6,opt,name=adminAddr" json:"adminAddr,omitempty"`
PreIndex int64 `protobuf:"varint,7,opt,name=preIndex" json:"preIndex,omitempty"`
Index int64 `protobuf:"varint,8,opt,name=index" json:"index,omitempty"`
Category string `protobuf:"bytes,9,opt,name=category" json:"category,omitempty"`
StatusChange bool `protobuf:"varint,10,opt,name=statusChange" json:"statusChange,omitempty"`
Bet bool `protobuf:"varint,11,opt,name=bet" json:"bet,omitempty"`
Option string `protobuf:"bytes,12,opt,name=option" json:"option,omitempty"`
BetsNumber int64 `protobuf:"varint,13,opt,name=betsNumber" json:"betsNumber,omitempty"`
Game *GuessGame `protobuf:"bytes,14,opt,name=game" json:"game,omitempty"`
}
func (m *ReceiptGuessGame) Reset() { *m = ReceiptGuessGame{} }
func (m *ReceiptGuessGame) String() string { return proto.CompactTextString(m) }
func (*ReceiptGuessGame) ProtoMessage() {}
func (*ReceiptGuessGame) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{16} }
func (m *ReceiptGuessGame) GetStartIndex() int64 {
if m != nil {
......@@ -1503,43 +1135,20 @@ func (m *ReceiptGuessGame) GetGame() *GuessGame {
return nil
}
//UserBet 用户下注信息
// UserBet 用户下注信息
type UserBet struct {
StartIndex int64 `protobuf:"varint,1,opt,name=startIndex,proto3" json:"startIndex,omitempty"`
Index int64 `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"`
GameID string `protobuf:"bytes,3,opt,name=gameID,proto3" json:"gameID,omitempty"`
Addr string `protobuf:"bytes,4,opt,name=addr,proto3" json:"addr,omitempty"`
Option string `protobuf:"bytes,5,opt,name=option,proto3" json:"option,omitempty"`
BetsNumber int64 `protobuf:"varint,6,opt,name=betsNumber,proto3" json:"betsNumber,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *UserBet) Reset() { *m = UserBet{} }
func (m *UserBet) String() string { return proto.CompactTextString(m) }
func (*UserBet) ProtoMessage() {}
func (*UserBet) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{17}
}
func (m *UserBet) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_UserBet.Unmarshal(m, b)
}
func (m *UserBet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_UserBet.Marshal(b, m, deterministic)
}
func (m *UserBet) XXX_Merge(src proto.Message) {
xxx_messageInfo_UserBet.Merge(m, src)
}
func (m *UserBet) XXX_Size() int {
return xxx_messageInfo_UserBet.Size(m)
}
func (m *UserBet) XXX_DiscardUnknown() {
xxx_messageInfo_UserBet.DiscardUnknown(m)
StartIndex int64 `protobuf:"varint,1,opt,name=startIndex" json:"startIndex,omitempty"`
Index int64 `protobuf:"varint,2,opt,name=index" json:"index,omitempty"`
GameID string `protobuf:"bytes,3,opt,name=gameID" json:"gameID,omitempty"`
Addr string `protobuf:"bytes,4,opt,name=addr" json:"addr,omitempty"`
Option string `protobuf:"bytes,5,opt,name=option" json:"option,omitempty"`
BetsNumber int64 `protobuf:"varint,6,opt,name=betsNumber" json:"betsNumber,omitempty"`
}
var xxx_messageInfo_UserBet proto.InternalMessageInfo
func (m *UserBet) Reset() { *m = UserBet{} }
func (m *UserBet) String() string { return proto.CompactTextString(m) }
func (*UserBet) ProtoMessage() {}
func (*UserBet) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{17} }
func (m *UserBet) GetStartIndex() int64 {
if m != nil {
......@@ -1583,50 +1192,27 @@ func (m *UserBet) GetBetsNumber() int64 {
return 0
}
//GuessStartTxReq 构造start交易的请求
// GuessStartTxReq 构造start交易的请求
type GuessStartTxReq struct {
Topic string `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"`
Options string `protobuf:"bytes,2,opt,name=options,proto3" json:"options,omitempty"`
Category string `protobuf:"bytes,3,opt,name=category,proto3" json:"category,omitempty"`
MaxHeight int64 `protobuf:"varint,4,opt,name=maxHeight,proto3" json:"maxHeight,omitempty"`
MaxBetHeight int64 `protobuf:"varint,5,opt,name=maxBetHeight,proto3" json:"maxBetHeight,omitempty"`
MaxBetsOneTime int64 `protobuf:"varint,6,opt,name=maxBetsOneTime,proto3" json:"maxBetsOneTime,omitempty"`
MaxBetsNumber int64 `protobuf:"varint,7,opt,name=maxBetsNumber,proto3" json:"maxBetsNumber,omitempty"`
DevFeeFactor int64 `protobuf:"varint,8,opt,name=devFeeFactor,proto3" json:"devFeeFactor,omitempty"`
DevFeeAddr string `protobuf:"bytes,9,opt,name=devFeeAddr,proto3" json:"devFeeAddr,omitempty"`
PlatFeeFactor int64 `protobuf:"varint,10,opt,name=platFeeFactor,proto3" json:"platFeeFactor,omitempty"`
PlatFeeAddr string `protobuf:"bytes,11,opt,name=platFeeAddr,proto3" json:"platFeeAddr,omitempty"`
ExpireHeight int64 `protobuf:"varint,12,opt,name=expireHeight,proto3" json:"expireHeight,omitempty"`
Fee int64 `protobuf:"varint,13,opt,name=fee,proto3" json:"fee,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GuessStartTxReq) Reset() { *m = GuessStartTxReq{} }
func (m *GuessStartTxReq) String() string { return proto.CompactTextString(m) }
func (*GuessStartTxReq) ProtoMessage() {}
func (*GuessStartTxReq) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{18}
}
func (m *GuessStartTxReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GuessStartTxReq.Unmarshal(m, b)
}
func (m *GuessStartTxReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GuessStartTxReq.Marshal(b, m, deterministic)
}
func (m *GuessStartTxReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_GuessStartTxReq.Merge(m, src)
}
func (m *GuessStartTxReq) XXX_Size() int {
return xxx_messageInfo_GuessStartTxReq.Size(m)
}
func (m *GuessStartTxReq) XXX_DiscardUnknown() {
xxx_messageInfo_GuessStartTxReq.DiscardUnknown(m)
}
var xxx_messageInfo_GuessStartTxReq proto.InternalMessageInfo
Topic string `protobuf:"bytes,1,opt,name=topic" json:"topic,omitempty"`
Options string `protobuf:"bytes,2,opt,name=options" json:"options,omitempty"`
Category string `protobuf:"bytes,3,opt,name=category" json:"category,omitempty"`
MaxHeight int64 `protobuf:"varint,4,opt,name=maxHeight" json:"maxHeight,omitempty"`
MaxBetHeight int64 `protobuf:"varint,5,opt,name=maxBetHeight" json:"maxBetHeight,omitempty"`
MaxBetsOneTime int64 `protobuf:"varint,6,opt,name=maxBetsOneTime" json:"maxBetsOneTime,omitempty"`
MaxBetsNumber int64 `protobuf:"varint,7,opt,name=maxBetsNumber" json:"maxBetsNumber,omitempty"`
DevFeeFactor int64 `protobuf:"varint,8,opt,name=devFeeFactor" json:"devFeeFactor,omitempty"`
DevFeeAddr string `protobuf:"bytes,9,opt,name=devFeeAddr" json:"devFeeAddr,omitempty"`
PlatFeeFactor int64 `protobuf:"varint,10,opt,name=platFeeFactor" json:"platFeeFactor,omitempty"`
PlatFeeAddr string `protobuf:"bytes,11,opt,name=platFeeAddr" json:"platFeeAddr,omitempty"`
ExpireHeight int64 `protobuf:"varint,12,opt,name=expireHeight" json:"expireHeight,omitempty"`
Fee int64 `protobuf:"varint,13,opt,name=fee" json:"fee,omitempty"`
}
func (m *GuessStartTxReq) Reset() { *m = GuessStartTxReq{} }
func (m *GuessStartTxReq) String() string { return proto.CompactTextString(m) }
func (*GuessStartTxReq) ProtoMessage() {}
func (*GuessStartTxReq) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{18} }
func (m *GuessStartTxReq) GetTopic() string {
if m != nil {
......@@ -1719,41 +1305,18 @@ func (m *GuessStartTxReq) GetFee() int64 {
return 0
}
//GuessBetTxReq 构造bet交易的请求
// GuessBetTxReq 构造bet交易的请求
type GuessBetTxReq struct {
GameID string `protobuf:"bytes,1,opt,name=gameID,proto3" json:"gameID,omitempty"`
Option string `protobuf:"bytes,2,opt,name=option,proto3" json:"option,omitempty"`
Bets int64 `protobuf:"varint,3,opt,name=bets,proto3" json:"bets,omitempty"`
Fee int64 `protobuf:"varint,4,opt,name=fee,proto3" json:"fee,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GuessBetTxReq) Reset() { *m = GuessBetTxReq{} }
func (m *GuessBetTxReq) String() string { return proto.CompactTextString(m) }
func (*GuessBetTxReq) ProtoMessage() {}
func (*GuessBetTxReq) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{19}
}
func (m *GuessBetTxReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GuessBetTxReq.Unmarshal(m, b)
}
func (m *GuessBetTxReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GuessBetTxReq.Marshal(b, m, deterministic)
}
func (m *GuessBetTxReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_GuessBetTxReq.Merge(m, src)
}
func (m *GuessBetTxReq) XXX_Size() int {
return xxx_messageInfo_GuessBetTxReq.Size(m)
}
func (m *GuessBetTxReq) XXX_DiscardUnknown() {
xxx_messageInfo_GuessBetTxReq.DiscardUnknown(m)
GameID string `protobuf:"bytes,1,opt,name=gameID" json:"gameID,omitempty"`
Option string `protobuf:"bytes,2,opt,name=option" json:"option,omitempty"`
Bets int64 `protobuf:"varint,3,opt,name=bets" json:"bets,omitempty"`
Fee int64 `protobuf:"varint,4,opt,name=fee" json:"fee,omitempty"`
}
var xxx_messageInfo_GuessBetTxReq proto.InternalMessageInfo
func (m *GuessBetTxReq) Reset() { *m = GuessBetTxReq{} }
func (m *GuessBetTxReq) String() string { return proto.CompactTextString(m) }
func (*GuessBetTxReq) ProtoMessage() {}
func (*GuessBetTxReq) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{19} }
func (m *GuessBetTxReq) GetGameID() string {
if m != nil {
......@@ -1783,39 +1346,16 @@ func (m *GuessBetTxReq) GetFee() int64 {
return 0
}
//GuessStopBetTxReq 构造stopBet交易的请求
// GuessStopBetTxReq 构造stopBet交易的请求
type GuessStopBetTxReq struct {
GameID string `protobuf:"bytes,1,opt,name=gameID,proto3" json:"gameID,omitempty"`
Fee int64 `protobuf:"varint,2,opt,name=fee,proto3" json:"fee,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
GameID string `protobuf:"bytes,1,opt,name=gameID" json:"gameID,omitempty"`
Fee int64 `protobuf:"varint,2,opt,name=fee" json:"fee,omitempty"`
}
func (m *GuessStopBetTxReq) Reset() { *m = GuessStopBetTxReq{} }
func (m *GuessStopBetTxReq) String() string { return proto.CompactTextString(m) }
func (*GuessStopBetTxReq) ProtoMessage() {}
func (*GuessStopBetTxReq) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{20}
}
func (m *GuessStopBetTxReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GuessStopBetTxReq.Unmarshal(m, b)
}
func (m *GuessStopBetTxReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GuessStopBetTxReq.Marshal(b, m, deterministic)
}
func (m *GuessStopBetTxReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_GuessStopBetTxReq.Merge(m, src)
}
func (m *GuessStopBetTxReq) XXX_Size() int {
return xxx_messageInfo_GuessStopBetTxReq.Size(m)
}
func (m *GuessStopBetTxReq) XXX_DiscardUnknown() {
xxx_messageInfo_GuessStopBetTxReq.DiscardUnknown(m)
}
var xxx_messageInfo_GuessStopBetTxReq proto.InternalMessageInfo
func (m *GuessStopBetTxReq) Reset() { *m = GuessStopBetTxReq{} }
func (m *GuessStopBetTxReq) String() string { return proto.CompactTextString(m) }
func (*GuessStopBetTxReq) ProtoMessage() {}
func (*GuessStopBetTxReq) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{20} }
func (m *GuessStopBetTxReq) GetGameID() string {
if m != nil {
......@@ -1831,39 +1371,16 @@ func (m *GuessStopBetTxReq) GetFee() int64 {
return 0
}
//GuessAbortTxReq 构造abort交易的请求
// GuessAbortTxReq 构造abort交易的请求
type GuessAbortTxReq struct {
GameID string `protobuf:"bytes,1,opt,name=gameID,proto3" json:"gameID,omitempty"`
Fee int64 `protobuf:"varint,2,opt,name=fee,proto3" json:"fee,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GuessAbortTxReq) Reset() { *m = GuessAbortTxReq{} }
func (m *GuessAbortTxReq) String() string { return proto.CompactTextString(m) }
func (*GuessAbortTxReq) ProtoMessage() {}
func (*GuessAbortTxReq) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{21}
}
func (m *GuessAbortTxReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GuessAbortTxReq.Unmarshal(m, b)
}
func (m *GuessAbortTxReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GuessAbortTxReq.Marshal(b, m, deterministic)
}
func (m *GuessAbortTxReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_GuessAbortTxReq.Merge(m, src)
}
func (m *GuessAbortTxReq) XXX_Size() int {
return xxx_messageInfo_GuessAbortTxReq.Size(m)
}
func (m *GuessAbortTxReq) XXX_DiscardUnknown() {
xxx_messageInfo_GuessAbortTxReq.DiscardUnknown(m)
GameID string `protobuf:"bytes,1,opt,name=gameID" json:"gameID,omitempty"`
Fee int64 `protobuf:"varint,2,opt,name=fee" json:"fee,omitempty"`
}
var xxx_messageInfo_GuessAbortTxReq proto.InternalMessageInfo
func (m *GuessAbortTxReq) Reset() { *m = GuessAbortTxReq{} }
func (m *GuessAbortTxReq) String() string { return proto.CompactTextString(m) }
func (*GuessAbortTxReq) ProtoMessage() {}
func (*GuessAbortTxReq) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{21} }
func (m *GuessAbortTxReq) GetGameID() string {
if m != nil {
......@@ -1879,40 +1396,17 @@ func (m *GuessAbortTxReq) GetFee() int64 {
return 0
}
//GuessPublishTxReq 构造publish交易的请求
// GuessPublishTxReq 构造publish交易的请求
type GuessPublishTxReq struct {
GameID string `protobuf:"bytes,1,opt,name=gameID,proto3" json:"gameID,omitempty"`
Result string `protobuf:"bytes,2,opt,name=result,proto3" json:"result,omitempty"`
Fee int64 `protobuf:"varint,3,opt,name=fee,proto3" json:"fee,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GuessPublishTxReq) Reset() { *m = GuessPublishTxReq{} }
func (m *GuessPublishTxReq) String() string { return proto.CompactTextString(m) }
func (*GuessPublishTxReq) ProtoMessage() {}
func (*GuessPublishTxReq) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{22}
}
func (m *GuessPublishTxReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GuessPublishTxReq.Unmarshal(m, b)
}
func (m *GuessPublishTxReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GuessPublishTxReq.Marshal(b, m, deterministic)
}
func (m *GuessPublishTxReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_GuessPublishTxReq.Merge(m, src)
}
func (m *GuessPublishTxReq) XXX_Size() int {
return xxx_messageInfo_GuessPublishTxReq.Size(m)
}
func (m *GuessPublishTxReq) XXX_DiscardUnknown() {
xxx_messageInfo_GuessPublishTxReq.DiscardUnknown(m)
GameID string `protobuf:"bytes,1,opt,name=gameID" json:"gameID,omitempty"`
Result string `protobuf:"bytes,2,opt,name=result" json:"result,omitempty"`
Fee int64 `protobuf:"varint,3,opt,name=fee" json:"fee,omitempty"`
}
var xxx_messageInfo_GuessPublishTxReq proto.InternalMessageInfo
func (m *GuessPublishTxReq) Reset() { *m = GuessPublishTxReq{} }
func (m *GuessPublishTxReq) String() string { return proto.CompactTextString(m) }
func (*GuessPublishTxReq) ProtoMessage() {}
func (*GuessPublishTxReq) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{22} }
func (m *GuessPublishTxReq) GetGameID() string {
if m != nil {
......@@ -1937,37 +1431,14 @@ func (m *GuessPublishTxReq) GetFee() int64 {
// GuessGameRecord game信息查询记录
type GuessGameRecord struct {
GameID string `protobuf:"bytes,1,opt,name=gameID,proto3" json:"gameID,omitempty"`
StartIndex int64 `protobuf:"varint,2,opt,name=startIndex,proto3" json:"startIndex,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GuessGameRecord) Reset() { *m = GuessGameRecord{} }
func (m *GuessGameRecord) String() string { return proto.CompactTextString(m) }
func (*GuessGameRecord) ProtoMessage() {}
func (*GuessGameRecord) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{23}
GameID string `protobuf:"bytes,1,opt,name=gameID" json:"gameID,omitempty"`
StartIndex int64 `protobuf:"varint,2,opt,name=startIndex" json:"startIndex,omitempty"`
}
func (m *GuessGameRecord) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GuessGameRecord.Unmarshal(m, b)
}
func (m *GuessGameRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GuessGameRecord.Marshal(b, m, deterministic)
}
func (m *GuessGameRecord) XXX_Merge(src proto.Message) {
xxx_messageInfo_GuessGameRecord.Merge(m, src)
}
func (m *GuessGameRecord) XXX_Size() int {
return xxx_messageInfo_GuessGameRecord.Size(m)
}
func (m *GuessGameRecord) XXX_DiscardUnknown() {
xxx_messageInfo_GuessGameRecord.DiscardUnknown(m)
}
var xxx_messageInfo_GuessGameRecord proto.InternalMessageInfo
func (m *GuessGameRecord) Reset() { *m = GuessGameRecord{} }
func (m *GuessGameRecord) String() string { return proto.CompactTextString(m) }
func (*GuessGameRecord) ProtoMessage() {}
func (*GuessGameRecord) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{23} }
func (m *GuessGameRecord) GetGameID() string {
if m != nil {
......@@ -1985,37 +1456,14 @@ func (m *GuessGameRecord) GetStartIndex() int64 {
// GuessGameRecords game信息查询记录集
type GuessGameRecords struct {
Records []*GuessGameRecord `protobuf:"bytes,1,rep,name=records,proto3" json:"records,omitempty"`
PrimaryKey string `protobuf:"bytes,2,opt,name=primaryKey,proto3" json:"primaryKey,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
Records []*GuessGameRecord `protobuf:"bytes,1,rep,name=records" json:"records,omitempty"`
PrimaryKey string `protobuf:"bytes,2,opt,name=primaryKey" json:"primaryKey,omitempty"`
}
func (m *GuessGameRecords) Reset() { *m = GuessGameRecords{} }
func (m *GuessGameRecords) String() string { return proto.CompactTextString(m) }
func (*GuessGameRecords) ProtoMessage() {}
func (*GuessGameRecords) Descriptor() ([]byte, []int) {
return fileDescriptor_7574406c5d3430e8, []int{24}
}
func (m *GuessGameRecords) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GuessGameRecords.Unmarshal(m, b)
}
func (m *GuessGameRecords) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GuessGameRecords.Marshal(b, m, deterministic)
}
func (m *GuessGameRecords) XXX_Merge(src proto.Message) {
xxx_messageInfo_GuessGameRecords.Merge(m, src)
}
func (m *GuessGameRecords) XXX_Size() int {
return xxx_messageInfo_GuessGameRecords.Size(m)
}
func (m *GuessGameRecords) XXX_DiscardUnknown() {
xxx_messageInfo_GuessGameRecords.DiscardUnknown(m)
}
var xxx_messageInfo_GuessGameRecords proto.InternalMessageInfo
func (m *GuessGameRecords) Reset() { *m = GuessGameRecords{} }
func (m *GuessGameRecords) String() string { return proto.CompactTextString(m) }
func (*GuessGameRecords) ProtoMessage() {}
func (*GuessGameRecords) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{24} }
func (m *GuessGameRecords) GetRecords() []*GuessGameRecord {
if m != nil {
......@@ -2059,98 +1507,6 @@ func init() {
proto.RegisterType((*GuessGameRecords)(nil), "types.GuessGameRecords")
}
func init() { proto.RegisterFile("guess.proto", fileDescriptor_7574406c5d3430e8) }
var fileDescriptor_7574406c5d3430e8 = []byte{
// 1367 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x58, 0xc9, 0x8e, 0xdb, 0x46,
0x13, 0x1e, 0x92, 0xa2, 0x96, 0x92, 0x66, 0x46, 0xee, 0xf1, 0xc2, 0x7f, 0x60, 0x18, 0xfa, 0x09,
0xc3, 0x11, 0x02, 0xd8, 0x09, 0x64, 0x20, 0x08, 0x1c, 0xf8, 0x30, 0x8a, 0x61, 0x7b, 0x10, 0x20,
0x71, 0x68, 0x1b, 0xc9, 0x95, 0x92, 0x7a, 0x34, 0x04, 0x24, 0x92, 0x26, 0x5b, 0x03, 0xe9, 0x21,
0x72, 0xcb, 0x1b, 0x38, 0x87, 0xdc, 0xf2, 0x1a, 0x41, 0x4e, 0x79, 0xa4, 0xa0, 0xaa, 0x9b, 0x62,
0x93, 0xa2, 0x16, 0x07, 0xb9, 0xb1, 0x96, 0xee, 0xaa, 0xae, 0xed, 0x2b, 0x09, 0xda, 0xd3, 0x05,
0x4f, 0xd3, 0x27, 0x71, 0x12, 0x89, 0x88, 0xd9, 0x62, 0x15, 0xf3, 0xf4, 0xfc, 0x96, 0x48, 0xfc,
0x30, 0xf5, 0xc7, 0x22, 0x88, 0x42, 0x29, 0x71, 0xff, 0xae, 0x43, 0xeb, 0x15, 0x6a, 0xbe, 0xf2,
0xe7, 0x9c, 0xdd, 0x85, 0xfa, 0xd4, 0x9f, 0xf3, 0xcb, 0x17, 0x8e, 0xd1, 0x33, 0xfa, 0x2d, 0x4f,
0x51, 0xc8, 0x4f, 0x85, 0x2f, 0x16, 0xa9, 0x63, 0xf6, 0x8c, 0xbe, 0xed, 0x29, 0x8a, 0xdd, 0x87,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x06, 0xb4, 0xf2, 0xaa, 0x94, 0x7d, 0x09,
0x8d, 0x44, 0x7e, 0xaa, 0x89, 0x7d, 0x77, 0x63, 0x32, 0x90, 0xd8, 0xcb, 0xd4, 0x4a, 0x28, 0x64,
0x96, 0x51, 0x68, 0xf0, 0xd1, 0x04, 0x9b, 0xfe, 0xda, 0x60, 0x5f, 0x01, 0xe4, 0x5d, 0xca, 0xaa,
0xf7, 0xec, 0xf3, 0xec, 0xc7, 0xd5, 0xfb, 0x30, 0x0d, 0xa6, 0xe1, 0xbb, 0xa5, 0x7b, 0xc4, 0x06,
0xda, 0x0f, 0xab, 0xaa, 0x85, 0xbb, 0xea, 0xcc, 0x33, 0xb5, 0xf4, 0x64, 0x6b, 0xc9, 0xb6, 0xdd,
0xbb, 0xea, 0x6c, 0xe6, 0xa7, 0x5c, 0x53, 0xaa, 0x57, 0xf0, 0x5d, 0x36, 0xb3, 0xa5, 0x65, 0xdb,
0x2e, 0x5e, 0x71, 0x76, 0x54, 0xa7, 0x7f, 0x77, 0x9e, 0xfe, 0x13, 0x00, 0x00, 0xff, 0xff, 0xd2,
0x0f, 0x63, 0x87, 0x06, 0x12, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn
......@@ -2159,20 +1515,19 @@ var _ grpc.ClientConn
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
// GuessClient is the client API for Guess service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
// Client API for Guess service
type GuessClient interface {
//游戏开始
GuessStart(ctx context.Context, in *GuessGameStart, opts ...grpc.CallOption) (*types.UnsignTx, error)
//游戏下注
GuessBet(ctx context.Context, in *GuessGameBet, opts ...grpc.CallOption) (*types.UnsignTx, error)
//游戏终止下注
GuessStopBet(ctx context.Context, in *GuessGameStopBet, opts ...grpc.CallOption) (*types.UnsignTx, error)
//游戏异常终止
GuessAbort(ctx context.Context, in *GuessGameAbort, opts ...grpc.CallOption) (*types.UnsignTx, error)
//游戏结束
GuessPublish(ctx context.Context, in *GuessGamePublish, opts ...grpc.CallOption) (*types.UnsignTx, error)
// 游戏开始
GuessStart(ctx context.Context, in *GuessGameStart, opts ...grpc.CallOption) (*types2.UnsignTx, error)
// 游戏下注
GuessBet(ctx context.Context, in *GuessGameBet, opts ...grpc.CallOption) (*types2.UnsignTx, error)
// 游戏终止下注
GuessStopBet(ctx context.Context, in *GuessGameStopBet, opts ...grpc.CallOption) (*types2.UnsignTx, error)
// 游戏异常终止
GuessAbort(ctx context.Context, in *GuessGameAbort, opts ...grpc.CallOption) (*types2.UnsignTx, error)
// 游戏结束
GuessPublish(ctx context.Context, in *GuessGamePublish, opts ...grpc.CallOption) (*types2.UnsignTx, error)
}
type guessClient struct {
......@@ -2183,63 +1538,64 @@ func NewGuessClient(cc *grpc.ClientConn) GuessClient {
return &guessClient{cc}
}
func (c *guessClient) GuessStart(ctx context.Context, in *GuessGameStart, opts ...grpc.CallOption) (*types.UnsignTx, error) {
out := new(types.UnsignTx)
err := c.cc.Invoke(ctx, "/types.guess/GuessStart", in, out, opts...)
func (c *guessClient) GuessStart(ctx context.Context, in *GuessGameStart, opts ...grpc.CallOption) (*types2.UnsignTx, error) {
out := new(types2.UnsignTx)
err := grpc.Invoke(ctx, "/types.guess/GuessStart", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *guessClient) GuessBet(ctx context.Context, in *GuessGameBet, opts ...grpc.CallOption) (*types.UnsignTx, error) {
out := new(types.UnsignTx)
err := c.cc.Invoke(ctx, "/types.guess/GuessBet", in, out, opts...)
func (c *guessClient) GuessBet(ctx context.Context, in *GuessGameBet, opts ...grpc.CallOption) (*types2.UnsignTx, error) {
out := new(types2.UnsignTx)
err := grpc.Invoke(ctx, "/types.guess/GuessBet", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *guessClient) GuessStopBet(ctx context.Context, in *GuessGameStopBet, opts ...grpc.CallOption) (*types.UnsignTx, error) {
out := new(types.UnsignTx)
err := c.cc.Invoke(ctx, "/types.guess/GuessStopBet", in, out, opts...)
func (c *guessClient) GuessStopBet(ctx context.Context, in *GuessGameStopBet, opts ...grpc.CallOption) (*types2.UnsignTx, error) {
out := new(types2.UnsignTx)
err := grpc.Invoke(ctx, "/types.guess/GuessStopBet", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *guessClient) GuessAbort(ctx context.Context, in *GuessGameAbort, opts ...grpc.CallOption) (*types.UnsignTx, error) {
out := new(types.UnsignTx)
err := c.cc.Invoke(ctx, "/types.guess/GuessAbort", in, out, opts...)
func (c *guessClient) GuessAbort(ctx context.Context, in *GuessGameAbort, opts ...grpc.CallOption) (*types2.UnsignTx, error) {
out := new(types2.UnsignTx)
err := grpc.Invoke(ctx, "/types.guess/GuessAbort", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *guessClient) GuessPublish(ctx context.Context, in *GuessGamePublish, opts ...grpc.CallOption) (*types.UnsignTx, error) {
out := new(types.UnsignTx)
err := c.cc.Invoke(ctx, "/types.guess/GuessPublish", in, out, opts...)
func (c *guessClient) GuessPublish(ctx context.Context, in *GuessGamePublish, opts ...grpc.CallOption) (*types2.UnsignTx, error) {
out := new(types2.UnsignTx)
err := grpc.Invoke(ctx, "/types.guess/GuessPublish", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// GuessServer is the server API for Guess service.
// Server API for Guess service
type GuessServer interface {
//游戏开始
GuessStart(context.Context, *GuessGameStart) (*types.UnsignTx, error)
//游戏下注
GuessBet(context.Context, *GuessGameBet) (*types.UnsignTx, error)
//游戏终止下注
GuessStopBet(context.Context, *GuessGameStopBet) (*types.UnsignTx, error)
//游戏异常终止
GuessAbort(context.Context, *GuessGameAbort) (*types.UnsignTx, error)
//游戏结束
GuessPublish(context.Context, *GuessGamePublish) (*types.UnsignTx, error)
// 游戏开始
GuessStart(context.Context, *GuessGameStart) (*types2.UnsignTx, error)
// 游戏下注
GuessBet(context.Context, *GuessGameBet) (*types2.UnsignTx, error)
// 游戏终止下注
GuessStopBet(context.Context, *GuessGameStopBet) (*types2.UnsignTx, error)
// 游戏异常终止
GuessAbort(context.Context, *GuessGameAbort) (*types2.UnsignTx, error)
// 游戏结束
GuessPublish(context.Context, *GuessGamePublish) (*types2.UnsignTx, error)
}
func RegisterGuessServer(s *grpc.Server, srv GuessServer) {
......@@ -2364,3 +1720,95 @@ var _Guess_serviceDesc = grpc.ServiceDesc{
Streams: []grpc.StreamDesc{},
Metadata: "guess.proto",
}
func init() { proto.RegisterFile("guess.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 1367 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x58, 0xc9, 0x8e, 0xdb, 0x46,
0x13, 0x1e, 0x92, 0xa2, 0x96, 0x92, 0x66, 0x46, 0xee, 0xf1, 0xc2, 0x7f, 0x60, 0x18, 0xfa, 0x09,
0xc3, 0x11, 0x02, 0xd8, 0x09, 0x64, 0x20, 0x08, 0x1c, 0xf8, 0x30, 0x8a, 0x61, 0x7b, 0x10, 0x20,
0x71, 0x68, 0x1b, 0xc9, 0x95, 0x92, 0x7a, 0x34, 0x04, 0x24, 0x92, 0x26, 0x5b, 0x03, 0xe9, 0x21,
0x72, 0xcb, 0x1b, 0x38, 0x87, 0xdc, 0xf2, 0x1a, 0x41, 0x4e, 0x79, 0xa4, 0xa0, 0xaa, 0x9b, 0x62,
0x93, 0xa2, 0x16, 0x07, 0xb9, 0xb1, 0x96, 0xee, 0xaa, 0xae, 0xed, 0x2b, 0x09, 0xda, 0xd3, 0x05,
0x4f, 0xd3, 0x27, 0x71, 0x12, 0x89, 0x88, 0xd9, 0x62, 0x15, 0xf3, 0xf4, 0xfc, 0x96, 0x48, 0xfc,
0x30, 0xf5, 0xc7, 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b8, 0x99, 0x1f,
0xff, 0x46, 0x95, 0x15, 0xe1, 0xd5, 0xa7, 0x1e, 0x7e, 0xaf, 0x6c, 0x2b, 0x08, 0xdb, 0xfb, 0xcc,
0x2a, 0x1c, 0xcb, 0xae, 0xb5, 0xf2, 0x6b, 0x2f, 0xb5, 0x05, 0xd6, 0xe3, 0xe3, 0x28, 0x99, 0x6c,
0xbd, 0xb4, 0xd8, 0xb0, 0x66, 0xb9, 0x61, 0xdd, 0x89, 0x06, 0xb4, 0xf2, 0xaa, 0x94, 0x7d, 0x09,
0x8d, 0x44, 0x7e, 0xaa, 0x89, 0x7d, 0x77, 0x63, 0x32, 0x90, 0xd8, 0xcb, 0xd4, 0x4a, 0x28, 0x64,
0x96, 0x51, 0x68, 0xf0, 0xd1, 0x04, 0x9b, 0xfe, 0xda, 0x60, 0x5f, 0x01, 0xe4, 0x5d, 0xca, 0xaa,
0xf7, 0xec, 0xf3, 0xec, 0xc7, 0xd5, 0xfb, 0x30, 0x0d, 0xa6, 0xe1, 0xbb, 0xa5, 0x7b, 0xc4, 0x06,
0xda, 0x0f, 0xab, 0xaa, 0x85, 0xbb, 0xea, 0xcc, 0x33, 0xb5, 0xf4, 0x64, 0x6b, 0xc9, 0xb6, 0xdd,
0xbb, 0xea, 0x6c, 0xe6, 0xa7, 0x5c, 0x53, 0xaa, 0x57, 0xf0, 0x5d, 0x36, 0xb3, 0xa5, 0x65, 0xdb,
0x2e, 0x5e, 0x71, 0x76, 0x54, 0xa7, 0x7f, 0x77, 0x9e, 0xfe, 0x13, 0x00, 0x00, 0xff, 0xff, 0xd2,
0x0f, 0x63, 0x87, 0x06, 0x12, 0x00, 0x00,
}
......@@ -3,6 +3,7 @@ package init
import (
_ "github.com/33cn/plugin/plugin/dapp/blackwhite" //auto gen
_ "github.com/33cn/plugin/plugin/dapp/cert" //auto gen
_ "github.com/33cn/plugin/plugin/dapp/dposvote" //auto gen
_ "github.com/33cn/plugin/plugin/dapp/echo" //auto gen
_ "github.com/33cn/plugin/plugin/dapp/evm" //auto gen
_ "github.com/33cn/plugin/plugin/dapp/game" //auto gen
......
......@@ -339,6 +339,16 @@ func testProcCreateNewAccount(t *testing.T, wallet *Wallet) {
}
println("TestProcCreateNewAccount end")
println("--------------------------")
Privkey1 := "85CA38F5FB65E5E13403F0704CA6DC479D8D18FFA5D87CE5A966838C9694EAFE"
privkeybyte1, _ := common.FromHex(Privkey1)
priv1, _ := cr.PrivKeyFromBytes(privkeybyte1)
fmt.Printf("pubkey:%X\n", priv1.PubKey().Bytes())
fmt.Printf("pubkey:%s\n", priv1.PubKey().KeyString())
fmt.Printf("priv:%X\n", priv1.Bytes())
addr = address.PubKeyToAddress(priv1.PubKey().Bytes())
fmt.Printf("address:%s\n", addr.String())
fmt.Printf("addr:%X\n", addr.Hash160)
}
func equal(acc1 types.Account, acc2 types.Account) bool {
......
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