Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
parity-bitcoin
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-bitcoin
Commits
3ab243ee
Commit
3ab243ee
authored
5 years ago
by
Svyatoslav Nikolsky
Browse files
Options
Downloads
Patches
Plain Diff
post-merge fix
parent
f8f8db65
Branches
zcash_backports2
Branches containing commit
No related merge requests found
Pipeline
#36661
passed with stage
in 19 minutes and 37 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
storage/src/error.rs
+4
-1
4 additions, 1 deletion
storage/src/error.rs
sync/src/blocks_writer.rs
+9
-9
9 additions, 9 deletions
sync/src/blocks_writer.rs
with
13 additions
and
10 deletions
storage/src/error.rs
+
4
−
1
View file @
3ab243ee
...
...
@@ -3,9 +3,12 @@ pub enum Error {
/// Low level database error
#[display(fmt
=
"Database error: {}"
,
_0)]
DatabaseError
(
String
),
///
Invalid
block
///
Cannot canonize
block
#[display(fmt
=
"Cannot canonize block"
)]
CannotCanonize
,
/// Cannot decanonize block
#[display(fmt
=
"Cannot decanonize block"
)]
CannotDecanonize
,
/// Uknown parent
#[display(fmt
=
"Block parent is unknown"
)]
UnknownParent
,
...
...
This diff is collapsed.
Click to expand it.
sync/src/blocks_writer.rs
+
9
−
9
View file @
3ab243ee
...
...
@@ -9,7 +9,7 @@ use super::Error;
use
synchronization_chain
::
Chain
;
use
synchronization_verifier
::{
Verifier
,
SyncVerifier
,
VerificationTask
,
VerificationSink
,
BlockVerificationSink
,
TransactionVerificationSink
};
use
types
::
{
PeerIndex
,
StorageRef
}
;
use
types
::
StorageRef
;
use
utils
::
OrphanBlocksPool
;
use
VerificationParameters
;
...
...
@@ -45,7 +45,7 @@ struct BlocksWriterSinkData {
impl
BlocksWriter
{
/// Create new synchronous blocks writer
pub
fn
new
(
storage
:
StorageRef
,
consensus
:
ConsensusParams
,
verification_params
:
VerificationParameters
)
->
BlocksWriter
{
let
sink_data
=
Arc
::
new
(
Mutex
::
new
(
BlocksWriterSinkData
::
new
(
storage
.clone
())));
let
sink_data
=
Arc
::
new
(
Mutex
::
new
(
BlocksWriterSinkData
::
new
(
storage
.clone
()
,
consensus
.clone
()
)));
let
sink
=
Arc
::
new
(
BlocksWriterSink
::
new
(
sink_data
.clone
()));
let
verifier
=
SyncVerifier
::
new
(
consensus
,
storage
.clone
(),
sink
,
verification_params
);
BlocksWriter
{
...
...
@@ -78,7 +78,7 @@ impl BlocksWriter {
verification_queue
.push_front
(
block
);
while
let
Some
(
block
)
=
verification_queue
.pop_front
()
{
self
.verifier
.verify_block
(
block
);
if
let
Some
(
err
)
=
self
.sink
.error
()
{
if
let
Some
(
err
)
=
self
.sink
.
lock
()
.
error
()
{
return
Err
(
err
);
}
}
...
...
@@ -98,9 +98,9 @@ impl BlocksWriterSink {
impl
BlocksWriterSinkData
{
/// Create new blocks writer data
pub
fn
new
(
storage
:
StorageRef
)
->
Self
{
pub
fn
new
(
storage
:
StorageRef
,
consensus
:
ConsensusParams
)
->
Self
{
BlocksWriterSinkData
{
chain
:
Chain
::
new
(
storage
,
Default
::
default
()),
chain
:
Chain
::
new
(
storage
,
consensus
,
Default
::
default
()),
err
:
None
,
}
}
...
...
@@ -213,13 +213,13 @@ mod tests {
// (1) b0 ---> (2) b1
// \--> (3) b2 ---> (4 - reorg) b3
let
b0
=
test_data
::
block_builder
()
.header
()
.build
()
.build
();
let
b1
=
test_data
::
block_builder
()
.header
()
.nonce
(
1
.into
()
)
.parent
(
b0
.hash
())
.build
()
.build
();
let
b2
=
test_data
::
block_builder
()
.header
()
.nonce
(
2
.into
()
)
.parent
(
b0
.hash
())
.build
()
.build
();
let
b1
=
test_data
::
block_builder
()
.header
()
.nonce
(
1
)
.parent
(
b0
.hash
())
.build
()
.build
();
let
b2
=
test_data
::
block_builder
()
.header
()
.nonce
(
2
)
.parent
(
b0
.hash
())
.build
()
.build
();
let
b3
=
test_data
::
block_builder
()
.header
()
.parent
(
b2
.hash
())
.build
()
.build
();
let
db
=
Arc
::
new
(
BlockChainDatabase
::
init_test_chain
(
vec!
[
b0
.into
()]));
let
mut
blocks_target
=
BlocksWriter
::
new
(
db
.clone
(),
ConsensusParams
::
new
(
Network
::
Testnet
),
VerificationParameters
{
verification_level
:
VerificationLevel
::
N
O_VERIFICATION
,
let
mut
blocks_target
=
BlocksWriter
::
new
(
db
.clone
(),
ConsensusParams
::
new
(
Network
::
Testnet
,
ConsensusFork
::
BitcoinCore
),
VerificationParameters
{
verification_level
:
VerificationLevel
::
N
oVerification
,
verification_edge
:
0u8
.into
(),
});
assert_eq!
(
blocks_target
.append_block
(
b1
.into
()),
Ok
(()));
...
...
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