Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polkadot-sdk
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
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Mirrored projects
polkadot-sdk
Commits
74ec849f
Commit
74ec849f
authored
7 years ago
by
asynchronous rob
Committed by
Tomasz Drwięga
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Block primitive (#11)
* initial primitives * add block primitives
parent
dbb123d0
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
substrate/primitives/src/block.rs
+70
-0
70 additions, 0 deletions
substrate/primitives/src/block.rs
substrate/primitives/src/lib.rs
+5
-1
5 additions, 1 deletion
substrate/primitives/src/lib.rs
with
75 additions
and
1 deletion
substrate/primitives/src/block.rs
0 → 100644
+
70
−
0
View file @
74ec849f
// Copyright 2017 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.
// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! Block and header type definitions.
use
hash
::
H256
;
/// Hash used to refer to a block hash.
pub
type
HeaderHash
=
H256
;
/// Hash used to refer to proof of block header.
pub
type
ProofHash
=
H256
;
/// Unique identifier of a parachain.
#[derive(Debug,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Clone,
Copy)]
pub
struct
ParachainId
(
u64
);
impl
From
<
ParachainId
>
for
u64
{
fn
from
(
x
:
ParachainId
)
->
Self
{
x
.0
}
}
impl
From
<
u64
>
for
ParachainId
{
fn
from
(
x
:
u64
)
->
Self
{
ParachainId
(
x
)
}
}
/// A parachain block proposal.
#[derive(Debug,
PartialEq,
Eq)]
pub
struct
ParachainProposal
{
/// The ID of the parachain this is a proposal for.
pub
parachain
:
ParachainId
,
/// Parachain block header bytes.
pub
header
:
Vec
<
u8
>
,
/// Hash of data necessary to prove validity of the header.
pub
proof_hash
:
ProofHash
,
}
/// A relay chain block header.
#[derive(Debug,
PartialEq,
Eq)]
pub
struct
Header
{
/// Block parent's hash.
pub
parent_hash
:
HeaderHash
,
/// State root after this transition.
pub
state_root
:
H256
,
/// Unix time at which this header was produced.
pub
timestamp
:
u64
,
/// Block number.
pub
number
:
u64
,
}
/// A relay chain block body.
///
/// Included candidates should be sorted by parachain ID, and without duplicate
/// IDs.
#[derive(Debug,
PartialEq,
Eq)]
pub
struct
Body
{
/// Parachain proposal blocks.
pub
para_blocks
:
Vec
<
ParachainProposal
>
,
}
This diff is collapsed.
Click to expand it.
substrate/primitives/src/lib.rs
+
5
−
1
View file @
74ec849f
...
...
@@ -28,8 +28,12 @@ extern crate fixed_hash;
#[macro_use]
extern
crate
uint
as
uint_crate
;
pub
mod
uint
;
pub
mod
block
;
pub
mod
hash
;
pub
mod
uint
;
/// Alias to 160-bit hash when used in the context of an account address.
pub
type
Address
=
hash
::
H160
;
#[cfg(test)]
mod
tests
{
...
...
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