Skip to content

Commit

Permalink
Merge pull request nervosnetwork#4302 from eval-exec/exec/active-chain
Browse files Browse the repository at this point in the history
Remove `ActiveChain`'s `state: SyncState` field, reuse `ActiveChain#shared#state` instead
  • Loading branch information
quake authored Jan 16, 2024
2 parents a053514 + 85b5678 commit 9855826
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sync/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,6 @@ impl SyncShared {
ActiveChain {
shared: self.clone(),
snapshot: Arc::clone(&self.shared.snapshot()),
state: Arc::clone(&self.state),
}
}

Expand Down Expand Up @@ -2048,7 +2047,6 @@ impl SyncState {
pub struct ActiveChain {
shared: SyncShared,
snapshot: Arc<Snapshot>,
state: Arc<SyncState>,
}

#[doc(hidden)]
Expand Down Expand Up @@ -2300,6 +2298,7 @@ impl ActiveChain {
block_number_and_hash: BlockNumberAndHash,
) {
if let Some(last_time) = self
.shared()
.state
.pending_get_headers
.write()
Expand All @@ -2318,7 +2317,8 @@ impl ActiveChain {
);
}
}
self.state
self.shared()
.state()
.pending_get_headers
.write()
.put((peer, block_number_and_hash.hash()), Instant::now());
Expand All @@ -2338,10 +2338,10 @@ impl ActiveChain {
}

pub fn get_block_status(&self, block_hash: &Byte32) -> BlockStatus {
match self.state.block_status_map.get(block_hash) {
match self.shared().state().block_status_map.get(block_hash) {
Some(status_ref) => *status_ref.value(),
None => {
if self.state.header_map.contains_key(block_hash) {
if self.shared().state().header_map.contains_key(block_hash) {
BlockStatus::HEADER_VALID
} else {
let verified = self
Expand Down

0 comments on commit 9855826

Please sign in to comment.