jimmysong / programmingbitcoin

Repository for the book
Other
1.75k stars 656 forks source link

Ch 11. Improvement: Calculation of merkle depth items. #227

Open sjorsvanheuveln opened 3 years ago

sjorsvanheuveln commented 3 years ago

This: num_items = math.ceil(self.total / 2**(self.max_depth - depth))

Can be simplified to this: num_items = 2**depth

For depth 0 to and including max_depth