Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
parity-test-sync
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
parity-test-sync
Commits
b51b8199
Commit
b51b8199
authored
9 years ago
by
Marek Kotewicz
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
https://github.com/gavofyork/ethcore-util
parents
6660b3d6
0eb6f97a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/nibbleslice.rs
+14
-0
14 additions, 0 deletions
src/nibbleslice.rs
src/rlp.rs
+0
-4
0 additions, 4 deletions
src/rlp.rs
src/trie.rs
+14
-3
14 additions, 3 deletions
src/trie.rs
with
28 additions
and
7 deletions
src/nibbleslice.rs
+
14
−
0
View file @
b51b8199
...
@@ -38,6 +38,11 @@ impl<'a> NibbleSlice<'a> {
...
@@ -38,6 +38,11 @@ impl<'a> NibbleSlice<'a> {
/// Create a new nibble slice with the given byte-slice with a nibble offset.
/// Create a new nibble slice with the given byte-slice with a nibble offset.
pub
fn
new_offset
(
data
:
&
'a
[
u8
],
offset
:
usize
)
->
NibbleSlice
{
NibbleSlice
{
data
:
data
,
offset
:
offset
}
}
pub
fn
new_offset
(
data
:
&
'a
[
u8
],
offset
:
usize
)
->
NibbleSlice
{
NibbleSlice
{
data
:
data
,
offset
:
offset
}
}
/// Create a new nibble slice from the given HPE encoded data (e.g. output of `encoded()`).
pub
fn
from_encoded
(
data
:
&
'a
[
u8
])
->
(
NibbleSlice
,
bool
)
{
(
Self
::
new_offset
(
data
,
if
data
[
0
]
&
16
==
16
{
1
}
else
{
2
}),
data
[
0
]
&
32
==
32
)
}
/// Is this an empty slice?
/// Is this an empty slice?
pub
fn
is_empty
(
&
self
)
->
bool
{
self
.len
()
==
0
}
pub
fn
is_empty
(
&
self
)
->
bool
{
self
.len
()
==
0
}
...
@@ -148,6 +153,15 @@ mod tests {
...
@@ -148,6 +153,15 @@ mod tests {
assert_eq!
(
n
.mid
(
1
)
.encoded
(
true
),
&
[
0x31
,
0x23
,
0x45
]);
assert_eq!
(
n
.mid
(
1
)
.encoded
(
true
),
&
[
0x31
,
0x23
,
0x45
]);
}
}
#[test]
fn
from_encoded
()
{
let
n
=
NibbleSlice
::
new
(
D
);
assert_eq!
((
n
,
false
),
NibbleSlice
::
from_encoded
(
&
[
0x00
,
0x01
,
0x23
,
0x45
]));
assert_eq!
((
n
,
true
),
NibbleSlice
::
from_encoded
(
&
[
0x20
,
0x01
,
0x23
,
0x45
]));
assert_eq!
((
n
.mid
(
1
),
false
),
NibbleSlice
::
from_encoded
(
&
[
0x11
,
0x23
,
0x45
]));
assert_eq!
((
n
.mid
(
1
),
true
),
NibbleSlice
::
from_encoded
(
&
[
0x31
,
0x23
,
0x45
]));
}
#[test]
#[test]
fn
shared
()
{
fn
shared
()
{
let
n
=
NibbleSlice
::
new
(
D
);
let
n
=
NibbleSlice
::
new
(
D
);
...
...
This diff is collapsed.
Click to expand it.
src/rlp.rs
+
0
−
4
View file @
b51b8199
...
@@ -227,10 +227,6 @@ impl<'a> Rlp<'a> {
...
@@ -227,10 +227,6 @@ impl<'a> Rlp<'a> {
From
::
from
(
self
.rlp
.at
(
index
)
.unwrap
())
From
::
from
(
self
.rlp
.at
(
index
)
.unwrap
())
}
}
pub
fn
data_at
(
&
self
,
_index
:
usize
)
->
&
[
u8
]
{
unimplemented!
();
}
/// No value
/// No value
///
///
/// ```rust
/// ```rust
...
...
This diff is collapsed.
Click to expand it.
src/trie.rs
+
14
−
3
View file @
b51b8199
...
@@ -88,6 +88,19 @@ impl TrieDB {
...
@@ -88,6 +88,19 @@ impl TrieDB {
unimplemented!
();
unimplemented!
();
},
},
Prototype
::
List
(
2
)
=>
{
Prototype
::
List
(
2
)
=>
{
let
their_key_rlp
=
o
.at
(
0
);
let
(
them
,
_
)
=
NibbleSlice
::
from_encoded
(
their_key_rlp
.data
());
match
partial_key
.common_prefix
(
&
them
)
{
0
=>
{
// transmute to branch here
},
cp
if
cp
==
them
.len
()
=>
{
// fast-forward
},
_
=>
{
// cleve into two + branch in the middle
},
}
// already have an extension. either fast_forward, cleve or transmute_to_branch.
// already have an extension. either fast_forward, cleve or transmute_to_branch.
unimplemented!
();
unimplemented!
();
},
},
...
@@ -143,7 +156,5 @@ fn playpen() {
...
@@ -143,7 +156,5 @@ fn playpen() {
assert!
(
t
.is_empty
());
assert!
(
t
.is_empty
());
t
.insert
(
&
[
0x01u8
,
0x23
],
&
[
0x01u8
,
0x23
]);
t
.insert
(
&
[
0x01u8
,
0x23
],
&
[
0x01u8
,
0x23
]);
assert_eq!
(
*
t
.root
(),
trie_root
(
vec!
[
assert_eq!
(
*
t
.root
(),
trie_root
(
vec!
[
(
vec!
[
1u8
,
0x23
],
vec!
[
1u8
,
0x23
])
]));
(
vec!
[
1u8
,
0x23
],
vec!
[
1u8
,
0x23
])
]));
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment