Commit 8222696c authored by vipwzw's avatar vipwzw Committed by 33cn

update new proto

parent c07239ab
...@@ -176,7 +176,7 @@ func (h *hasher) store(n node, db *Database, force bool) (node, error) { ...@@ -176,7 +176,7 @@ func (h *hasher) store(n node, db *Database, force bool) (node, error) {
//这个不用非常精确,只要保持确定性就可以了 //这个不用非常精确,只要保持确定性就可以了
size := n.size() size := n.size()
if size < 64 && !force { if size < 64 && !force {
return n, nil // Nodes smaller than 32 bytes are stored inside their parent return n, nil // Nodes smaller than 64 bytes are stored inside their parent
} }
nn := n.create() nn := n.create()
data, err := proto.Marshal(nn) data, err := proto.Marshal(nn)
......
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// source: node.proto // source: node.proto
/*
Package mpt is a generated protocol buffer package.
It is generated from these files:
node.proto
It has these top-level messages:
Node
FullNode
ShortNode
HashNode
ValueNode
*/
package mpt package mpt
import proto "github.com/golang/protobuf/proto" import proto "github.com/golang/protobuf/proto"
...@@ -39,35 +26,63 @@ type Node struct { ...@@ -39,35 +26,63 @@ type Node struct {
// *Node_Hash // *Node_Hash
// *Node_Val // *Node_Val
Value isNode_Value `protobuf_oneof:"value"` Value isNode_Value `protobuf_oneof:"value"`
Ty int32 `protobuf:"varint,1,opt,name=Ty" json:"Ty,omitempty"` Ty int32 `protobuf:"varint,1,opt,name=Ty,proto3" json:"Ty,omitempty"`
Index int32 `protobuf:"varint,6,opt,name=index" json:"index,omitempty"` Index int32 `protobuf:"varint,6,opt,name=index,proto3" json:"index,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *Node) Reset() { *m = Node{} } func (m *Node) Reset() { *m = Node{} }
func (m *Node) String() string { return proto.CompactTextString(m) } func (m *Node) String() string { return proto.CompactTextString(m) }
func (*Node) ProtoMessage() {} func (*Node) ProtoMessage() {}
func (*Node) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } func (*Node) Descriptor() ([]byte, []int) {
return fileDescriptor_node_001a9bd628f8d256, []int{0}
}
func (m *Node) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Node.Unmarshal(m, b)
}
func (m *Node) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Node.Marshal(b, m, deterministic)
}
func (dst *Node) XXX_Merge(src proto.Message) {
xxx_messageInfo_Node.Merge(dst, src)
}
func (m *Node) XXX_Size() int {
return xxx_messageInfo_Node.Size(m)
}
func (m *Node) XXX_DiscardUnknown() {
xxx_messageInfo_Node.DiscardUnknown(m)
}
var xxx_messageInfo_Node proto.InternalMessageInfo
type isNode_Value interface { type isNode_Value interface {
isNode_Value() isNode_Value()
} }
type Node_Full struct { type Node_Full struct {
Full *FullNode `protobuf:"bytes,2,opt,name=full,oneof"` Full *FullNode `protobuf:"bytes,2,opt,name=full,proto3,oneof"`
} }
type Node_Short struct { type Node_Short struct {
Short *ShortNode `protobuf:"bytes,3,opt,name=short,oneof"` Short *ShortNode `protobuf:"bytes,3,opt,name=short,proto3,oneof"`
} }
type Node_Hash struct { type Node_Hash struct {
Hash *HashNode `protobuf:"bytes,4,opt,name=hash,oneof"` Hash *HashNode `protobuf:"bytes,4,opt,name=hash,proto3,oneof"`
} }
type Node_Val struct { type Node_Val struct {
Val *ValueNode `protobuf:"bytes,5,opt,name=val,oneof"` Val *ValueNode `protobuf:"bytes,5,opt,name=val,proto3,oneof"`
} }
func (*Node_Full) isNode_Value() {} func (*Node_Full) isNode_Value() {}
func (*Node_Short) isNode_Value() {} func (*Node_Short) isNode_Value() {}
func (*Node_Hash) isNode_Value() {} func (*Node_Hash) isNode_Value() {}
func (*Node_Val) isNode_Value() {} func (*Node_Val) isNode_Value() {}
func (m *Node) GetValue() isNode_Value { func (m *Node) GetValue() isNode_Value {
...@@ -206,22 +221,22 @@ func _Node_OneofSizer(msg proto.Message) (n int) { ...@@ -206,22 +221,22 @@ func _Node_OneofSizer(msg proto.Message) (n int) {
switch x := m.Value.(type) { switch x := m.Value.(type) {
case *Node_Full: case *Node_Full:
s := proto.Size(x.Full) s := proto.Size(x.Full)
n += proto.SizeVarint(2<<3 | proto.WireBytes) n += 1 // tag and wire
n += proto.SizeVarint(uint64(s)) n += proto.SizeVarint(uint64(s))
n += s n += s
case *Node_Short: case *Node_Short:
s := proto.Size(x.Short) s := proto.Size(x.Short)
n += proto.SizeVarint(3<<3 | proto.WireBytes) n += 1 // tag and wire
n += proto.SizeVarint(uint64(s)) n += proto.SizeVarint(uint64(s))
n += s n += s
case *Node_Hash: case *Node_Hash:
s := proto.Size(x.Hash) s := proto.Size(x.Hash)
n += proto.SizeVarint(4<<3 | proto.WireBytes) n += 1 // tag and wire
n += proto.SizeVarint(uint64(s)) n += proto.SizeVarint(uint64(s))
n += s n += s
case *Node_Val: case *Node_Val:
s := proto.Size(x.Val) s := proto.Size(x.Val)
n += proto.SizeVarint(5<<3 | proto.WireBytes) n += 1 // tag and wire
n += proto.SizeVarint(uint64(s)) n += proto.SizeVarint(uint64(s))
n += s n += s
case nil: case nil:
...@@ -233,13 +248,35 @@ func _Node_OneofSizer(msg proto.Message) (n int) { ...@@ -233,13 +248,35 @@ func _Node_OneofSizer(msg proto.Message) (n int) {
// FullNode 分支节点 // FullNode 分支节点
type FullNode struct { type FullNode struct {
Nodes []*Node `protobuf:"bytes,1,rep,name=nodes" json:"nodes,omitempty"` Nodes []*Node `protobuf:"bytes,1,rep,name=nodes,proto3" json:"nodes,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *FullNode) Reset() { *m = FullNode{} } func (m *FullNode) Reset() { *m = FullNode{} }
func (m *FullNode) String() string { return proto.CompactTextString(m) } func (m *FullNode) String() string { return proto.CompactTextString(m) }
func (*FullNode) ProtoMessage() {} func (*FullNode) ProtoMessage() {}
func (*FullNode) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } func (*FullNode) Descriptor() ([]byte, []int) {
return fileDescriptor_node_001a9bd628f8d256, []int{1}
}
func (m *FullNode) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_FullNode.Unmarshal(m, b)
}
func (m *FullNode) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_FullNode.Marshal(b, m, deterministic)
}
func (dst *FullNode) XXX_Merge(src proto.Message) {
xxx_messageInfo_FullNode.Merge(dst, src)
}
func (m *FullNode) XXX_Size() int {
return xxx_messageInfo_FullNode.Size(m)
}
func (m *FullNode) XXX_DiscardUnknown() {
xxx_messageInfo_FullNode.DiscardUnknown(m)
}
var xxx_messageInfo_FullNode proto.InternalMessageInfo
func (m *FullNode) GetNodes() []*Node { func (m *FullNode) GetNodes() []*Node {
if m != nil { if m != nil {
...@@ -251,13 +288,35 @@ func (m *FullNode) GetNodes() []*Node { ...@@ -251,13 +288,35 @@ func (m *FullNode) GetNodes() []*Node {
// ShortNode 扩展/叶子节点 // ShortNode 扩展/叶子节点
type ShortNode struct { type ShortNode struct {
Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
Val *Node `protobuf:"bytes,2,opt,name=val" json:"val,omitempty"` Val *Node `protobuf:"bytes,2,opt,name=val,proto3" json:"val,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *ShortNode) Reset() { *m = ShortNode{} } func (m *ShortNode) Reset() { *m = ShortNode{} }
func (m *ShortNode) String() string { return proto.CompactTextString(m) } func (m *ShortNode) String() string { return proto.CompactTextString(m) }
func (*ShortNode) ProtoMessage() {} func (*ShortNode) ProtoMessage() {}
func (*ShortNode) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } func (*ShortNode) Descriptor() ([]byte, []int) {
return fileDescriptor_node_001a9bd628f8d256, []int{2}
}
func (m *ShortNode) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ShortNode.Unmarshal(m, b)
}
func (m *ShortNode) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ShortNode.Marshal(b, m, deterministic)
}
func (dst *ShortNode) XXX_Merge(src proto.Message) {
xxx_messageInfo_ShortNode.Merge(dst, src)
}
func (m *ShortNode) XXX_Size() int {
return xxx_messageInfo_ShortNode.Size(m)
}
func (m *ShortNode) XXX_DiscardUnknown() {
xxx_messageInfo_ShortNode.DiscardUnknown(m)
}
var xxx_messageInfo_ShortNode proto.InternalMessageInfo
func (m *ShortNode) GetKey() []byte { func (m *ShortNode) GetKey() []byte {
if m != nil { if m != nil {
...@@ -276,12 +335,34 @@ func (m *ShortNode) GetVal() *Node { ...@@ -276,12 +335,34 @@ func (m *ShortNode) GetVal() *Node {
// HashNode hash节点 // HashNode hash节点
type HashNode struct { type HashNode struct {
Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *HashNode) Reset() { *m = HashNode{} } func (m *HashNode) Reset() { *m = HashNode{} }
func (m *HashNode) String() string { return proto.CompactTextString(m) } func (m *HashNode) String() string { return proto.CompactTextString(m) }
func (*HashNode) ProtoMessage() {} func (*HashNode) ProtoMessage() {}
func (*HashNode) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } func (*HashNode) Descriptor() ([]byte, []int) {
return fileDescriptor_node_001a9bd628f8d256, []int{3}
}
func (m *HashNode) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_HashNode.Unmarshal(m, b)
}
func (m *HashNode) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_HashNode.Marshal(b, m, deterministic)
}
func (dst *HashNode) XXX_Merge(src proto.Message) {
xxx_messageInfo_HashNode.Merge(dst, src)
}
func (m *HashNode) XXX_Size() int {
return xxx_messageInfo_HashNode.Size(m)
}
func (m *HashNode) XXX_DiscardUnknown() {
xxx_messageInfo_HashNode.DiscardUnknown(m)
}
var xxx_messageInfo_HashNode proto.InternalMessageInfo
func (m *HashNode) GetHash() []byte { func (m *HashNode) GetHash() []byte {
if m != nil { if m != nil {
...@@ -293,12 +374,34 @@ func (m *HashNode) GetHash() []byte { ...@@ -293,12 +374,34 @@ func (m *HashNode) GetHash() []byte {
// ValueNode value节点 // ValueNode value节点
type ValueNode struct { type ValueNode struct {
Value []byte `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` Value []byte `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *ValueNode) Reset() { *m = ValueNode{} } func (m *ValueNode) Reset() { *m = ValueNode{} }
func (m *ValueNode) String() string { return proto.CompactTextString(m) } func (m *ValueNode) String() string { return proto.CompactTextString(m) }
func (*ValueNode) ProtoMessage() {} func (*ValueNode) ProtoMessage() {}
func (*ValueNode) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } func (*ValueNode) Descriptor() ([]byte, []int) {
return fileDescriptor_node_001a9bd628f8d256, []int{4}
}
func (m *ValueNode) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ValueNode.Unmarshal(m, b)
}
func (m *ValueNode) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ValueNode.Marshal(b, m, deterministic)
}
func (dst *ValueNode) XXX_Merge(src proto.Message) {
xxx_messageInfo_ValueNode.Merge(dst, src)
}
func (m *ValueNode) XXX_Size() int {
return xxx_messageInfo_ValueNode.Size(m)
}
func (m *ValueNode) XXX_DiscardUnknown() {
xxx_messageInfo_ValueNode.DiscardUnknown(m)
}
var xxx_messageInfo_ValueNode proto.InternalMessageInfo
func (m *ValueNode) GetValue() []byte { func (m *ValueNode) GetValue() []byte {
if m != nil { if m != nil {
...@@ -315,9 +418,9 @@ func init() { ...@@ -315,9 +418,9 @@ func init() {
proto.RegisterType((*ValueNode)(nil), "mpt.ValueNode") proto.RegisterType((*ValueNode)(nil), "mpt.ValueNode")
} }
func init() { proto.RegisterFile("node.proto", fileDescriptor0) } func init() { proto.RegisterFile("node.proto", fileDescriptor_node_001a9bd628f8d256) }
var fileDescriptor0 = []byte{ var fileDescriptor_node_001a9bd628f8d256 = []byte{
// 264 bytes of a gzipped FileDescriptorProto // 264 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x51, 0xc1, 0x4a, 0xc3, 0x40, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x51, 0xc1, 0x4a, 0xc3, 0x40,
0x10, 0x75, 0xb3, 0xd9, 0xda, 0x4c, 0xb5, 0xc8, 0xe0, 0x61, 0x41, 0xd0, 0xb8, 0x82, 0x04, 0x84, 0x10, 0x75, 0xb3, 0xd9, 0xda, 0x4c, 0xb5, 0xc8, 0xe0, 0x61, 0x41, 0xd0, 0xb8, 0x82, 0x04, 0x84,
......
...@@ -37,6 +37,7 @@ import ( ...@@ -37,6 +37,7 @@ import (
"github.com/33cn/chain33/common" "github.com/33cn/chain33/common"
dbm "github.com/33cn/chain33/common/db" dbm "github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/common/log"
comTy "github.com/33cn/chain33/types" comTy "github.com/33cn/chain33/types"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
...@@ -54,6 +55,7 @@ var ( ...@@ -54,6 +55,7 @@ var (
func init() { func init() {
rand.Seed(time.Now().UnixNano()) rand.Seed(time.Now().UnixNano())
log.SetLogLevel("err")
spew.Config.Indent = " " spew.Config.Indent = " "
spew.Config.DisableMethods = false spew.Config.DisableMethods = false
} }
......
...@@ -29,10 +29,12 @@ import ( ...@@ -29,10 +29,12 @@ import (
"github.com/33cn/chain33/common" "github.com/33cn/chain33/common"
dbm "github.com/33cn/chain33/common/db" dbm "github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/common/log"
) )
func init() { func init() {
mrand.Seed(time.Now().UnixNano()) mrand.Seed(time.Now().UnixNano())
log.SetLogLevel("err")
} }
// makeProvers creates Merkle trie provers based on different implementations to // makeProvers creates Merkle trie provers based on different implementations to
......
...@@ -735,7 +735,6 @@ func get10000(t assert.TestingT, root common.Hash, db dbm.DB, keys map[string]st ...@@ -735,7 +735,6 @@ func get10000(t assert.TestingT, root common.Hash, db dbm.DB, keys map[string]st
database := NewDatabase(db) database := NewDatabase(db)
t1, _ := New(root, database) t1, _ := New(root, database)
for k, v := range keys { for k, v := range keys {
fmt.Println(k, v)
value, err := t1.TryGet([]byte(k)) value, err := t1.TryGet([]byte(k))
assert.Nil(t, err) assert.Nil(t, err)
assert.Equal(t, string(value), v) assert.Equal(t, string(value), v)
......
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