Skip to content

Commit

Permalink
no verification just execute
Browse files Browse the repository at this point in the history
  • Loading branch information
jackzhhuang committed Dec 6, 2024
1 parent 188fd4a commit 8f01900
Showing 1 changed file with 10 additions and 49 deletions.
59 changes: 10 additions & 49 deletions flexidag/src/ghostdag/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,58 +184,19 @@ impl<
let selected_parent = self.find_selected_parent(header.parents_hash().into_iter())?;
// Initialize new GHOSTDAG block data with the selected parent
let mut new_block_data = GhostdagData::new_with_selected_parent(selected_parent, self.k);
let ordered_mergeset = self.sort_blocks(
new_block_data.mergeset_blues = Arc::new(
vec![selected_parent]
.into_iter()
.chain(self.sort_blocks(blue_blocks.iter().map(|header| header.id()))?)
.collect(),
);
new_block_data.mergeset_reds = Arc::new(
header
.parents_hash()
.into_iter()
.filter(|header_id| *header_id != new_block_data.selected_parent)
.chain(
blue_blocks
.iter()
.filter(|header| header.id() != new_block_data.selected_parent)
.map(|header| header.id()),
)
.collect::<HashSet<_>>()
.into_iter()
.collect::<Vec<_>>(),
)?;

for blue_candidate in ordered_mergeset.iter().cloned() {
let coloring = self.check_blue_candidate(&new_block_data, blue_candidate)?;
if let ColoringOutput::Blue(blue_anticone_size, blues_anticone_sizes) = coloring {
// No k-cluster violation found, we can now set the candidate block as blue
new_block_data.add_blue(blue_candidate, blue_anticone_size, &blues_anticone_sizes);
} else {
new_block_data.add_red(blue_candidate);
}
}

if new_block_data
.mergeset_blues
.iter()
.skip(1)
.cloned()
.collect::<HashSet<_>>()
!= blue_blocks
.iter()
.map(|header| header.id())
.collect::<HashSet<_>>()
{
warn!("The data of blue set is not equal when executing the block: {:?}, for {:?}, checking data: {:?}", header.id(), blue_blocks.iter().map(|header| header.id()).collect::<Vec<_>>(), new_block_data.mergeset_blues);
new_block_data.mergeset_blues = Arc::new(
vec![selected_parent]
.into_iter()
.chain(blue_blocks.iter().map(|header| header.id()))
.collect(),
);
new_block_data.mergeset_reds = Arc::new(
header
.parents_hash()
.into_iter()
.filter(|header_id| !new_block_data.mergeset_blues.contains(header_id))
.collect(),
);
}
.filter(|header_id| !new_block_data.mergeset_blues.contains(header_id))
.collect(),
);

let blue_score = self
.ghostdag_store
Expand Down

0 comments on commit 8f01900

Please sign in to comment.