Commit c3da2ad9 authored by 张振华's avatar 张振华

merge master

parents ef5b3f90 59703110
......@@ -247,19 +247,17 @@ function sync_status() {
while [ $count -gt 0 ]; do
sync_status=$(${1} net is_sync)
if [ "${sync_status}" = "true" ]; then
break
echo "=========== query clock sync status========== "
sync_status=$(${1} net is_clock_sync)
if [ "${sync_status}" = "true" ]; then
break
fi
fi
((count--))
wait_sec=$((wait_sec + 1))
sleep 1
done
echo "sync wait ${wait_sec} s"
echo "=========== query clock sync status========== "
sync_status=$(${1} net is_clock_sync)
if [ "${sync_status}" = "false" ]; then
exit 1
fi
}
function sync() {
......
......@@ -47,8 +47,9 @@ var (
zeroHash [32]byte
grpcRecSize = 30 * 1024 * 1024 //the size should be limited in server
//current miner tx take any privatekey for unify all nodes sign purpose, and para chain is free
minerPrivateKey = "6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b"
searchHashMatchDepth int32 = 100
minerPrivateKey = "6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b"
searchHashMatchDepth int32 = 100
mainBlockHashForkHeight int64 = types.MaxHeight //calc block hash fork height in main chain
)
func init() {
......@@ -176,6 +177,12 @@ func (client *client) SetQueueClient(c queue.Client) {
}
func (client *client) InitBlock() {
var err error
mainBlockHashForkHeight, err = client.GetBlockHashForkHeightOnMainChain()
if err != nil {
panic(err)
}
block, err := client.RequestLastBlock()
if err != nil {
panic(err)
......@@ -203,6 +210,7 @@ func (client *client) GetStartSeq(height int64) int64 {
if height == 0 {
return 0
}
lastHeight, err := client.GetLastHeightOnMainChain()
if err != nil {
panic(err)
......@@ -368,6 +376,16 @@ func (client *client) getLastBlockInfo() (int64, *types.Block, []byte, int64, er
}
func (client *client) GetBlockHashForkHeightOnMainChain() (int64, error) {
ret, err := client.grpcClient.GetFork(context.Background(), &types.ReqKey{Key: []byte("ForkBlockHash")})
if err != nil {
plog.Error("para get rpc ForkBlockHash fail", "err", err.Error())
return -1, err
}
return ret.Data, nil
}
func (client *client) GetLastHeightOnMainChain() (int64, error) {
header, err := client.grpcClient.GetLastHeader(context.Background(), &types.ReqNil{})
if err != nil {
......@@ -421,6 +439,14 @@ func (client *client) GetBlockOnMainBySeq(seq int64) (*types.BlockSeq, error) {
plog.Error("Not found block on main", "seq", seq)
return nil, err
}
hash := blockSeq.Detail.Block.HashByForkHeight(mainBlockHashForkHeight)
if !bytes.Equal(blockSeq.Seq.Hash, hash) {
plog.Error("para compare ForkBlockHash fail", "forkHeight", mainBlockHashForkHeight,
"seqHash", common.Bytes2Hex(blockSeq.Seq.Hash), "calcHash", common.Bytes2Hex(hash))
return nil, types.ErrBlockHashNoMatch
}
return blockSeq, nil
}
......@@ -505,6 +531,7 @@ func (client *client) switchHashMatchedBlock(currSeq int64) (int64, []byte, erro
if err != nil {
return -2, nil, err
}
//当前block结构已经有mainHash和MainHeight但是从blockchain获取的block还没有写入,以后如果获取到,可以替换从minerTx获取
miner, err := getMinerTxInfo(block)
if err != nil {
return -2, nil, err
......@@ -684,19 +711,20 @@ func (client *client) addMinerTx(preStateHash []byte, block *types.Block, main *
func (client *client) createBlock(lastBlock *types.Block, txs []*types.Transaction, seq int64, mainBlock *types.BlockSeq) error {
var newblock types.Block
plog.Debug(fmt.Sprintf("the len txs is: %v", len(txs)))
newblock.ParentHash = lastBlock.Hash()
newblock.Height = lastBlock.Height + 1
newblock.Txs = txs
err := client.addMinerTx(lastBlock.StateHash, &newblock, mainBlock)
if err != nil {
return err
}
//挖矿固定难度
newblock.Difficulty = types.GetP(0).PowLimitBits
newblock.TxHash = merkle.CalcMerkleRoot(newblock.Txs)
newblock.BlockTime = mainBlock.Detail.Block.BlockTime
newblock.MainHash = mainBlock.Detail.Block.Hash()
newblock.MainHash = mainBlock.Seq.Hash
newblock.MainHeight = mainBlock.Detail.Block.Height
err := client.addMinerTx(lastBlock.StateHash, &newblock, mainBlock)
if err != nil {
return err
}
err = client.WriteBlock(lastBlock.StateHash, &newblock, seq)
......
......@@ -11,9 +11,13 @@ import (
"testing"
"time"
"errors"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/types"
typesmocks "github.com/33cn/chain33/types/mocks"
pt "github.com/33cn/plugin/plugin/dapp/paracross/types"
"github.com/stretchr/testify/mock"
)
var (
......@@ -222,3 +226,17 @@ func createTxsGroup(txs []*types.Transaction) ([]*types.Transaction, error) {
}
return group.Txs, nil
}
func TestGetBlockHashForkHeightOnMainChain(t *testing.T) {
para := new(client)
grpcClient := &typesmocks.Chain33Client{}
grpcClient.On("GetFork", mock.Anything, &types.ReqKey{Key: []byte("ForkBlockHash")}).Return(&types.Int64{Data: 1}, errors.New("err")).Once()
para.grpcClient = grpcClient
_, err := para.GetBlockHashForkHeightOnMainChain()
assert.NotNil(t, err)
grpcClient.On("GetFork", mock.Anything, &types.ReqKey{Key: []byte("ForkBlockHash")}).Return(&types.Int64{Data: 1}, nil).Once()
ret, err := para.GetBlockHashForkHeightOnMainChain()
assert.Nil(t, err)
assert.Equal(t, int64(1), ret)
}
......@@ -75,6 +75,7 @@ func (s *suiteParaCommitMsg) initEnv(cfg *types.Config, sub *types.ConfigSubModu
s.para = New(cfg.Consensus, sub.Consensus["para"]).(*client)
s.grpcCli = &typesmocks.Chain33Client{}
s.grpcCli.On("GetFork", mock.Anything, &types.ReqKey{Key: []byte("ForkBlockHash")}).Return(&types.Int64{Data: 1}, nil).Once()
// GetBlockBySeq return error to stop create's for cycle to request tx
s.grpcCli.On("GetBlockBySeq", mock.Anything, mock.Anything).Return(nil, errors.New("quit create"))
//data := &types.Int64{1}
......
......@@ -66,6 +66,7 @@ func (s *suiteParaClient) initEnv(cfg *types.Config, sub *types.ConfigSubModule)
s.para = New(cfg.Consensus, sub.Consensus["para"]).(*client)
s.grpcCli = &typesmocks.Chain33Client{}
s.grpcCli.On("GetFork", mock.Anything, &types.ReqKey{Key: []byte("ForkBlockHash")}).Return(&types.Int64{Data: 1}, nil).Once()
s.createBlockMock()
reply := &types.Reply{IsOk: true}
......
......@@ -46,7 +46,6 @@ func createConn(ip string) {
c = types.NewChain33Client(conn)
r = rand.New(rand.NewSource(types.Now().UnixNano()))
}
func main() {
rlog.SetLogLevel("eror")
if len(os.Args) == 1 || os.Args[1] == "-h" {
......@@ -149,7 +148,7 @@ func SendToAddress(from string, to string, amount string, note string) {
return
}
amountInt64 := int64(amountFloat64 * 1e4)
tx := &types.ReqWalletSendToAddress{From: from, To: to, Amount: amountInt64 * 1e4, Note: []byte(note)}
tx := &types.ReqWalletSendToAddress{From: from, To: to, Amount: amountInt64 * 1e4, Note: note}
reply, err := c.SendToAddress(context.Background(), tx)
if err != nil {
......
......@@ -699,7 +699,7 @@ func parseAccInfo(view interface{}) (interface{}, error) {
for _, dailyLimit := range res.DailyLimits {
dailyLimt := strconv.FormatFloat(float64(dailyLimit.DailyLimit)/float64(types.Coin), 'f', 4, 64)
spentToday := strconv.FormatFloat(float64(dailyLimit.SpentToday)/float64(types.Coin), 'f', 4, 64)
fmt.Println("parseAccInfo dailyLimt", dailyLimt)
dailyLimitResult := &mty.DailyLimitResult{
Symbol: dailyLimit.Symbol,
Execer: dailyLimit.Execer,
......
......@@ -45,7 +45,7 @@ func (m *MultiSig) Query_MultiSigAccounts(in *mty.ReqMultiSigAccs) (types.Messag
if totalcount == 0 {
return accountAddrs, nil
}
if in.End > totalcount {
if in.End >= totalcount {
return nil, types.ErrInvalidParam
}
for index := in.Start; index <= in.End; index++ {
......
......@@ -923,7 +923,7 @@ func testAbnormal(t *testing.T, mocker *testnode.Chain33Mock, jrpcClient *jsoncl
RequiredWeight: 15,
DailyLimit: symboldailylimit,
}
testAbnormalCreateTx(t, mocker, jrpcClient, req, mty.ErrInvalidSymbol)
testAbnormalCreateTx(t, mocker, jrpcClient, req, nil)
// Execer 错误
symboldailylimit = &mty.SymbolDailyLimit{
......
......@@ -5,8 +5,6 @@
package types
import (
"strings"
"github.com/33cn/chain33/common/log/log15"
"github.com/33cn/chain33/types"
)
......@@ -125,26 +123,6 @@ func IsAssetsInvalid(exec, symbol string) error {
multisiglog.Error("IsAssetsInvalid", "exec", exec)
return ErrInvalidExec
}
//Symbol检测
symbolstr := strings.Split(symbol, ".")[len(strings.Split(symbol, "."))-1]
valid := validSymbol([]byte(symbolstr))
if !valid {
multisiglog.Error("IsAssetsInvalid", "symbol", symbol)
return ErrInvalidSymbol
}
//Symbol不做检测
return nil
}
func isUpperChar(a byte) bool {
res := (a <= 'Z' && a >= 'A')
return res
}
func validSymbol(cs []byte) bool {
for _, c := range cs {
if !isUpperChar(c) {
return false
}
}
return true
}
......@@ -3,7 +3,8 @@ worker_processes 1;
events {
worker_connections 1024;
#worker_connections 1024 may not enough
worker_connections 10240;
}
......
......@@ -82,7 +82,6 @@ func (policy *privacyPolicy) reqTxDetailByAddr(addr string) {
return
}
txcount := len(ReplyTxInfos.TxInfos)
var ReqHashes types.ReqHashes
ReqHashes.Hashes = make([][]byte, len(ReplyTxInfos.TxInfos))
for index, ReplyTxInfo := range ReplyTxInfos.TxInfos {
......@@ -592,7 +591,7 @@ func (policy *privacyPolicy) createPublic2PrivacyTx(req *types.ReqCreateTransact
value := &privacytypes.Public2Privacy{
Tokenname: req.Tokenname,
Amount: amount,
Note: string(req.GetNote()),
Note: req.GetNote(),
Output: privacyOutput,
}
......@@ -662,7 +661,7 @@ func (policy *privacyPolicy) createPrivacy2PrivacyTx(req *types.ReqCreateTransac
value := &privacytypes.Privacy2Privacy{
Tokenname: req.GetTokenname(),
Amount: req.GetAmount(),
Note: string(req.GetNote()),
Note: req.GetNote(),
Input: privacyInput,
Output: privacyOutput,
}
......@@ -731,7 +730,7 @@ func (policy *privacyPolicy) createPrivacy2PublicTx(req *types.ReqCreateTransact
value := &privacytypes.Privacy2Public{
Tokenname: req.GetTokenname(),
Amount: req.GetAmount(),
Note: string(req.GetNote()),
Note: req.GetNote(),
Input: privacyInput,
Output: privacyOutput,
}
......
......@@ -1061,8 +1061,6 @@ func (bs *BlockStore) SetUpgradeMeta(meta *types.UpgradeMeta) error {
//isRecordBlockSequence配置的合法性检测
func (bs *BlockStore) isRecordBlockSequenceValid() {
storeLog.Error("isRecordBlockSequenceValid")
lastHeight := bs.Height()
lastSequence, err := bs.LoadBlockLastSequence()
if err != nil {
......
......@@ -119,6 +119,7 @@ func TestBlockChain(t *testing.T) {
testProcGetBlockBySeqMsg(t, mock33, blockchain)
testProcBlockChainFork(t, blockchain)
testDelBlock(t, blockchain, curBlock)
testIsRecordFaultErr(t)
}
......@@ -501,7 +502,7 @@ func testGetBlocksMsg(t *testing.T, blockchain *blockchain.BlockChain) {
if err == nil && blocks != nil {
for _, block := range blocks.Items {
if checkheight != block.Block.Height || block.Receipts == nil {
t.Error("testGetBlocksMsg Block Height or Receipts check error")
t.Error("TestGetBlocksMsg", "checkheight", checkheight, "block", block)
}
checkheight++
}
......@@ -955,3 +956,11 @@ func testAddBlockSeqCB(t *testing.T, blockchain *blockchain.BlockChain) {
}
chainlog.Info("testAddBlockSeqCB end -------------------------")
}
func testIsRecordFaultErr(t *testing.T) {
chainlog.Info("testIsRecordFaultErr begin ---------------------")
isok := blockchain.IsRecordFaultErr(types.ErrFutureBlock)
if isok {
t.Error("testIsRecordFaultErr IsRecordFaultErr", "isok", isok)
}
chainlog.Info("testIsRecordFaultErr begin ---------------------")
}
......@@ -231,7 +231,6 @@ func (chain *BlockChain) addBlockDetail(msg queue.Message) {
blockDetail := msg.Data.(*types.BlockDetail)
Height := blockDetail.Block.Height
chainlog.Info("EventAddBlockDetail", "height", blockDetail.Block.Height, "parent", common.ToHex(blockDetail.Block.ParentHash))
//首先判断共识过来的block的parenthash是否是当前bestchain链的tip区块,如果不是就直接返回错误给共识模块
blockDetail, err := chain.ProcAddBlockMsg(true, blockDetail, "self")
if err != nil {
chainlog.Error("addBlockDetail", "err", err.Error())
......@@ -244,7 +243,6 @@ func (chain *BlockChain) addBlockDetail(msg queue.Message) {
msg.Reply(chain.client.NewMessage("consensus", types.EventAddBlockDetail, err))
return
}
//获取此高度区块执行后的区块详情blockdetail返回给共识模块
chainlog.Debug("addBlockDetail success ", "Height", Height, "hash", common.HashHex(blockDetail.Block.Hash()))
msg.Reply(chain.client.NewMessage("consensus", types.EventAddBlockDetail, blockDetail))
}
......
......@@ -10,6 +10,7 @@ import (
"math/big"
"sync/atomic"
"github.com/33cn/chain33/client/api"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/difficulty"
"github.com/33cn/chain33/types"
......@@ -296,14 +297,19 @@ func (b *BlockChain) connectBlock(node *blockNode, blockdetail *types.BlockDetai
block := blockdetail.Block
prevStateHash := b.bestChain.Tip().statehash
//广播或者同步过来的blcok需要调用执行模块
errReturn := (node.pid != "self")
//println("--exec before--")
blockdetail, _, err = execBlock(b.client, prevStateHash, block, errReturn, sync)
//println("--exec end--")
if err != nil && err != types.ErrFutureBlock {
//记录执行出错的block信息,需要过滤掉ErrFutureBlock错误的block,不计入故障中,尝试再次执行
b.RecordFaultPeer(node.pid, block.Height, node.hash, err)
if err != nil {
//记录执行出错的block信息,需要过滤掉一些特殊的错误,不计入故障中,尝试再次执行
if IsRecordFaultErr(err) {
b.RecordFaultPeer(node.pid, block.Height, node.hash, err)
} else if node.pid == "self" {
// 本节点产生的block由于api或者queue导致执行失败需要删除block在index中的记录,
// 返回错误信息给共识模块,由共识模块尝试再次发起block的执行
// 同步或者广播过来的情况会再下了一个区块过来后重新触发此block的执行
chainlog.Debug("connectBlock DelNode!", "height", block.Height, "node.hash", common.ToHex(node.hash), "err", err)
b.index.DelNode(node.hash)
}
chainlog.Error("connectBlock ExecBlock is err!", "height", block.Height, "err", err)
return nil, err
}
......@@ -578,3 +584,8 @@ func (b *BlockChain) ProcessDelParaChainBlock(broadcast bool, blockdetail *types
return nil, true, false, nil
}
// IsRecordFaultErr 检测此错误是否要记录到故障错误中
func IsRecordFaultErr(err error) bool {
return err != types.ErrFutureBlock && !api.IsGrpcError(err) && !api.IsQueueError(err)
}
......@@ -436,7 +436,7 @@ func testWalletSendToAddress(t *testing.T, api client.QueueProtocolAPI) {
if err == nil {
t.Error("WalletSendToAddress(nil) need return error.")
}
_, err = api.WalletSendToAddress(&types.ReqWalletSendToAddress{Note: []byte("case1")})
_, err = api.WalletSendToAddress(&types.ReqWalletSendToAddress{Note: "case1"})
if err == nil {
t.Error("WalletSendToAddress(&types.ReqWalletSendToAddress{Note:\"case1\"}) need return error.")
}
......
......@@ -371,7 +371,7 @@ func createPub2PrivTx(cmd *cobra.Command, args []string) {
Tokenname: tokenname,
Type: types.PrivacyTypePublic2Privacy,
Amount: amount,
Note: []byte(note),
Note: note,
Pubkeypair: pubkeypair,
Expire: expire,
}
......@@ -431,7 +431,7 @@ func createPriv2PrivTx(cmd *cobra.Command, args []string) {
Tokenname: tokenname,
Type: types.PrivacyTypePrivacy2Privacy,
Amount: amount,
Note: []byte(note),
Note: note,
Pubkeypair: pubkeypair,
From: sender,
Mixcount: defaultPrivacyMixCount,
......@@ -493,7 +493,7 @@ func createPriv2PubTx(cmd *cobra.Command, args []string) {
Tokenname: tokenname,
Type: types.PrivacyTypePrivacy2Public,
Amount: amount,
Note: []byte(note),
Note: note,
From: from,
To: to,
Mixcount: defaultPrivacyMixCount,
......
......@@ -66,7 +66,7 @@ func SendToAddress(rpcAddr string, from string, to string, amount int64, note st
if isWithdraw {
amt = -amount
}
params := types.ReqWalletSendToAddress{From: from, To: to, Amount: amt, Note: []byte(note)}
params := types.ReqWalletSendToAddress{From: from, To: to, Amount: amt, Note: note}
if !isToken {
params.IsToken = false
} else {
......
......@@ -521,7 +521,11 @@ func (m *Marshaler) marshalValue(out *errWriter, prop *proto.Properties, v refle
return out.err
}
//[]byte
//[]byte 写bytes 的情况,默认情况下,转化成 hex
//为什么不用base64:
//1. 我们的数据都经过压缩(base64带来的字节数的减少有限)
//2. hex 是一种最容易解析的格式
//3. 我们的hash 默认是 bytes,而且转化成hex
if v.Kind() == reflect.Slice && v.Type().Elem().Kind() == reflect.Uint8 {
if v.IsNil() {
out.write("null")
......@@ -1037,7 +1041,7 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe
if err != nil {
return err
}
b, err := common.FromHex(hexstr)
b, err := parseBytes(hexstr)
if err != nil {
return err
}
......@@ -1309,3 +1313,19 @@ func checkRequiredFieldsInValue(v reflect.Value) error {
}
return nil
}
//ErrBytesFormat 错误的bytes 类型
var ErrBytesFormat = errors.New("ErrBytesFormat")
func parseBytes(jsonstr string) ([]byte, error) {
if jsonstr == "" {
return []byte{}, nil
}
if strings.HasPrefix(jsonstr, "str://") {
return []byte(jsonstr[len("str://"):]), nil
}
if strings.HasPrefix(jsonstr, "0x") || strings.HasPrefix(jsonstr, "0X") {
return common.FromHex(jsonstr)
}
return nil, ErrBytesFormat
}
......@@ -524,7 +524,6 @@ var marshalingTests = []struct {
{"BoolValue", marshaler, &pb.KnownTypes{Bool: &wpb.BoolValue{Value: true}}, `{"bool":true}`},
{"StringValue", marshaler, &pb.KnownTypes{Str: &wpb.StringValue{Value: "plush"}}, `{"str":"plush"}`},
{"BytesValue", marshaler, &pb.KnownTypes{Bytes: &wpb.BytesValue{Value: []byte("wow")}}, `{"bytes":"0x776f77"}`},
{"required", marshaler, &pb.MsgWithRequired{Str: proto.String("hello")}, `{"str":"hello"}`},
{"required bytes", marshaler, &pb.MsgWithRequiredBytes{Byts: []byte{}}, `{"byts":""}`},
}
......@@ -833,7 +832,9 @@ var unmarshalingTests = []struct {
},
}},
{"BytesValue", Unmarshaler{}, `{"bytes":"0x776f77"}`, &pb.KnownTypes{Bytes: &wpb.BytesValue{Value: []byte("wow")}}},
{"BytesValue", Unmarshaler{}, `{"bytes":"0X776f77"}`, &pb.KnownTypes{Bytes: &wpb.BytesValue{Value: []byte("wow")}}},
{"BytesValue", Unmarshaler{}, `{"bytes":"str://wow"}`, &pb.KnownTypes{Bytes: &wpb.BytesValue{Value: []byte("wow")}}},
{"BytesValue", Unmarshaler{}, `{"bytes":"str://"}`, &pb.KnownTypes{Bytes: &wpb.BytesValue{Value: []byte("")}}},
// Ensure that `null` as a value ends up with a nil pointer instead of a [type]Value struct.
{"null DoubleValue", Unmarshaler{}, `{"dbl":null}`, &pb.KnownTypes{Dbl: nil}},
{"null FloatValue", Unmarshaler{}, `{"flt":null}`, &pb.KnownTypes{Flt: nil}},
......
......@@ -147,7 +147,7 @@ message ReqWalletSendToAddress {
string from = 1;
string to = 2;
int64 amount = 3;
bytes note = 4;
string note = 4;
bool isToken = 5;
string tokenSymbol = 6;
}
......@@ -232,9 +232,9 @@ message ReqCreateTransaction {
// 1:隐私交易 公开->隐私
// 2:隐私交易 隐私->隐私
// 3:隐私交易 隐私->公开
int32 type = 2;
int64 amount = 3;
bytes note = 4;
int32 type = 2;
int64 amount = 3;
string note = 4;
// 普通交易的发送方
string from = 5;
// 普通交易的接收方
......
......@@ -124,9 +124,20 @@ func TestProtoToJson(t *testing.T) {
assert.Equal(t, dr.Msg, []byte("OK"))
err = jsonpb.UnmarshalString(`{"isOk":false,"msg":"4f4b"}`, &dr)
assert.Equal(t, err, jsonpb.ErrBytesFormat)
err = jsonpb.UnmarshalString(`{"isOk":false,"msg":"0x"}`, &dr)
assert.Nil(t, err)
assert.Equal(t, dr.Msg, []byte(""))
err = jsonpb.UnmarshalString(`{"isOk":false,"msg":"str://OK"}`, &dr)
assert.Nil(t, err)
assert.Equal(t, dr.Msg, []byte("OK"))
err = jsonpb.UnmarshalString(`{"isOk":false,"msg":"str://0"}`, &dr)
assert.Nil(t, err)
assert.Equal(t, dr.Msg, []byte("0"))
r = &Reply{Msg: []byte{}}
b, err = json.Marshal(r)
assert.Nil(t, err)
......
......@@ -884,7 +884,7 @@ type ReqWalletSendToAddress struct {
From string `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"`
To string `protobuf:"bytes,2,opt,name=to,proto3" json:"to,omitempty"`
Amount int64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty"`
Note []byte `protobuf:"bytes,4,opt,name=note,proto3" json:"note,omitempty"`
Note string `protobuf:"bytes,4,opt,name=note,proto3" json:"note,omitempty"`
IsToken bool `protobuf:"varint,5,opt,name=isToken,proto3" json:"isToken,omitempty"`
TokenSymbol string `protobuf:"bytes,6,opt,name=tokenSymbol,proto3" json:"tokenSymbol,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
......@@ -938,11 +938,11 @@ func (m *ReqWalletSendToAddress) GetAmount() int64 {
return 0
}
func (m *ReqWalletSendToAddress) GetNote() []byte {
func (m *ReqWalletSendToAddress) GetNote() string {
if m != nil {
return m.Note
}
return nil
return ""
}
func (m *ReqWalletSendToAddress) GetIsToken() bool {
......@@ -1594,7 +1594,7 @@ type ReqCreateTransaction struct {
// 3:隐私交易 隐私->公开
Type int32 `protobuf:"varint,2,opt,name=type,proto3" json:"type,omitempty"`
Amount int64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty"`
Note []byte `protobuf:"bytes,4,opt,name=note,proto3" json:"note,omitempty"`
Note string `protobuf:"bytes,4,opt,name=note,proto3" json:"note,omitempty"`
// 普通交易的发送方
From string `protobuf:"bytes,5,opt,name=from,proto3" json:"from,omitempty"`
// 普通交易的接收方
......@@ -1654,11 +1654,11 @@ func (m *ReqCreateTransaction) GetAmount() int64 {
return 0
}
func (m *ReqCreateTransaction) GetNote() []byte {
func (m *ReqCreateTransaction) GetNote() string {
if m != nil {
return m.Note
}
return nil
return ""
}
func (m *ReqCreateTransaction) GetFrom() string {
......@@ -1771,7 +1771,7 @@ func init() {
func init() { proto.RegisterFile("wallet.proto", fileDescriptor_b88fd140af4deb6f) }
var fileDescriptor_b88fd140af4deb6f = []byte{
// 1305 bytes of a gzipped FileDescriptorProto
// 1304 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x5f, 0x6e, 0x1b, 0x37,
0x13, 0xc7, 0x4a, 0x96, 0x6d, 0xd1, 0xb2, 0x93, 0x2c, 0x92, 0x40, 0xf0, 0xf7, 0x25, 0x71, 0x58,
0x24, 0x75, 0x81, 0xc2, 0x01, 0xa2, 0x97, 0xa2, 0x40, 0x81, 0x38, 0x7f, 0x1d, 0xc0, 0x49, 0x0d,
......@@ -1819,39 +1819,39 @@ var fileDescriptor_b88fd140af4deb6f = []byte{
0x36, 0xf6, 0xc2, 0xbf, 0xd9, 0x2f, 0x7c, 0xcd, 0xfc, 0xf7, 0xa8, 0x66, 0x6a, 0x08, 0x79, 0x3a,
0xd2, 0xa7, 0x69, 0x6a, 0xa0, 0x2c, 0x91, 0x51, 0xbc, 0x62, 0x60, 0x14, 0xd7, 0xf1, 0x01, 0x6b,
0x59, 0xed, 0x2d, 0xb4, 0xac, 0xae, 0x35, 0xc8, 0x76, 0xa3, 0x41, 0xc6, 0x6c, 0x2b, 0xd7, 0x16,
0xe8, 0xc5, 0xf4, 0x04, 0xad, 0xf1, 0x6a, 0xaa, 0x1c, 0xe9, 0x19, 0xe4, 0xd4, 0x68, 0x77, 0x45,
0x80, 0xf1, 0x11, 0xdb, 0xb3, 0xb8, 0x18, 0xae, 0xe7, 0x63, 0x9d, 0x51, 0xaf, 0xed, 0x8a, 0xba,
0x88, 0x7f, 0xc3, 0x6e, 0xd5, 0x33, 0xf9, 0x16, 0xea, 0xbd, 0x39, 0xaa, 0xbb, 0xe6, 0x3f, 0xb0,
0x3b, 0x75, 0xd5, 0xf3, 0x46, 0xd3, 0x8a, 0x6a, 0x4d, 0xeb, 0x66, 0x42, 0xbe, 0x66, 0xf7, 0x36,
0xc7, 0x3f, 0x80, 0x99, 0xc0, 0x4b, 0x99, 0xc9, 0x3c, 0x01, 0x1f, 0x7a, 0x14, 0x42, 0xe7, 0x7f,
0x46, 0xe4, 0x88, 0x22, 0xb8, 0x30, 0xf0, 0xca, 0x80, 0xb4, 0x10, 0x3f, 0x66, 0xbd, 0x04, 0x57,
0xda, 0xfc, 0x5a, 0x73, 0xb8, 0xe7, 0x65, 0x48, 0x2d, 0x71, 0x83, 0x5f, 0x80, 0x73, 0x4b, 0x6b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 0x2e, 0x0e, 0xf1, 0xef, 0x90, 0xef, 0x2b, 0xff, 0x5f, 0xd1, 0x0f, 0x84, 0xbf,
0xbb, 0xb2, 0x53, 0xbd, 0xb0, 0xbe, 0xa7, 0xf9, 0xb1, 0xe9, 0x13, 0xe9, 0xcb, 0x47, 0xbf, 0x3c,
0x98, 0x28, 0x3b, 0x5d, 0x8c, 0x4f, 0x12, 0x3d, 0x7f, 0x36, 0x18, 0x24, 0xf9, 0x33, 0x1a, 0xf2,
0x07, 0x83, 0x67, 0x34, 0x8b, 0x8c, 0xb7, 0x69, 0x9c, 0x1f, 0xfc, 0x13, 0x00, 0x00, 0xff, 0xff,
0xb9, 0xa3, 0x5d, 0xe0, 0x29, 0x0c, 0x00, 0x00,
}
......@@ -17,9 +17,9 @@ import (
)
var (
listenAddr = "localhost:8805"
unSyncMaxTimes uint32 = 6 //max 6 times
checkInterval uint32 = 5 // 5s
listenAddr = ":8805" //as server, should keep default 0.0.0.0
unSyncMaxTimes uint32 = 6 //max 6 times
checkInterval uint32 = 5 // 5s
)
// HealthCheckServer a node's health check server
......
......@@ -552,7 +552,7 @@ func (wallet *Wallet) ProcSendToAddress(SendToAddress *types.ReqWalletSendToAddr
if err != nil {
return nil, err
}
return wallet.sendToAddress(priv, addrto, amount, string(note), SendToAddress.IsToken, SendToAddress.TokenSymbol)
return wallet.sendToAddress(priv, addrto, amount, note, SendToAddress.IsToken, SendToAddress.TokenSymbol)
}
// ProcWalletSetFee 处理设置手续费
......
......@@ -464,7 +464,7 @@ func testProcSendToAddress(t *testing.T, wallet *Wallet) {
transfer := &types.ReqWalletSendToAddress{
Amount: 1000,
From: FromAddr,
Note: []byte("test"),
Note: "test",
To: "1L1zEgVcjqdM2KkQixENd7SZTaudKkcyDu",
}
msg := wallet.client.NewMessage("wallet", types.EventWalletSendToAddress, transfer)
......@@ -476,7 +476,7 @@ func testProcSendToAddress(t *testing.T, wallet *Wallet) {
withdraw := &types.ReqWalletSendToAddress{
Amount: -1000,
From: FromAddr,
Note: []byte("test"),
Note: "test",
To: "16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp",
}
msg = wallet.client.NewMessage("wallet", types.EventWalletSendToAddress, withdraw)
......@@ -597,7 +597,7 @@ func testProcWalletLock(t *testing.T, wallet *Wallet) {
transfer := &types.ReqWalletSendToAddress{
Amount: 1000,
From: FromAddr,
Note: []byte("test"),
Note: "test",
To: "1L1zEgVcjqdM2KkQixENd7SZTaudKkcyDu",
}
msg = wallet.client.NewMessage("wallet", types.EventWalletSendToAddress, transfer)
......
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