Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
8222696c
Commit
8222696c
authored
Dec 01, 2018
by
vipwzw
Committed by
33cn
Dec 01, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update new proto
parent
c07239ab
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
140 additions
and
34 deletions
+140
-34
hasher.go
plugin/store/mpt/db/hasher.go
+1
-1
node.pb.go
plugin/store/mpt/db/node.pb.go
+135
-32
trie_test.go
plugin/store/mpt/db/trie_test.go
+2
-0
proof_test.go
plugin/store/mpt/db2/proof_test.go
+2
-0
trie_test.go
plugin/store/mpt/db2/trie_test.go
+0
-1
No files found.
plugin/store/mpt/db/hasher.go
View file @
8222696c
...
...
@@ -176,7 +176,7 @@ func (h *hasher) store(n node, db *Database, force bool) (node, error) {
//这个不用非常精确,只要保持确定性就可以了
size
:=
n
.
size
()
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
()
data
,
err
:=
proto
.
Marshal
(
nn
)
...
...
plugin/store/mpt/db/node.pb.go
View file @
8222696c
// Code generated by protoc-gen-go. DO NOT EDIT.
// 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
import
proto
"github.com/golang/protobuf/proto"
...
...
@@ -39,35 +26,63 @@ type Node struct {
// *Node_Hash
// *Node_Val
Value
isNode_Value
`protobuf_oneof:"value"`
Ty
int32
`protobuf:"varint,1,opt,name=Ty" json:"Ty,omitempty"`
Index
int32
`protobuf:"varint,6,opt,name=index" json:"index,omitempty"`
Ty
int32
`protobuf:"varint,1,opt,name=Ty,proto3" json:"Ty,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
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
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
{
isNode_Value
()
}
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
{
Short
*
ShortNode
`protobuf:"bytes,3,opt,name=short,oneof"`
Short
*
ShortNode
`protobuf:"bytes,3,opt,name=short,
proto3,
oneof"`
}
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
{
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_Short
)
isNode_Value
()
{}
func
(
*
Node_Hash
)
isNode_Value
()
{}
func
(
*
Node_Val
)
isNode_Value
()
{}
func
(
m
*
Node
)
GetValue
()
isNode_Value
{
...
...
@@ -206,22 +221,22 @@ func _Node_OneofSizer(msg proto.Message) (n int) {
switch
x
:=
m
.
Value
.
(
type
)
{
case
*
Node_Full
:
s
:=
proto
.
Size
(
x
.
Full
)
n
+=
proto
.
SizeVarint
(
2
<<
3
|
proto
.
WireBytes
)
n
+=
1
// tag and wire
n
+=
proto
.
SizeVarint
(
uint64
(
s
))
n
+=
s
case
*
Node_Short
:
s
:=
proto
.
Size
(
x
.
Short
)
n
+=
proto
.
SizeVarint
(
3
<<
3
|
proto
.
WireBytes
)
n
+=
1
// tag and wire
n
+=
proto
.
SizeVarint
(
uint64
(
s
))
n
+=
s
case
*
Node_Hash
:
s
:=
proto
.
Size
(
x
.
Hash
)
n
+=
proto
.
SizeVarint
(
4
<<
3
|
proto
.
WireBytes
)
n
+=
1
// tag and wire
n
+=
proto
.
SizeVarint
(
uint64
(
s
))
n
+=
s
case
*
Node_Val
:
s
:=
proto
.
Size
(
x
.
Val
)
n
+=
proto
.
SizeVarint
(
5
<<
3
|
proto
.
WireBytes
)
n
+=
1
// tag and wire
n
+=
proto
.
SizeVarint
(
uint64
(
s
))
n
+=
s
case
nil
:
...
...
@@ -233,13 +248,35 @@ func _Node_OneofSizer(msg proto.Message) (n int) {
// FullNode 分支节点
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
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
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
{
if
m
!=
nil
{
...
...
@@ -251,13 +288,35 @@ func (m *FullNode) GetNodes() []*Node {
// ShortNode 扩展/叶子节点
type
ShortNode
struct
{
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
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
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
{
if
m
!=
nil
{
...
...
@@ -276,12 +335,34 @@ func (m *ShortNode) GetVal() *Node {
// HashNode hash节点
type
HashNode
struct
{
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
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
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
{
if
m
!=
nil
{
...
...
@@ -293,12 +374,34 @@ func (m *HashNode) GetHash() []byte {
// ValueNode value节点
type
ValueNode
struct
{
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
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
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
{
if
m
!=
nil
{
...
...
@@ -315,9 +418,9 @@ func init() {
proto
.
RegisterType
((
*
ValueNode
)(
nil
),
"mpt.ValueNode"
)
}
func
init
()
{
proto
.
RegisterFile
(
"node.proto"
,
fileDescriptor
0
)
}
func
init
()
{
proto
.
RegisterFile
(
"node.proto"
,
fileDescriptor
_node_001a9bd628f8d256
)
}
var
fileDescriptor
0
=
[]
byte
{
var
fileDescriptor
_node_001a9bd628f8d256
=
[]
byte
{
// 264 bytes of a gzipped FileDescriptorProto
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
,
...
...
plugin/store/mpt/db/trie_test.go
View file @
8222696c
...
...
@@ -37,6 +37,7 @@ import (
"github.com/33cn/chain33/common"
dbm
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/common/log"
comTy
"github.com/33cn/chain33/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
...
...
@@ -54,6 +55,7 @@ var (
func
init
()
{
rand
.
Seed
(
time
.
Now
()
.
UnixNano
())
log
.
SetLogLevel
(
"err"
)
spew
.
Config
.
Indent
=
" "
spew
.
Config
.
DisableMethods
=
false
}
...
...
plugin/store/mpt/db2/proof_test.go
View file @
8222696c
...
...
@@ -29,10 +29,12 @@ import (
"github.com/33cn/chain33/common"
dbm
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/common/log"
)
func
init
()
{
mrand
.
Seed
(
time
.
Now
()
.
UnixNano
())
log
.
SetLogLevel
(
"err"
)
}
// makeProvers creates Merkle trie provers based on different implementations to
...
...
plugin/store/mpt/db2/trie_test.go
View file @
8222696c
...
...
@@ -735,7 +735,6 @@ func get10000(t assert.TestingT, root common.Hash, db dbm.DB, keys map[string]st
database
:=
NewDatabase
(
db
)
t1
,
_
:=
New
(
root
,
database
)
for
k
,
v
:=
range
keys
{
fmt
.
Println
(
k
,
v
)
value
,
err
:=
t1
.
TryGet
([]
byte
(
k
))
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
string
(
value
),
v
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment