Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
shasper
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository 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
shasper
Commits
57aa3311
Unverified
Commit
57aa3311
authored
5 years ago
by
Wei Tang
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
ssz: RawHashable and RawDigestible (#121)
parent
812fcd0d
Branches
Branches containing commit
No related merge requests found
Pipeline
#36287
passed with stages
Stage:
Stage:
in 8 minutes and 48 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
utils/ssz/src/hash.rs
+28
-0
28 additions, 0 deletions
utils/ssz/src/hash.rs
utils/ssz/src/lib.rs
+1
-1
1 addition, 1 deletion
utils/ssz/src/lib.rs
with
29 additions
and
1 deletion
utils/ssz/src/hash.rs
+
28
−
0
View file @
57aa3311
...
...
@@ -2,6 +2,8 @@ use primitive_types::{U256, H256, H160};
use
hash_db
::
Hasher
;
use
digest
::
Digest
;
use
generic_array
::
GenericArray
;
use
core
::
marker
::
PhantomData
;
use
crate
::
Fixed
;
pub
trait
Digestible
<
D
:
Digest
>
{
...
...
@@ -20,6 +22,32 @@ pub trait Hashable<H: Hasher> {
pub
trait
Composite
{
}
pub
struct
RawDigestible
<
D
:
Digest
>
{
hash
:
GenericArray
<
u8
,
D
::
OutputSize
>
,
_marker
:
PhantomData
<
D
>
,
}
impl
<
D
:
Digest
>
Composite
for
RawDigestible
<
D
>
{
}
impl
<
D
:
Digest
>
Digestible
<
D
>
for
RawDigestible
<
D
>
{
fn
hash
(
&
self
)
->
GenericArray
<
u8
,
D
::
OutputSize
>
{
self
.hash
.clone
()
}
}
pub
struct
RawHashable
<
H
:
Hasher
>
{
hash
:
H
::
Out
,
_marker
:
PhantomData
<
H
>
,
}
impl
<
H
:
Hasher
>
Composite
for
RawHashable
<
H
>
{
}
impl
<
H
:
Hasher
>
Hashable
<
H
>
for
RawHashable
<
H
>
{
fn
hash
(
&
self
)
->
H
::
Out
{
self
.hash
.clone
()
}
}
macro_rules!
impl_hashable_and_digestible_with_chunkify
{
(
$t:ty
,
$self:ident
,
$merkleize:ident
,
$chunkify:ident
,
$mix_in_length:ident
,
$e:expr
)
=>
{
impl
<
H
:
Hasher
>
Hashable
<
H
>
for
$t
{
...
...
This diff is collapsed.
Click to expand it.
utils/ssz/src/lib.rs
+
1
−
1
View file @
57aa3311
...
...
@@ -58,7 +58,7 @@ pub mod hash;
mod
tests
;
pub
use
self
::
codec
::{
Input
,
Output
,
Encode
,
Decode
,
Prefixable
,
Fixed
};
pub
use
self
::
hash
::{
Hashable
,
Digestible
,
Composite
};
pub
use
self
::
hash
::{
Hashable
,
Digestible
,
Composite
,
RawDigestible
,
RawHashable
};
/// Trait that allows zero-copy read/write of value-references to/from slices in LE format.
pub
trait
Ssz
:
Decode
+
Encode
{}
...
...
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