Commit 7ef7e54f authored by vipwzw's avatar vipwzw Committed by 33cn

update chain33 2019/01/16

parent 75dc19c4
...@@ -1061,8 +1061,6 @@ func (bs *BlockStore) SetUpgradeMeta(meta *types.UpgradeMeta) error { ...@@ -1061,8 +1061,6 @@ func (bs *BlockStore) SetUpgradeMeta(meta *types.UpgradeMeta) error {
//isRecordBlockSequence配置的合法性检测 //isRecordBlockSequence配置的合法性检测
func (bs *BlockStore) isRecordBlockSequenceValid() { func (bs *BlockStore) isRecordBlockSequenceValid() {
storeLog.Error("isRecordBlockSequenceValid")
lastHeight := bs.Height() lastHeight := bs.Height()
lastSequence, err := bs.LoadBlockLastSequence() lastSequence, err := bs.LoadBlockLastSequence()
if err != nil { if err != nil {
......
...@@ -119,6 +119,7 @@ func TestBlockChain(t *testing.T) { ...@@ -119,6 +119,7 @@ func TestBlockChain(t *testing.T) {
testProcGetBlockBySeqMsg(t, mock33, blockchain) testProcGetBlockBySeqMsg(t, mock33, blockchain)
testProcBlockChainFork(t, blockchain) testProcBlockChainFork(t, blockchain)
testDelBlock(t, blockchain, curBlock) testDelBlock(t, blockchain, curBlock)
testIsRecordFaultErr(t)
} }
...@@ -501,7 +502,7 @@ func testGetBlocksMsg(t *testing.T, blockchain *blockchain.BlockChain) { ...@@ -501,7 +502,7 @@ func testGetBlocksMsg(t *testing.T, blockchain *blockchain.BlockChain) {
if err == nil && blocks != nil { if err == nil && blocks != nil {
for _, block := range blocks.Items { for _, block := range blocks.Items {
if checkheight != block.Block.Height || block.Receipts == nil { 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++ checkheight++
} }
...@@ -955,3 +956,11 @@ func testAddBlockSeqCB(t *testing.T, blockchain *blockchain.BlockChain) { ...@@ -955,3 +956,11 @@ func testAddBlockSeqCB(t *testing.T, blockchain *blockchain.BlockChain) {
} }
chainlog.Info("testAddBlockSeqCB end -------------------------") 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) { ...@@ -231,7 +231,6 @@ func (chain *BlockChain) addBlockDetail(msg queue.Message) {
blockDetail := msg.Data.(*types.BlockDetail) blockDetail := msg.Data.(*types.BlockDetail)
Height := blockDetail.Block.Height Height := blockDetail.Block.Height
chainlog.Info("EventAddBlockDetail", "height", blockDetail.Block.Height, "parent", common.ToHex(blockDetail.Block.ParentHash)) chainlog.Info("EventAddBlockDetail", "height", blockDetail.Block.Height, "parent", common.ToHex(blockDetail.Block.ParentHash))
//首先判断共识过来的block的parenthash是否是当前bestchain链的tip区块,如果不是就直接返回错误给共识模块
blockDetail, err := chain.ProcAddBlockMsg(true, blockDetail, "self") blockDetail, err := chain.ProcAddBlockMsg(true, blockDetail, "self")
if err != nil { if err != nil {
chainlog.Error("addBlockDetail", "err", err.Error()) chainlog.Error("addBlockDetail", "err", err.Error())
...@@ -244,7 +243,6 @@ func (chain *BlockChain) addBlockDetail(msg queue.Message) { ...@@ -244,7 +243,6 @@ func (chain *BlockChain) addBlockDetail(msg queue.Message) {
msg.Reply(chain.client.NewMessage("consensus", types.EventAddBlockDetail, err)) msg.Reply(chain.client.NewMessage("consensus", types.EventAddBlockDetail, err))
return return
} }
//获取此高度区块执行后的区块详情blockdetail返回给共识模块
chainlog.Debug("addBlockDetail success ", "Height", Height, "hash", common.HashHex(blockDetail.Block.Hash())) chainlog.Debug("addBlockDetail success ", "Height", Height, "hash", common.HashHex(blockDetail.Block.Hash()))
msg.Reply(chain.client.NewMessage("consensus", types.EventAddBlockDetail, blockDetail)) msg.Reply(chain.client.NewMessage("consensus", types.EventAddBlockDetail, blockDetail))
} }
......
...@@ -10,6 +10,7 @@ import ( ...@@ -10,6 +10,7 @@ import (
"math/big" "math/big"
"sync/atomic" "sync/atomic"
"github.com/33cn/chain33/client/api"
"github.com/33cn/chain33/common" "github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/difficulty" "github.com/33cn/chain33/common/difficulty"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
...@@ -296,14 +297,19 @@ func (b *BlockChain) connectBlock(node *blockNode, blockdetail *types.BlockDetai ...@@ -296,14 +297,19 @@ func (b *BlockChain) connectBlock(node *blockNode, blockdetail *types.BlockDetai
block := blockdetail.Block block := blockdetail.Block
prevStateHash := b.bestChain.Tip().statehash prevStateHash := b.bestChain.Tip().statehash
//广播或者同步过来的blcok需要调用执行模块
errReturn := (node.pid != "self") errReturn := (node.pid != "self")
//println("--exec before--")
blockdetail, _, err = execBlock(b.client, prevStateHash, block, errReturn, sync) blockdetail, _, err = execBlock(b.client, prevStateHash, block, errReturn, sync)
//println("--exec end--") if err != nil {
if err != nil && err != types.ErrFutureBlock { //记录执行出错的block信息,需要过滤掉一些特殊的错误,不计入故障中,尝试再次执行
//记录执行出错的block信息,需要过滤掉ErrFutureBlock错误的block,不计入故障中,尝试再次执行 if IsRecordFaultErr(err) {
b.RecordFaultPeer(node.pid, block.Height, node.hash, 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) chainlog.Error("connectBlock ExecBlock is err!", "height", block.Height, "err", err)
return nil, err return nil, err
} }
...@@ -578,3 +584,8 @@ func (b *BlockChain) ProcessDelParaChainBlock(broadcast bool, blockdetail *types ...@@ -578,3 +584,8 @@ func (b *BlockChain) ProcessDelParaChainBlock(broadcast bool, blockdetail *types
return nil, true, false, nil 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) { ...@@ -436,7 +436,7 @@ func testWalletSendToAddress(t *testing.T, api client.QueueProtocolAPI) {
if err == nil { if err == nil {
t.Error("WalletSendToAddress(nil) need return error.") 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 { if err == nil {
t.Error("WalletSendToAddress(&types.ReqWalletSendToAddress{Note:\"case1\"}) need return error.") t.Error("WalletSendToAddress(&types.ReqWalletSendToAddress{Note:\"case1\"}) need return error.")
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package commands package commands
import ( import (
"encoding/json"
"fmt" "fmt"
"math" "math"
"os" "os"
...@@ -132,10 +133,15 @@ func CreateAssetSendToExec(cmd *cobra.Command, args []string, fromExec string) { ...@@ -132,10 +133,15 @@ func CreateAssetSendToExec(cmd *cobra.Command, args []string, fromExec string) {
ExecName: exec, ExecName: exec,
} }
data, err := json.Marshal(&payload)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
params := &rpcTypes.CreateTxIn{ params := &rpcTypes.CreateTxIn{
Execer: types.ExecName(fromExec), Execer: types.ExecName(fromExec),
ActionName: "TransferToExec", ActionName: "TransferToExec",
Payload: types.MustPBToJSON(payload), Payload: data,
} }
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr") rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
...@@ -165,10 +171,15 @@ func CreateAssetWithdraw(cmd *cobra.Command, args []string, fromExec string) { ...@@ -165,10 +171,15 @@ func CreateAssetWithdraw(cmd *cobra.Command, args []string, fromExec string) {
Cointoken: symbol, Cointoken: symbol,
ExecName: exec, ExecName: exec,
} }
data, err := json.Marshal(&payload)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
params := &rpcTypes.CreateTxIn{ params := &rpcTypes.CreateTxIn{
Execer: types.ExecName(fromExec), Execer: types.ExecName(fromExec),
ActionName: "Withdraw", ActionName: "Withdraw",
Payload: types.MustPBToJSON(payload), Payload: data,
} }
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr") rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
...@@ -189,10 +200,15 @@ func CreateAssetTransfer(cmd *cobra.Command, args []string, fromExec string) { ...@@ -189,10 +200,15 @@ func CreateAssetTransfer(cmd *cobra.Command, args []string, fromExec string) {
Note: []byte(note), Note: []byte(note),
Cointoken: symbol, Cointoken: symbol,
} }
data, err := json.Marshal(&payload)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
params := &rpcTypes.CreateTxIn{ params := &rpcTypes.CreateTxIn{
Execer: types.ExecName(fromExec), Execer: types.ExecName(fromExec),
ActionName: "Transfer", ActionName: "Transfer",
Payload: types.MustPBToJSON(payload), Payload: data,
} }
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr") rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
......
...@@ -371,7 +371,7 @@ func createPub2PrivTx(cmd *cobra.Command, args []string) { ...@@ -371,7 +371,7 @@ func createPub2PrivTx(cmd *cobra.Command, args []string) {
Tokenname: tokenname, Tokenname: tokenname,
Type: types.PrivacyTypePublic2Privacy, Type: types.PrivacyTypePublic2Privacy,
Amount: amount, Amount: amount,
Note: []byte(note), Note: note,
Pubkeypair: pubkeypair, Pubkeypair: pubkeypair,
Expire: expire, Expire: expire,
} }
...@@ -431,7 +431,7 @@ func createPriv2PrivTx(cmd *cobra.Command, args []string) { ...@@ -431,7 +431,7 @@ func createPriv2PrivTx(cmd *cobra.Command, args []string) {
Tokenname: tokenname, Tokenname: tokenname,
Type: types.PrivacyTypePrivacy2Privacy, Type: types.PrivacyTypePrivacy2Privacy,
Amount: amount, Amount: amount,
Note: []byte(note), Note: note,
Pubkeypair: pubkeypair, Pubkeypair: pubkeypair,
From: sender, From: sender,
Mixcount: defaultPrivacyMixCount, Mixcount: defaultPrivacyMixCount,
...@@ -493,7 +493,7 @@ func createPriv2PubTx(cmd *cobra.Command, args []string) { ...@@ -493,7 +493,7 @@ func createPriv2PubTx(cmd *cobra.Command, args []string) {
Tokenname: tokenname, Tokenname: tokenname,
Type: types.PrivacyTypePrivacy2Public, Type: types.PrivacyTypePrivacy2Public,
Amount: amount, Amount: amount,
Note: []byte(note), Note: note,
From: from, From: from,
To: to, To: to,
Mixcount: defaultPrivacyMixCount, Mixcount: defaultPrivacyMixCount,
......
...@@ -66,7 +66,7 @@ func SendToAddress(rpcAddr string, from string, to string, amount int64, note st ...@@ -66,7 +66,7 @@ func SendToAddress(rpcAddr string, from string, to string, amount int64, note st
if isWithdraw { if isWithdraw {
amt = -amount 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 { if !isToken {
params.IsToken = false params.IsToken = false
} else { } else {
......
...@@ -521,7 +521,11 @@ func (m *Marshaler) marshalValue(out *errWriter, prop *proto.Properties, v refle ...@@ -521,7 +521,11 @@ func (m *Marshaler) marshalValue(out *errWriter, prop *proto.Properties, v refle
return out.err 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.Kind() == reflect.Slice && v.Type().Elem().Kind() == reflect.Uint8 {
if v.IsNil() { if v.IsNil() {
out.write("null") out.write("null")
...@@ -1037,7 +1041,7 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe ...@@ -1037,7 +1041,7 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe
if err != nil { if err != nil {
return err return err
} }
b, err := common.FromHex(hexstr) b, err := parseBytes(hexstr)
if err != nil { if err != nil {
return err return err
} }
...@@ -1309,3 +1313,19 @@ func checkRequiredFieldsInValue(v reflect.Value) error { ...@@ -1309,3 +1313,19 @@ func checkRequiredFieldsInValue(v reflect.Value) error {
} }
return nil 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 { ...@@ -524,7 +524,6 @@ var marshalingTests = []struct {
{"BoolValue", marshaler, &pb.KnownTypes{Bool: &wpb.BoolValue{Value: true}}, `{"bool":true}`}, {"BoolValue", marshaler, &pb.KnownTypes{Bool: &wpb.BoolValue{Value: true}}, `{"bool":true}`},
{"StringValue", marshaler, &pb.KnownTypes{Str: &wpb.StringValue{Value: "plush"}}, `{"str":"plush"}`}, {"StringValue", marshaler, &pb.KnownTypes{Str: &wpb.StringValue{Value: "plush"}}, `{"str":"plush"}`},
{"BytesValue", marshaler, &pb.KnownTypes{Bytes: &wpb.BytesValue{Value: []byte("wow")}}, `{"bytes":"0x776f77"}`}, {"BytesValue", marshaler, &pb.KnownTypes{Bytes: &wpb.BytesValue{Value: []byte("wow")}}, `{"bytes":"0x776f77"}`},
{"required", marshaler, &pb.MsgWithRequired{Str: proto.String("hello")}, `{"str":"hello"}`}, {"required", marshaler, &pb.MsgWithRequired{Str: proto.String("hello")}, `{"str":"hello"}`},
{"required bytes", marshaler, &pb.MsgWithRequiredBytes{Byts: []byte{}}, `{"byts":""}`}, {"required bytes", marshaler, &pb.MsgWithRequiredBytes{Byts: []byte{}}, `{"byts":""}`},
} }
...@@ -833,7 +832,9 @@ var unmarshalingTests = []struct { ...@@ -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":"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. // 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 DoubleValue", Unmarshaler{}, `{"dbl":null}`, &pb.KnownTypes{Dbl: nil}},
{"null FloatValue", Unmarshaler{}, `{"flt":null}`, &pb.KnownTypes{Flt: nil}}, {"null FloatValue", Unmarshaler{}, `{"flt":null}`, &pb.KnownTypes{Flt: nil}},
......
...@@ -147,7 +147,7 @@ message ReqWalletSendToAddress { ...@@ -147,7 +147,7 @@ message ReqWalletSendToAddress {
string from = 1; string from = 1;
string to = 2; string to = 2;
int64 amount = 3; int64 amount = 3;
bytes note = 4; string note = 4;
bool isToken = 5; bool isToken = 5;
string tokenSymbol = 6; string tokenSymbol = 6;
} }
...@@ -232,9 +232,9 @@ message ReqCreateTransaction { ...@@ -232,9 +232,9 @@ message ReqCreateTransaction {
// 1:隐私交易 公开->隐私 // 1:隐私交易 公开->隐私
// 2:隐私交易 隐私->隐私 // 2:隐私交易 隐私->隐私
// 3:隐私交易 隐私->公开 // 3:隐私交易 隐私->公开
int32 type = 2; int32 type = 2;
int64 amount = 3; int64 amount = 3;
bytes note = 4; string note = 4;
// 普通交易的发送方 // 普通交易的发送方
string from = 5; string from = 5;
// 普通交易的接收方 // 普通交易的接收方
......
...@@ -124,9 +124,20 @@ func TestProtoToJson(t *testing.T) { ...@@ -124,9 +124,20 @@ func TestProtoToJson(t *testing.T) {
assert.Equal(t, dr.Msg, []byte("OK")) assert.Equal(t, dr.Msg, []byte("OK"))
err = jsonpb.UnmarshalString(`{"isOk":false,"msg":"4f4b"}`, &dr) 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.Nil(t, err)
assert.Equal(t, dr.Msg, []byte("OK")) 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{}} r = &Reply{Msg: []byte{}}
b, err = json.Marshal(r) b, err = json.Marshal(r)
assert.Nil(t, err) assert.Nil(t, err)
......
...@@ -884,7 +884,7 @@ type ReqWalletSendToAddress struct { ...@@ -884,7 +884,7 @@ type ReqWalletSendToAddress struct {
From string `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"` From string `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"`
To string `protobuf:"bytes,2,opt,name=to,proto3" json:"to,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"` 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"` IsToken bool `protobuf:"varint,5,opt,name=isToken,proto3" json:"isToken,omitempty"`
TokenSymbol string `protobuf:"bytes,6,opt,name=tokenSymbol,proto3" json:"tokenSymbol,omitempty"` TokenSymbol string `protobuf:"bytes,6,opt,name=tokenSymbol,proto3" json:"tokenSymbol,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
...@@ -938,11 +938,11 @@ func (m *ReqWalletSendToAddress) GetAmount() int64 { ...@@ -938,11 +938,11 @@ func (m *ReqWalletSendToAddress) GetAmount() int64 {
return 0 return 0
} }
func (m *ReqWalletSendToAddress) GetNote() []byte { func (m *ReqWalletSendToAddress) GetNote() string {
if m != nil { if m != nil {
return m.Note return m.Note
} }
return nil return ""
} }
func (m *ReqWalletSendToAddress) GetIsToken() bool { func (m *ReqWalletSendToAddress) GetIsToken() bool {
...@@ -1594,7 +1594,7 @@ type ReqCreateTransaction struct { ...@@ -1594,7 +1594,7 @@ type ReqCreateTransaction struct {
// 3:隐私交易 隐私->公开 // 3:隐私交易 隐私->公开
Type int32 `protobuf:"varint,2,opt,name=type,proto3" json:"type,omitempty"` Type int32 `protobuf:"varint,2,opt,name=type,proto3" json:"type,omitempty"`
Amount int64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,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"` From string `protobuf:"bytes,5,opt,name=from,proto3" json:"from,omitempty"`
// 普通交易的接收方 // 普通交易的接收方
...@@ -1654,11 +1654,11 @@ func (m *ReqCreateTransaction) GetAmount() int64 { ...@@ -1654,11 +1654,11 @@ func (m *ReqCreateTransaction) GetAmount() int64 {
return 0 return 0
} }
func (m *ReqCreateTransaction) GetNote() []byte { func (m *ReqCreateTransaction) GetNote() string {
if m != nil { if m != nil {
return m.Note return m.Note
} }
return nil return ""
} }
func (m *ReqCreateTransaction) GetFrom() string { func (m *ReqCreateTransaction) GetFrom() string {
...@@ -1771,7 +1771,7 @@ func init() { ...@@ -1771,7 +1771,7 @@ func init() {
func init() { proto.RegisterFile("wallet.proto", fileDescriptor_b88fd140af4deb6f) } func init() { proto.RegisterFile("wallet.proto", fileDescriptor_b88fd140af4deb6f) }
var fileDescriptor_b88fd140af4deb6f = []byte{ 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, 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, 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, 0x24, 0x75, 0x81, 0xc2, 0x01, 0xa2, 0x97, 0xa2, 0x40, 0x81, 0x38, 0x7f, 0x1d, 0xc0, 0x49, 0x0d,
...@@ -1819,39 +1819,39 @@ var fileDescriptor_b88fd140af4deb6f = []byte{ ...@@ -1819,39 +1819,39 @@ var fileDescriptor_b88fd140af4deb6f = []byte{
0x36, 0xf6, 0xc2, 0xbf, 0xd9, 0x2f, 0x7c, 0xcd, 0xfc, 0xf7, 0xa8, 0x66, 0x6a, 0x08, 0x79, 0x3a, 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, 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, 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, 0x7c, 0x2f, 0xa0, 0x35, 0x5e, 0x4d, 0x95, 0x23, 0x3d, 0x83, 0x9c, 0x1a, 0xed, 0xae, 0x08, 0x30,
0x80, 0xf1, 0x11, 0xdb, 0xb3, 0xb8, 0x18, 0xae, 0xe7, 0x63,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xf8, 0x77, 0xc8, 0xf7, 0x95, 0xff, 0xaf, 0xe8, 0x07, 0xc2, 0x22, 0x7a, 0xee, 0x2e, 0x0e, 0xf1, 0xef, 0x90, 0xef, 0x2b, 0xff, 0x5f, 0xd1, 0x0f, 0x84, 0xbf,
0xdf, 0x5d, 0xd9, 0xa9, 0x5e, 0x58, 0xdf, 0xd3, 0xfc, 0xd8, 0xf4, 0x89, 0xf4, 0xe5, 0xa3, 0x5f, 0xbb, 0xb2, 0x53, 0xbd, 0xb0, 0xbe, 0xa7, 0xf9, 0xb1, 0xe9, 0x13, 0xe9, 0xcb, 0x47, 0xbf, 0x3c,
0x1e, 0x4c, 0x94, 0x9d, 0x2e, 0xc6, 0x27, 0x89, 0x9e, 0x3f, 0x1b, 0x0c, 0x92, 0xfc, 0x19, 0x0d, 0x98, 0x28, 0x3b, 0x5d, 0x8c, 0x4f, 0x12, 0x3d, 0x7f, 0x36, 0x18, 0x24, 0xf9, 0x33, 0x1a, 0xf2,
0xf9, 0x83, 0xc1, 0x33, 0x9a, 0x45, 0xc6, 0xdb, 0x34, 0xce, 0x0f, 0xfe, 0x09, 0x00, 0x00, 0xff, 0x07, 0x83, 0x67, 0x34, 0x8b, 0x8c, 0xb7, 0x69, 0x9c, 0x1f, 0xfc, 0x13, 0x00, 0x00, 0xff, 0xff,
0xff, 0xab, 0x59, 0x52, 0xd8, 0x29, 0x0c, 0x00, 0x00, 0xb9, 0xa3, 0x5d, 0xe0, 0x29, 0x0c, 0x00, 0x00,
} }
...@@ -17,9 +17,9 @@ import ( ...@@ -17,9 +17,9 @@ import (
) )
var ( var (
listenAddr = "localhost:8805" listenAddr = ":8805" //as server, should keep default 0.0.0.0
unSyncMaxTimes uint32 = 6 //max 6 times unSyncMaxTimes uint32 = 6 //max 6 times
checkInterval uint32 = 5 // 5s checkInterval uint32 = 5 // 5s
) )
// HealthCheckServer a node's health check server // HealthCheckServer a node's health check server
......
...@@ -552,7 +552,7 @@ func (wallet *Wallet) ProcSendToAddress(SendToAddress *types.ReqWalletSendToAddr ...@@ -552,7 +552,7 @@ func (wallet *Wallet) ProcSendToAddress(SendToAddress *types.ReqWalletSendToAddr
if err != nil { if err != nil {
return nil, err 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 处理设置手续费 // ProcWalletSetFee 处理设置手续费
......
...@@ -464,7 +464,7 @@ func testProcSendToAddress(t *testing.T, wallet *Wallet) { ...@@ -464,7 +464,7 @@ func testProcSendToAddress(t *testing.T, wallet *Wallet) {
transfer := &types.ReqWalletSendToAddress{ transfer := &types.ReqWalletSendToAddress{
Amount: 1000, Amount: 1000,
From: FromAddr, From: FromAddr,
Note: []byte("test"), Note: "test",
To: "1L1zEgVcjqdM2KkQixENd7SZTaudKkcyDu", To: "1L1zEgVcjqdM2KkQixENd7SZTaudKkcyDu",
} }
msg := wallet.client.NewMessage("wallet", types.EventWalletSendToAddress, transfer) msg := wallet.client.NewMessage("wallet", types.EventWalletSendToAddress, transfer)
...@@ -476,7 +476,7 @@ func testProcSendToAddress(t *testing.T, wallet *Wallet) { ...@@ -476,7 +476,7 @@ func testProcSendToAddress(t *testing.T, wallet *Wallet) {
withdraw := &types.ReqWalletSendToAddress{ withdraw := &types.ReqWalletSendToAddress{
Amount: -1000, Amount: -1000,
From: FromAddr, From: FromAddr,
Note: []byte("test"), Note: "test",
To: "16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp", To: "16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp",
} }
msg = wallet.client.NewMessage("wallet", types.EventWalletSendToAddress, withdraw) msg = wallet.client.NewMessage("wallet", types.EventWalletSendToAddress, withdraw)
...@@ -597,7 +597,7 @@ func testProcWalletLock(t *testing.T, wallet *Wallet) { ...@@ -597,7 +597,7 @@ func testProcWalletLock(t *testing.T, wallet *Wallet) {
transfer := &types.ReqWalletSendToAddress{ transfer := &types.ReqWalletSendToAddress{
Amount: 1000, Amount: 1000,
From: FromAddr, From: FromAddr,
Note: []byte("test"), Note: "test",
To: "1L1zEgVcjqdM2KkQixENd7SZTaudKkcyDu", To: "1L1zEgVcjqdM2KkQixENd7SZTaudKkcyDu",
} }
msg = wallet.client.NewMessage("wallet", types.EventWalletSendToAddress, transfer) 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