Skip to content

Commit

Permalink
Add is_parent_exists for HeaderProcess
Browse files Browse the repository at this point in the history
  • Loading branch information
eval-exec committed Dec 13, 2024
1 parent df6cab7 commit 7accf53
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sync/src/synchronizer/headers_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ impl<'a> HeadersProcess<'a> {
true
}

fn is_parent_exists(&self, first_header: &core:HeaderView) -> bool {
let shared: &SyncShared = self.synchronizer.shared();
shared.get_header_fields(first_header.parent_hash).is_some()
}


pub fn accept_first(&self, first: &core::HeaderView) -> ValidationResult {
let shared: &SyncShared = self.synchronizer.shared();
let verifier = HeaderVerifier::new(shared, shared.consensus());
Expand Down Expand Up @@ -128,6 +134,12 @@ impl<'a> HeadersProcess<'a> {
return StatusCode::HeadersIsInvalid.with_context("not continuous");
}

if !self.is_parent_exists(&headers[0]) {
// put the headers into a memory cache
// verify them later
return Status::ok();
}

let result = self.accept_first(&headers[0]);
match result.state {
ValidationState::Invalid => {
Expand Down

0 comments on commit 7accf53

Please sign in to comment.