Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Boot the Builder pattern from GenesisBlock #6364

Merged
merged 1 commit into from
Oct 15, 2019

Conversation

garious
Copy link
Contributor

@garious garious commented Oct 15, 2019

Problem

Rust's Builder pattern is an anti-pattern. We ran this experiment a while back with the MessageBuilder struct. It led to confusing code and redundant wrappers. It's especially ugly when you start using it in imperative code (let builder = builder.do_something()). In the case of GenesisBlock, it went the same way.

Summary of Changes

  • Remove the Builder wrapper and add &mut self methods to GenesisBlock that move their input parameters instead of cloning them. Use the T { field*, ..T::default() } pattern.
  • Change some function names from ambiguous names like genesis() to the form <verb>_<subject>.
  • Purge term "primordial", because it's used the same was a "genesis" everywhere else.
  • Removed some unused crate dependencies.

@garious garious requested a review from rob-solana October 15, 2019 17:16
@codecov
Copy link

codecov bot commented Oct 15, 2019

Codecov Report

Merging #6364 into master will decrease coverage by 1%.
The diff coverage is 77.6%.

@@           Coverage Diff            @@
##           master   #6364     +/-   ##
========================================
- Coverage    75.8%   74.7%   -1.1%     
========================================
  Files         219     219             
  Lines       42965   43495    +530     
========================================
- Hits        32568   32499     -69     
- Misses      10397   10996    +599

@garious garious merged commit ae41c88 into solana-labs:master Oct 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants