Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add proposer::TransactionPicker #153

Merged
merged 12 commits into from
Oct 10, 2018
Merged

add proposer::TransactionPicker #153

merged 12 commits into from
Oct 10, 2018

Conversation

scravy
Copy link
Member

@scravy scravy commented Oct 9, 2018

This adds a class named TransactionPicker and introduces a new namespace proposer in its own directory. I sort of got fed up of the untestability of bitcoin and that everything is intertwined with each other directly.

In order to propose a block I need to build one which is I have to (1) pick transactions (2) put a coinstake transaction (includes block height, signature, reward output) (3) sign the thing. Picking transactions is already implemented in bitcoin but it's well buried inside CBlockAssembler which does too many things at once for my taste + deals with that horrendous CBlockTemplate (see comment in BlockAssemblerAdapter in the source).

Since I want my Proposer to be testable and (1+2+3) are essentially simple operations I want the code to be simple. So here is the part which performs 1, by delegating to bitcoin's block assembler (for now). This way I do not have to change the block assembler or overwrite the coinbase transaction in the block template.

I would be interested in hearing your thoughts about my approach, as I intend to follow it with everything I do from now on. Maybe you are fundamentally opposed to virtual methods or whatever.

In bitcoin there have been small efforts to extract things into Interfaces (CValidationInterface for instance) also. More recent work is on separating wallet and node and also here they start to create interfaces (bitcoin/bitcoin#14437, src/interfaces).

@scravy scravy added the wip Work in progress which is not supposed to be merged yet label Oct 9, 2018
@scravy scravy self-assigned this Oct 9, 2018
@scravy scravy changed the title WIP: add transactionpicker add transactionpicker Oct 9, 2018
@scravy scravy removed the wip Work in progress which is not supposed to be merged yet label Oct 9, 2018
@scravy scravy changed the title add transactionpicker add proposer::TransactionPicker Oct 9, 2018
Copy link
Member

@Gnappuraz Gnappuraz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 3afc901

@scravy
Copy link
Member Author

scravy commented Oct 10, 2018

@Gnappuraz Thanks for your approval :-)

@AM5800 @Ruteri WDYT? I'd be very much interested in your opinion.

src/proposer/transactionpicker.cpp Outdated Show resolved Hide resolved
src/proposer/transactionpicker.cpp Outdated Show resolved Hide resolved
src/proposer/transactionpicker.h Outdated Show resolved Hide resolved
src/proposer/transactionpicker.h Show resolved Hide resolved
src/proposer/transactionpicker.h Outdated Show resolved Hide resolved
virtual ~TransactionPicker() = default;

//! \brief Factory method for creating a BlockAssemblerAdapter
static std::unique_ptr<TransactionPicker> BlockAssemblerAdapter(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my personal opinion: avoid any collisions, e.g., all these names should be unique:

  1. namespace
  2. class name
  3. function names
  4. local variables

Otherwise, it can confuse the reader. maybe think of another name for it?
and then you don't need to explicitly use class keyword when instantiating the object.
new class BlockAssemblerAdapter(chainParams));

@scravy scravy force-pushed the transactionpicker branch from fe454ca to d0d595c Compare October 10, 2018 09:42
Copy link
Member

@kostyantyn kostyantyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

Copy link
Member

@cornelius cornelius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the concept. Just some small questions about conventions in the other comments.

src/proposer/transactionpicker.h Show resolved Hide resolved
src/proposer/transactionpicker.cpp Show resolved Hide resolved
@scravy scravy force-pushed the transactionpicker branch from d63f7cc to d0d595c Compare October 10, 2018 10:01
Copy link
Member

@AM5800 AM5800 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@scravy
Copy link
Member Author

scravy commented Oct 10, 2018

For the newcommers: When reviewing we try to stick to the contribution guidelines outlined by bitcoin, which are documented in https://github.com/dtr-org/unit-e/blob/master/CONTRIBUTING.md#peer-review

Additionally we use githubs review/approve mechanism.

@frolosofsky frolosofsky requested review from frolosofsky and removed request for frolosofsky October 10, 2018 11:50
Copy link
Member

@frolosofsky frolosofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

Copy link
Member

@Nizametdinov Nizametdinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK d0d595c

@scravy scravy merged commit 2f4a236 into master Oct 10, 2018
@scravy scravy deleted the transactionpicker branch October 11, 2018 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants