Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Dunitrust
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nodes
rust
Dunitrust
Commits
0315153d
Commit
0315153d
authored
7 years ago
by
Éloïs
Browse files
Options
Downloads
Plain Diff
Merge branch '46-protocol-add-documenthasher-trait' into 'dev'
Resolve "protocol : add DocumentHasher Trait" Closes
#46
See merge request
!33
parents
d4935650
dc5ca45e
No related branches found
No related tags found
1 merge request
!33
Resolve "protocol : add DocumentHasher Trait"
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
documents/blockchain/v10/documents/mod.rs
+10
-0
10 additions, 0 deletions
documents/blockchain/v10/documents/mod.rs
with
10 additions
and
0 deletions
documents/blockchain/v10/documents/mod.rs
+
10
−
0
View file @
0315153d
...
@@ -15,6 +15,10 @@
...
@@ -15,6 +15,10 @@
//! Provide wrappers around Duniter blockchain documents for protocol version 10.
//! Provide wrappers around Duniter blockchain documents for protocol version 10.
extern
crate
crypto
;
use
self
::
crypto
::
digest
::
Digest
;
use
duniter_crypto
::
keys
::{
Signature
,
ed25519
};
use
duniter_crypto
::
keys
::{
Signature
,
ed25519
};
use
regex
::
Regex
;
use
regex
::
Regex
;
use
blockchain
::{
Document
,
DocumentBuilder
,
DocumentParser
};
use
blockchain
::{
Document
,
DocumentBuilder
,
DocumentParser
};
...
@@ -72,6 +76,12 @@ pub trait TextDocument: Document<PublicKey = ed25519::PublicKey, CurrencyType =
...
@@ -72,6 +76,12 @@ pub trait TextDocument: Document<PublicKey = ed25519::PublicKey, CurrencyType =
/// Return document as text.
/// Return document as text.
fn
as_text
(
&
self
)
->
&
str
;
fn
as_text
(
&
self
)
->
&
str
;
/// Return sha256 hash of text document
fn
hash
<
H
:
Digest
>
(
&
self
,
digest
:
&
mut
H
)
->
String
{
digest
.input_str
(
self
.as_text
());
digest
.result_str
()
}
/// Return document as text with leading signatures.
/// Return document as text with leading signatures.
fn
as_text_with_signatures
(
&
self
)
->
String
{
fn
as_text_with_signatures
(
&
self
)
->
String
{
let
mut
text
=
self
.as_text
()
.to_string
();
let
mut
text
=
self
.as_text
()
.to_string
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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