Skip to content

Commit d716ee9

Browse files
committed
update block import
1 parent cabba66 commit d716ee9

File tree

1 file changed

+16
-12
lines changed
  • substrate/client/consensus/babe/src

1 file changed

+16
-12
lines changed

substrate/client/consensus/babe/src/lib.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,11 +1630,12 @@ where
16301630
});
16311631
}
16321632

1633-
aux_schema::write_block_weight(hash, total_weight, |values| {
1634-
block
1635-
.auxiliary
1636-
.extend(values.iter().map(|(k, v)| (k.to_vec(), Some(v.to_vec()))))
1637-
});
1633+
// aux_schema::write_block_weight(hash, total_weight, |values| {
1634+
// block
1635+
// .auxiliary
1636+
// .extend(values.iter().map(|(k, v)| (k.to_vec(), Some(v.to_vec()))))
1637+
// });
1638+
self.epoch_changes.update_block_weight(hash, total_weight);
16381639

16391640
// The fork choice rule is that we pick the heaviest chain (i.e.
16401641
// more primary blocks), if there's a tie we go with the longest
@@ -1647,13 +1648,16 @@ where
16471648
// so we don't need to cover again here.
16481649
parent_weight
16491650
} else {
1650-
aux_schema::load_block_weight(&*self.client, last_best)
1651-
.map_err(|e| ConsensusError::ChainLookup(e.to_string()))?
1652-
.ok_or_else(|| {
1653-
ConsensusError::ChainLookup(
1654-
"No block weight for parent header.".to_string(),
1655-
)
1656-
})?
1651+
// aux_schema::load_block_weight(&*self.client, last_best)
1652+
// .map_err(|e| ConsensusError::ChainLookup(e.to_string()))?
1653+
// .ok_or_else(|| {
1654+
// ConsensusError::ChainLookup(
1655+
// "No block weight for parent header.".to_string(),
1656+
// )
1657+
// })?
1658+
self.epoch_changes.get_block_weight(last_best).ok_or_else(|| {
1659+
ConsensusError::ChainLookup("No block weight for parent header".to_string()),
1660+
})?
16571661
};
16581662

16591663
Some(ForkChoiceStrategy::Custom(if total_weight > last_best_weight {

0 commit comments

Comments
 (0)