Commit b2638e9d authored by kingwang's avatar kingwang

fix bug amount

parent 78fbea97
......@@ -19,7 +19,7 @@ func (chain *BlockChain) ProcRecvMsg() {
defer chain.recvwg.Done()
reqnum := make(chan struct{}, 1000)
for msg := range chain.client.Recv() {
chainlog.Debug("blockchain recv", "msg", types.GetEventName(int(msg.Ty)), "id", msg.Id, "cap", len(reqnum))
chainlog.Debug("blockchain recv", "msg", types.GetEventName(int(msg.Ty)), "id", msg.ID, "cap", len(reqnum))
msgtype := msg.Ty
reqnum <- struct{}{}
atomic.AddInt32(&chain.runcount, 1)
......
......@@ -9,7 +9,7 @@ package strategy
//const
const (
// 創建main.go的文件模板
CPFT_MAIN_GO = `package main
CpftMainGo = `package main
import (
_ "github.com/33cn/chain33/system"
......@@ -26,7 +26,7 @@ func main() {
`
// 生成的配置文件模板 xxx.toml
CPFT_CFG_TOML = `
CpftCfgToml = `
Title="${PROJECTNAME}"
FixTime=false
......@@ -102,14 +102,14 @@ enableMVCC=false
saveTokenTxList=false
`
CPFT_RUNMAIN_BLOCK = `package main
CpftRunmainBlock = `package main
var ${PROJECTNAME} = `
// 生成项目运行主程序的模板 xxx.go
// 顶部还需要加上package main
//var bityuan = `CPFT_RUNMAIN`
CPFT_RUNMAIN = `TestNet=false
CpftRunMain = `TestNet=false
[blockchain]
defCacheSize=128
maxFetchBlockNum=128
......@@ -248,7 +248,7 @@ ForkTradeAsset= -1
`
// 生成项目Makefile文件的模板 Makefile
CPFT_MAKEFILE = `
CpftMakefile = `
CHAIN33=github.com/33cn/chain33
CHAIN33_PATH=vendor/${CHAIN33}
all: vendor proto build
......@@ -297,7 +297,7 @@ clean:
`
// 生成 .travis.yml 文件模板
CPFT_TRAVIS_YML = `
CpftTravisYml = `
language: go
go:
......@@ -306,7 +306,7 @@ go:
`
// 生成 plugin/plugin.toml的文件模板
CPFT_PLUGIN_TOML = `
CpftPluginToml = `
# type字段仅支持 consensus dapp store
[dapp-ticket]
gitrepo = "github.com/33cn/plugin/plugin/dapp/ticket"
......@@ -327,7 +327,7 @@ gitrepo = "github.com/33cn/plugin/plugin/dapp/token"
gitrepo = "github.com/33cn/plugin/plugin/dapp/trade"
`
// 项目 cli/main.go 文件模板
CPFT_CLI_MAIN = `package main
CpftCliMain = `package main
import (
_ "${PROJECTPATH}/plugin"
......@@ -340,7 +340,7 @@ func main() {
}
`
// plugin/dapp/xxxx/commands/cmd.go文件的模板c
CPFT_DAPP_COMMANDS = `package commands
CpftDappCommands = `package commands
import (
"github.com/spf13/cobra"
......@@ -351,7 +351,7 @@ func Cmd() *cobra.Command {
}`
// plugin/dapp/xxxx/plugin.go文件的模板
CPFT_DAPP_PLUGIN = `package ${PROJECTNAME}
CpftDappPlugin = `package ${PROJECTNAME}
import (
"github.com/33cn/chain33/pluginmgr"
......@@ -372,7 +372,7 @@ func init() {
`
// plugin/dapp/xxxx/executor/xxxx.go文件模板
CPFT_DAPP_EXEC = `package executor
CpftDappExec = `package executor
import (
log "github.com/inconshreveable/log15"
......@@ -425,17 +425,17 @@ func (this *${CLASSNAME}) CheckTx(tx *types.Transaction, index int) error {
}
`
// plugin/dapp/xxxx/proto/create_protobuf.sh文件模板
CPFT_DAPP_CREATEPB = `#!/bin/sh
CpftDappCreatepb = `#!/bin/sh
protoc --go_out=plugins=grpc:../types ./*.proto --proto_path=.
`
// plugin/dapp/xxxx/proto/Makefile 文件模板
CPFT_DAPP_MAKEFILE = `all:
CpftDappMakefile = `all:
sh ./create_protobuf.sh
`
// plugin/dapp/xxxx/proto/xxxx.proto的文件模板
CPFT_DAPP_PROTO = `syntax = "proto3";
CpftDappProto = `syntax = "proto3";
package types;
message ${ACTIONNAME} {
......@@ -450,7 +450,7 @@ message ${ACTIONNAME}None {
`
// plugin/dapp/xxxx/types/types.go的文件模板cd
CPFT_DAPP_TYPEFILE = `package types
CpftDappTypefile = `package types
import (
"gitlab.33.cn/chain33/chain33/types"
......
......@@ -78,7 +78,7 @@ func (c *createPluginStrategy) buildTask() []tasks.Task {
taskSlice := make([]tasks.Task, 0)
taskSlice = append(taskSlice,
&tasks.CreateFileFromStrTemplateTask{
SourceStr: CPFT_MAIN_GO,
SourceStr: CpftMainGo,
OutputFile: fmt.Sprintf("%s/main.go", c.projectPath),
ReplaceKeyPairs: map[string]string{
types.TagProjectName: c.projName,
......@@ -86,15 +86,15 @@ func (c *createPluginStrategy) buildTask() []tasks.Task {
},
},
&tasks.CreateFileFromStrTemplateTask{
SourceStr: CPFT_CFG_TOML,
SourceStr: CpftCfgToml,
OutputFile: fmt.Sprintf("%s/%s.toml", c.projectPath, c.projName),
ReplaceKeyPairs: map[string]string{
types.TagProjectName: c.projName,
},
},
&tasks.CreateFileFromStrTemplateTask{
SourceStr: CPFT_RUNMAIN,
BlockStrBegin: CPFT_RUNMAIN_BLOCK + "`",
SourceStr: CpftRunMain,
BlockStrBegin: CpftRunmainBlock + "`",
BlockStrEnd: "`",
OutputFile: fmt.Sprintf("%s/%s.go", c.projectPath, c.projName),
ReplaceKeyPairs: map[string]string{
......@@ -102,7 +102,7 @@ func (c *createPluginStrategy) buildTask() []tasks.Task {
},
},
&tasks.CreateFileFromStrTemplateTask{
SourceStr: CPFT_MAKEFILE,
SourceStr: CpftMakefile,
OutputFile: fmt.Sprintf("%s/Makefile", c.projectPath),
ReplaceKeyPairs: map[string]string{
types.TagProjectName: c.projName,
......@@ -112,21 +112,21 @@ func (c *createPluginStrategy) buildTask() []tasks.Task {
},
},
&tasks.CreateFileFromStrTemplateTask{
SourceStr: CPFT_TRAVIS_YML,
SourceStr: CpftTravisYml,
OutputFile: fmt.Sprintf("%s/.travis.yml", c.projectPath),
ReplaceKeyPairs: map[string]string{
types.TagProjectName: c.projName,
},
},
&tasks.CreateFileFromStrTemplateTask{
SourceStr: CPFT_PLUGIN_TOML,
SourceStr: CpftPluginToml,
OutputFile: fmt.Sprintf("%s/plugin/plugin.toml", c.projectPath),
ReplaceKeyPairs: map[string]string{
types.TagProjectName: c.projName,
},
},
&tasks.CreateFileFromStrTemplateTask{
SourceStr: CPFT_CLI_MAIN,
SourceStr: CpftCliMain,
OutputFile: fmt.Sprintf("%s/cli/main.go", c.projectPath),
ReplaceKeyPairs: map[string]string{
types.TagProjectName: c.projName,
......@@ -134,14 +134,14 @@ func (c *createPluginStrategy) buildTask() []tasks.Task {
},
},
&tasks.CreateFileFromStrTemplateTask{
SourceStr: CPFT_DAPP_COMMANDS,
SourceStr: CpftDappCommands,
OutputFile: fmt.Sprintf("%s/plugin/dapp/%s/commands/cmd.go", c.projectPath, c.execName),
ReplaceKeyPairs: map[string]string{
types.TagProjectName: c.projName,
},
},
&tasks.CreateFileFromStrTemplateTask{
SourceStr: CPFT_DAPP_PLUGIN,
SourceStr: CpftDappPlugin,
OutputFile: fmt.Sprintf("%s/plugin/dapp/%s/plugin.go", c.projectPath, c.projName),
ReplaceKeyPairs: map[string]string{
types.TagProjectName: c.projName,
......@@ -150,7 +150,7 @@ func (c *createPluginStrategy) buildTask() []tasks.Task {
},
},
&tasks.CreateFileFromStrTemplateTask{
SourceStr: CPFT_DAPP_EXEC,
SourceStr: CpftDappExec,
OutputFile: fmt.Sprintf("%s/plugin/dapp/%s/executor/%s.go", c.projectPath, c.projName, c.execName),
ReplaceKeyPairs: map[string]string{
types.TagProjectName: c.projName,
......@@ -159,24 +159,24 @@ func (c *createPluginStrategy) buildTask() []tasks.Task {
},
},
&tasks.CreateFileFromStrTemplateTask{
SourceStr: CPFT_DAPP_CREATEPB,
SourceStr: CpftDappCreatepb,
OutputFile: fmt.Sprintf("%s/plugin/dapp/%s/proto/create_protobuf.sh", c.projectPath, c.projName),
ReplaceKeyPairs: map[string]string{},
},
&tasks.CreateFileFromStrTemplateTask{
SourceStr: CPFT_DAPP_MAKEFILE,
SourceStr: CpftDappMakefile,
OutputFile: fmt.Sprintf("%s/plugin/dapp/%s/proto/Makefile", c.projectPath, c.projName),
ReplaceKeyPairs: map[string]string{},
},
&tasks.CreateFileFromStrTemplateTask{
SourceStr: CPFT_DAPP_PROTO,
SourceStr: CpftDappProto,
OutputFile: fmt.Sprintf("%s/plugin/dapp/%s/proto/%s.proto", c.projectPath, c.projName, c.execName),
ReplaceKeyPairs: map[string]string{
types.TagActionName: c.classActionName,
},
},
&tasks.CreateFileFromStrTemplateTask{
SourceStr: CPFT_DAPP_TYPEFILE,
SourceStr: CpftDappTypefile,
OutputFile: fmt.Sprintf("%s/plugin/dapp/%s/types/types.go", c.projectPath, c.projName),
ReplaceKeyPairs: map[string]string{
types.TagExecNameFB: c.execNameFB,
......
......@@ -21,7 +21,7 @@ const (
KeyUpdateInit = "update_init"
KeyCreatePlugin = "create_plugin"
DEF_CPM_CONFIGFILE = "chain33.cpm.toml"
DefCpmConfigfile = "chain33.cpm.toml"
TagGoPath = "${GOPATH}"
TagProjectName = "${PROJECTNAME}" // 项目名称替换标签
......
......@@ -11,11 +11,12 @@ chain33 是由复杂美科技有限公司开发的区块链链框架
3. 创新的 合约 调用和组合方式
*/
package chain33
//有些包国内需要翻墙才能下载,我们把部分参见的包含在这里
import (
_ "golang.org/x/crypto/nacl/box"
_ "golang.org/x/crypto/nacl/box" //register box package
_ "golang.org/x/crypto/nacl/secretbox"
_ "golang.org/x/crypto/ssh"
)
......@@ -16,6 +16,7 @@ function filterLinter() {
--enable=structcheck \
--enable=goimports \
--enable=misspell \
--enable=golint \
--vendor ./...)
# --enable=staticcheck \
# --enable=gocyclo \
......
......@@ -600,7 +600,7 @@ func (mem *Mempool) SetQueueClient(client queue.Client) {
defer mlog.Info("mempool message recv quit")
defer mem.wg.Done()
for msg := range mem.client.Recv() {
mlog.Debug("mempool recv", "msgid", msg.Id, "msg", types.GetEventName(int(msg.Ty)))
mlog.Debug("mempool recv", "msgid", msg.ID, "msg", types.GetEventName(int(msg.Ty)))
beg := types.Now()
switch msg.Ty {
case types.EventTx:
......
......@@ -16,31 +16,31 @@ import (
func TestStep(t *testing.T) {
done := make(chan struct{})
in := make(chan queue.Message)
msg := queue.Message{Id: 0}
msg := queue.Message{ID: 0}
cb := func(in queue.Message) queue.Message {
in.Id++
in.ID++
time.Sleep(time.Microsecond)
return in
}
out := step(done, in, cb)
in <- msg
msg2 := <-out
assert.Equal(t, msg2.Id, int64(1))
assert.Equal(t, msg2.ID, int64(1))
close(done)
}
func TestMutiStep(t *testing.T) {
done := make(chan struct{})
in := make(chan queue.Message)
msg := queue.Message{Id: 0}
msg := queue.Message{ID: 0}
step1 := func(in queue.Message) queue.Message {
in.Id++
in.ID++
time.Sleep(time.Microsecond)
return in
}
out1 := step(done, in, step1)
step2 := func(in queue.Message) queue.Message {
in.Id++
in.ID++
time.Sleep(time.Microsecond)
return in
}
......@@ -50,16 +50,16 @@ func TestMutiStep(t *testing.T) {
out3 := mergeList(done, out21, out22)
in <- msg
msg2 := <-out3
assert.Equal(t, msg2.Id, int64(2))
assert.Equal(t, msg2.ID, int64(2))
close(done)
}
func BenchmarkStep(b *testing.B) {
done := make(chan struct{})
in := make(chan queue.Message)
msg := queue.Message{Id: 0}
msg := queue.Message{ID: 0}
cb := func(in queue.Message) queue.Message {
in.Id++
in.ID++
time.Sleep(100 * time.Microsecond)
return in
}
......@@ -71,7 +71,7 @@ func BenchmarkStep(b *testing.B) {
}()
for i := 0; i < b.N; i++ {
msg2 := <-out
assert.Equal(b, msg2.Id, int64(1))
assert.Equal(b, msg2.ID, int64(1))
}
close(done)
}
......@@ -79,9 +79,9 @@ func BenchmarkStep(b *testing.B) {
func BenchmarkStepMerge(b *testing.B) {
done := make(chan struct{})
in := make(chan queue.Message)
msg := queue.Message{Id: 0}
msg := queue.Message{ID: 0}
cb := func(in queue.Message) queue.Message {
in.Id++
in.ID++
time.Sleep(100 * time.Microsecond)
return in
}
......@@ -97,7 +97,7 @@ func BenchmarkStepMerge(b *testing.B) {
}()
for i := 0; i < b.N; i++ {
msg2 := <-out
assert.Equal(b, msg2.Id, int64(1))
assert.Equal(b, msg2.ID, int64(1))
}
close(done)
}
......@@ -39,7 +39,7 @@ func (l *listener) Close() {
type listener struct {
server *grpc.Server
nodeInfo *NodeInfo
p2pserver *P2pServer
p2pserver *P2pserver
node *Node
netlistener net.Listener
}
......
......@@ -219,32 +219,33 @@ func (na *NetAddress) ReachabilityTo(o *NetAddress) int {
return Teredo
} else if o.IP.To4() != nil {
return Ipv4
} else { // ipv6
return Ipv6Weak
}
// ipv6
return Ipv6Weak
} else if na.IP.To4() != nil {
if o.Routable() && o.IP.To4() != nil {
return Ipv4
}
return Default
} else /* ipv6 */ {
var tunnelled bool
// Is our v6 is tunnelled?
if o.RFC3964() || o.RFC6052() || o.RFC6145() {
tunnelled = true
}
if !o.Routable() {
return Default
} else if o.RFC4380() {
return Teredo
} else if o.IP.To4() != nil {
return Ipv4
} else if tunnelled {
// only prioritise ipv6 if we aren't tunnelling it.
return Ipv6Weak
}
return Ipv6Strong
}
/* ipv6 */
var tunnelled bool
// Is our v6 is tunnelled?
if o.RFC3964() || o.RFC6052() || o.RFC6145() {
tunnelled = true
}
if !o.Routable() {
return Default
} else if o.RFC4380() {
return Teredo
} else if o.IP.To4() != nil {
return Ipv4
} else if tunnelled {
// only prioritise ipv6 if we aren't tunnelling it.
return Ipv6Weak
}
return Ipv6Strong
}
// RFC1918: IPv4 Private networks (10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12)
......
......@@ -188,7 +188,7 @@ func (client *client) isEnd(data Message, ok bool) bool {
if atomic.LoadInt32(&client.isClosed) == 1 {
return true
}
if data.Data == nil && data.Id == 0 && data.Ty == 0 {
if data.Data == nil && data.ID == 0 && data.Ty == 0 {
return true
}
return false
......
......@@ -229,14 +229,14 @@ func (q *queue) Client() Client {
type Message struct {
Topic string
Ty int64
Id int64
ID int64
Data interface{}
chReply chan Message
}
// NewMessage new message
func NewMessage(id int64, topic string, ty int64, data interface{}) (msg Message) {
msg.Id = id
msg.ID = id
msg.Ty = ty
msg.Data = data
msg.Topic = topic
......@@ -275,7 +275,7 @@ func (msg Message) Reply(replyMsg Message) {
// String print the message information
func (msg Message) String() string {
return fmt.Sprintf("{topic:%s, Ty:%s, Id:%d, Err:%v, Ch:%v}", msg.Topic,
types.GetEventName(int(msg.Ty)), msg.Id, msg.Err(), msg.chReply != nil)
types.GetEventName(int(msg.Ty)), msg.ID, msg.Err(), msg.chReply != nil)
}
// ReplyErr reply error
......
......@@ -20,8 +20,8 @@ import (
//const
const (
SM2_RPIVATEKEY_LENGTH = 32
SM2_PUBLICKEY_LENGTH = 65
SM2PrivateKeyLength = 32
SM2PublicKeyLength = 65
)
//Driver 驱动
......@@ -29,8 +29,8 @@ type Driver struct{}
//GenKey 生成私钥
func (d Driver) GenKey() (crypto.PrivKey, error) {
privKeyBytes := [SM2_RPIVATEKEY_LENGTH]byte{}
copy(privKeyBytes[:], crypto.CRandBytes(SM2_RPIVATEKEY_LENGTH))
privKeyBytes := [SM2PrivateKeyLength]byte{}
copy(privKeyBytes[:], crypto.CRandBytes(SM2PrivateKeyLength))
priv, _ := privKeyFromBytes(sm2.P256Sm2(), privKeyBytes[:])
copy(privKeyBytes[:], SerializePrivateKey(priv))
return PrivKeySM2(privKeyBytes), nil
......@@ -38,11 +38,11 @@ func (d Driver) GenKey() (crypto.PrivKey, error) {
//PrivKeyFromBytes 字节转为私钥
func (d Driver) PrivKeyFromBytes(b []byte) (privKey crypto.PrivKey, err error) {
if len(b) != SM2_RPIVATEKEY_LENGTH {
if len(b) != SM2PrivateKeyLength {
return nil, errors.New("invalid priv key byte")
}
privKeyBytes := new([SM2_RPIVATEKEY_LENGTH]byte)
copy(privKeyBytes[:], b[:SM2_RPIVATEKEY_LENGTH])
privKeyBytes := new([SM2PrivateKeyLength]byte)
copy(privKeyBytes[:], b[:SM2PrivateKeyLength])
priv, _ := privKeyFromBytes(sm2.P256Sm2(), privKeyBytes[:])
......@@ -52,10 +52,10 @@ func (d Driver) PrivKeyFromBytes(b []byte) (privKey crypto.PrivKey, err error) {
//PubKeyFromBytes 字节转为公钥
func (d Driver) PubKeyFromBytes(b []byte) (pubKey crypto.PubKey, err error) {
if len(b) != SM2_PUBLICKEY_LENGTH {
if len(b) != SM2PublicKeyLength {
return nil, errors.New("invalid pub key byte")
}
pubKeyBytes := new([SM2_PUBLICKEY_LENGTH]byte)
pubKeyBytes := new([SM2PublicKeyLength]byte)
copy(pubKeyBytes[:], b[:])
return PubKeySM2(*pubKeyBytes), nil
}
......@@ -76,11 +76,11 @@ func (d Driver) SignatureFromBytes(b []byte) (sig crypto.Signature, err error) {
}
//PrivKeySM2 私钥
type PrivKeySM2 [SM2_RPIVATEKEY_LENGTH]byte
type PrivKeySM2 [SM2PrivateKeyLength]byte
//Bytes 字节格式
func (privKey PrivKeySM2) Bytes() []byte {
s := make([]byte, SM2_RPIVATEKEY_LENGTH)
s := make([]byte, SM2PrivateKeyLength)
copy(s, privKey[:])
return s
}
......@@ -120,11 +120,11 @@ func (privKey PrivKeySM2) String() string {
}
//PubKeySM2 公钥
type PubKeySM2 [SM2_PUBLICKEY_LENGTH]byte
type PubKeySM2 [SM2PublicKeyLength]byte
//Bytes 字节格式
func (pubKey PubKeySM2) Bytes() []byte {
s := make([]byte, SM2_PUBLICKEY_LENGTH)
s := make([]byte, SM2PublicKeyLength)
copy(s, pubKey[:])
return s
}
......
......@@ -103,7 +103,7 @@ func parsePubKey(pubKeyStr []byte, curve elliptic.Curve) (key *sm2.PublicKey, er
//SerializePublicKey 公钥序列化
func SerializePublicKey(p *sm2.PublicKey) []byte {
b := make([]byte, 0, SM2_PUBLICKEY_LENGTH)
b := make([]byte, 0, SM2PublicKeyLength)
b = append(b, 0x4)
b = paddedAppend(32, b, p.X.Bytes())
return paddedAppend(32, b, p.Y.Bytes())
......@@ -111,8 +111,8 @@ func SerializePublicKey(p *sm2.PublicKey) []byte {
//SerializePrivateKey 私钥序列化
func SerializePrivateKey(p *sm2.PrivateKey) []byte {
b := make([]byte, 0, SM2_RPIVATEKEY_LENGTH)
return paddedAppend(SM2_RPIVATEKEY_LENGTH, b, p.D.Bytes())
b := make([]byte, 0, SM2PrivateKeyLength)
return paddedAppend(SM2PrivateKeyLength, b, p.D.Bytes())
}
func paddedAppend(size uint, dst, src []byte) []byte {
......
......@@ -6,7 +6,7 @@
package system
import (
_ "github.com/33cn/chain33/system/consensus/init"
_ "github.com/33cn/chain33/system/consensus/init" //register consensus init package
_ "github.com/33cn/chain33/system/crypto/init"
_ "github.com/33cn/chain33/system/dapp/init"
_ "github.com/33cn/chain33/system/store/init"
......
......@@ -172,23 +172,27 @@ func (store *BaseStore) GetQueueClient() queue.Client {
return store.qclient
}
func NewStoreListQuery(store SubStore, req *types.StoreList) *StoreListQuery {
// NewStoreListQuery new store list query object
func NewStoreListQuery(store SubStore, req *types.StoreList) *StorelistQuery {
reply := &types.StoreListReply{Start: req.Start, End: req.End, Suffix: req.Suffix, Count: req.Count, Mode: req.Mode}
return &StoreListQuery{StoreListReply: reply, req: req, store: store}
return &StorelistQuery{StoreListReply: reply, req: req, store: store}
}
type StoreListQuery struct {
// StorelistQuery defines a type store list query
type StorelistQuery struct {
store SubStore
req *types.StoreList
*types.StoreListReply
}
func (t *StoreListQuery) Run() *types.StoreListReply {
// Run store list query
func (t *StorelistQuery) Run() *types.StoreListReply {
t.store.IterateRangeByStateHash(t.req.StateHash, t.req.Start, t.req.End, true, t.IterateCallBack)
return t.StoreListReply
}
func (t *StoreListQuery) IterateCallBack(key, value []byte) bool {
// IterateCallBack store list query iterate callback
func (t *StorelistQuery) IterateCallBack(key, value []byte) bool {
if t.Mode == 1 { //[start, end)模式
if t.Num >= t.Count {
t.NextKey = key
......@@ -198,7 +202,8 @@ func (t *StoreListQuery) IterateCallBack(key, value []byte) bool {
t.Keys = append(t.Keys, cloneByte(key))
t.Values = append(t.Values, cloneByte(value))
return false
} else if t.Mode == 2 { //prefix + suffix模式,要对按prefix得到的数据key进行suffix的判断,符合条件的数据才是最终要的数据
}
if t.Mode == 2 { //prefix + suffix模式,要对按prefix得到的数据key进行suffix的判断,符合条件的数据才是最终要的数据
if len(key) > len(t.Suffix) {
if string(key[len(key)-len(t.Suffix):]) == string(t.Suffix) {
t.Num++
......@@ -209,16 +214,16 @@ func (t *StoreListQuery) IterateCallBack(key, value []byte) bool {
return true
}
return false
} else {
return false
}
} else {
return false
}
} else {
slog.Error("StoreListReply.IterateCallBack unsupported mode", "mode", t.Mode)
return true
return false
}
slog.Error("StoreListReply.IterateCallBack unsupported mode", "mode", t.Mode)
return true
}
func cloneByte(v []byte) []byte {
......
......@@ -658,6 +658,7 @@ func deleteOldNode(db dbm.DB, mp map[string][]hashData, curHeight int64, lastKey
pruningHashNode(db, delMp)
}
// PruningTreePrintDB pruning tree print db
func PruningTreePrintDB(db dbm.DB, prefix []byte) {
it := db.Iterator(prefix, nil, true)
defer it.Close()
......
......@@ -214,7 +214,7 @@ func genPrefixEdge(prefix []byte) (r []byte) {
i := len(prefix) - 1
for i >= 0 {
if r[i] < 0xff {
r[i] += 1
r[i]++
break
} else {
i--
......@@ -294,7 +294,7 @@ func TestIterateCallBack_Mode1(t *testing.T) {
resp1.Count = 5
resp1.Mode = 1
query = &drivers.StoreListQuery{StoreListReply: resp1}
query = &drivers.StorelistQuery{StoreListReply: resp1}
store.IterateRangeByStateHash(hash1, resp1.Start, resp1.End, true, query.IterateCallBack)
tool.AddItem(resp1.Values)
......@@ -314,7 +314,7 @@ func TestIterateCallBack_Mode1(t *testing.T) {
resp0.End = genPrefixEdge([]byte(prefix))
resp0.Count = 5
resp0.Mode = 1
query = &drivers.StoreListQuery{StoreListReply: resp0}
query = &drivers.StorelistQuery{StoreListReply: resp0}
store.IterateRangeByStateHash(hash0, resp0.Start, resp0.End, true, query.IterateCallBack)
tool.AddItem(resp0.Values)
......@@ -334,7 +334,7 @@ func TestIterateCallBack_Mode1(t *testing.T) {
resp.End = genPrefixEdge([]byte(prefix))
resp.Count = 1
resp.Mode = 1
query = &drivers.StoreListQuery{StoreListReply: resp}
query = &drivers.StorelistQuery{StoreListReply: resp}
store.IterateRangeByStateHash(hash2, resp.Start, resp.End, true, query.IterateCallBack)
tool.AddItem(resp.Values)
......@@ -354,7 +354,7 @@ func TestIterateCallBack_Mode1(t *testing.T) {
resp.End = genPrefixEdge([]byte(prefix))
resp.Count = 2
resp.Mode = 1
query = &drivers.StoreListQuery{StoreListReply: resp}
query = &drivers.StorelistQuery{StoreListReply: resp}
store.IterateRangeByStateHash(hash2, resp.Start, resp.End, true, query.IterateCallBack)
tool.AddItem(resp.Values)
......@@ -422,7 +422,7 @@ func TestIterateCallBack_Mode2(t *testing.T) {
resp2.Count = 5
resp2.Mode = 2
query := &drivers.StoreListQuery{StoreListReply: resp2}
query := &drivers.StorelistQuery{StoreListReply: resp2}
store.IterateRangeByStateHash(hash2, resp2.Start, nil, true, query.IterateCallBack)
tool := &StatTool{}
tool.AddItem(resp2.Values)
......@@ -442,7 +442,7 @@ func TestIterateCallBack_Mode2(t *testing.T) {
resp1.End = genPrefixEdge([]byte(prefix))
resp1.Count = 5
resp1.Mode = 2
query = &drivers.StoreListQuery{StoreListReply: resp1}
query = &drivers.StorelistQuery{StoreListReply: resp1}
store.IterateRangeByStateHash(hash1, resp1.Start, resp1.End, true, query.IterateCallBack)
tool.AddItem(resp1.Values)
......@@ -462,7 +462,7 @@ func TestIterateCallBack_Mode2(t *testing.T) {
resp0.End = genPrefixEdge([]byte(prefix))
resp0.Count = 5
resp0.Mode = 2
query = &drivers.StoreListQuery{StoreListReply: resp0}
query = &drivers.StorelistQuery{StoreListReply: resp0}
store.IterateRangeByStateHash(hash0, resp0.Start, nil, true, query.IterateCallBack)
tool.AddItem(resp0.Values)
......@@ -482,7 +482,7 @@ func TestIterateCallBack_Mode2(t *testing.T) {
resp.End = genPrefixEdge([]byte(prefix))
resp.Count = 1
resp.Mode = 2
query = &drivers.StoreListQuery{StoreListReply: resp}
query = &drivers.StorelistQuery{StoreListReply: resp}
store.IterateRangeByStateHash(hash2, resp.Start, nil, true, query.IterateCallBack)
tool.AddItem(resp.Values)
......@@ -502,7 +502,7 @@ func TestIterateCallBack_Mode2(t *testing.T) {
resp.End = genPrefixEdge([]byte(prefix))
resp.Count = 2
resp.Mode = 2
query = &drivers.StoreListQuery{StoreListReply: resp}
query = &drivers.StorelistQuery{StoreListReply: resp}
store.IterateRangeByStateHash(hash2, resp.Start, nil, true, query.IterateCallBack)
tool.AddItem(resp.Values)
......@@ -522,7 +522,7 @@ func TestIterateCallBack_Mode2(t *testing.T) {
resp.End = genPrefixEdge([]byte("mavl-coins-bty-exec-26htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp:"))
resp.Count = 1
resp.Mode = 2
query = &drivers.StoreListQuery{StoreListReply: resp}
query = &drivers.StorelistQuery{StoreListReply: resp}
store.IterateRangeByStateHash(hash2, resp.Start, resp.End, true, query.IterateCallBack)
tool.AddItem(resp.Values)
assert.Equal(t, int64(1), resp.Num)
......
......@@ -33,7 +33,7 @@ var (
// coin conversation
const (
Coin int64 = 1e8
MaxCoin int64 = 9e18
MaxCoin int64 = 1e17
MaxTxSize = 100000 //100K
MaxTxGroupSize int32 = 20
MaxBlockSize = 20000000 //20M
......
......@@ -107,25 +107,25 @@ func defaultResolveAny(typeURL string) (proto.Message, error) {
return reflect.New(mt.Elem()).Interface().(proto.Message), nil
}
// JSONPBMarshaler is implemented by protobuf messages that customize the
// JSONPBmarshaler is implemented by protobuf messages that customize the
// way they are marshaled to JSON. Messages that implement this should
// also implement JSONPBUnmarshaler so that the custom format can be
// parsed.
//
// The JSON marshaling must follow the proto to JSON specification:
// https://developers.google.com/protocol-buffers/docs/proto3#json
type JSONPBMarshaler interface {
type JSONPBmarshaler interface {
MarshalJSONPB(*Marshaler) ([]byte, error)
}
// JSONPBUnmarshaler is implemented by protobuf messages that customize
// JSONPBunmarshaler is implemented by protobuf messages that customize
// the way they are unmarshaled from JSON. Messages that implement this
// should also implement JSONPBMarshaler so that the custom format can be
// produced.
//
// The JSON unmarshaling must follow the JSON to proto specification:
// https://developers.google.com/protocol-buffers/docs/proto3#json
type JSONPBUnmarshaler interface {
type JSONPBunmarshaler interface {
UnmarshalJSONPB(*Unmarshaler, []byte) error
}
......@@ -171,7 +171,7 @@ type wkt interface {
// marshalObject writes a struct to the Writer.
func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent, typeURL string) error {
if jsm, ok := v.(JSONPBMarshaler); ok {
if jsm, ok := v.(JSONPBmarshaler); ok {
b, err := jsm.MarshalJSONPB(m)
if err != nil {
return err
......@@ -727,7 +727,7 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe
if targetType.Kind() == reflect.Ptr {
// If input value is "null" and target is a pointer type, then the field should be treated as not set
// UNLESS the target is structpb.Value, in which case it should be set to structpb.NullValue.
_, isJSONPBUnmarshaler := target.Interface().(JSONPBUnmarshaler)
_, isJSONPBUnmarshaler := target.Interface().(JSONPBunmarshaler)
if string(inputValue) == "null" && targetType != reflect.TypeOf(&stpb.Value{}) && !isJSONPBUnmarshaler {
return nil
}
......@@ -736,7 +736,7 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe
return u.unmarshalValue(target.Elem(), inputValue, prop)
}
if jsu, ok := target.Addr().Interface().(JSONPBUnmarshaler); ok {
if jsu, ok := target.Addr().Interface().(JSONPBunmarshaler); ok {
return jsu.UnmarshalJSONPB(u, []byte(inputValue))
}
......
......@@ -9,6 +9,7 @@
//消息队列本身可插拔,可以支持各种队列
//同时共识模式也是可以插拔的。
//rpc 服务也是可以插拔的
package cli
import (
......
......@@ -3,6 +3,7 @@
// license that can be found in the LICENSE file.
// package testnode 提供一个通用的测试节点,用于单元测试和集成测试。
package testnode
import (
......
......@@ -12,7 +12,7 @@ import (
bip39 "github.com/33cn/chain33/wallet/bipwallet/go-bip39"
bip44 "github.com/33cn/chain33/wallet/bipwallet/go-bip44"
"github.com/33cn/chain33/wallet/bipwallet/transformer"
_ "github.com/33cn/chain33/wallet/bipwallet/transformer/btcbase"
_ "github.com/33cn/chain33/wallet/bipwallet/transformer/btcbase" //register btcbase package
)
// https://github.com/satoshilabs/slips/blob/master/slip-0044.md
......
......@@ -156,7 +156,9 @@ func GetPrivkeyBySeed(db dbm.DB, seed string) (string, error) {
}
index = backupindex + 1
}
if SignType != 1 && SignType != 2 {
return "", types.ErrNotSupport
}
//secp256k1
if SignType == 1 {
......@@ -204,10 +206,6 @@ func GetPrivkeyBySeed(db dbm.DB, seed string) (string, error) {
//seedlog.Error("GetPrivkeyBySeed", "index", index, "secretKey", secretKey, "publicKey", publicKey)
Hexsubprivkey = secretKey
} else if SignType == 3 { //sm2
return "", types.ErrNotSupport
} else {
return "", types.ErrNotSupport
}
// back up index in db
var pubkeyindex []byte
......
......@@ -14,7 +14,7 @@ import (
func (wallet *Wallet) ProcRecvMsg() {
defer wallet.wg.Done()
for msg := range wallet.client.Recv() {
walletlog.Debug("wallet recv", "msg", types.GetEventName(int(msg.Ty)), "Id", msg.Id)
walletlog.Debug("wallet recv", "msg", types.GetEventName(int(msg.Ty)), "Id", msg.ID)
beg := types.Now()
reply, err := wallet.ExecWallet(&msg)
if err != nil {
......@@ -23,7 +23,7 @@ func (wallet *Wallet) ProcRecvMsg() {
} else {
msg.Reply(wallet.api.NewMessage("", 0, reply))
}
walletlog.Debug("end process", "msg.id", msg.Id, "cost", types.Since(beg))
walletlog.Debug("end process", "msg.id", msg.ID, "cost", types.Since(beg))
}
}
......
......@@ -458,10 +458,10 @@ func (wallet *Wallet) ProcImportPrivKey(PrivKey *types.ReqWalletImportPrivkey) (
if Account.Privkey == Encrypteredstr {
walletlog.Error("ProcImportPrivKey Privkey is exist in wallet!")
return nil, types.ErrPrivkeyExist
} else {
walletlog.Error("ProcImportPrivKey!", "Account.Privkey", Account.Privkey, "input Privkey", PrivKey.Privkey)
return nil, types.ErrPrivkey
}
walletlog.Error("ProcImportPrivKey!", "Account.Privkey", Account.Privkey, "input Privkey", PrivKey.Privkey)
return nil, types.ErrPrivkey
}
var walletaccount types.WalletAccount
......
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