Skip to content

Conversation

@NicolasDorier
Copy link
Contributor

For consensus block verification method into libconsensus, we need to get rid of BOOST dependencies.
This commit trivially transform the BOOST_FOREACH into for loop so we can move those functions into libconsensus later. Ping @jtimon

src/main.cpp Outdated
Copy link
Contributor

@dcousens dcousens Jul 15, 2016

Choose a reason for hiding this comment

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

Why not?

for (auto txout : tx.vout) {

It's C++11

Copy link
Member

Choose a reason for hiding this comment

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

Please use

for (const auto& txout : tx.vout)

to avoid copying the entire txout.

@NicolasDorier
Copy link
Contributor Author

Fixed nit, now using C++11 iteration loop style.

@maflcko
Copy link
Member

maflcko commented Jul 15, 2016

move those functions into libconsensus later

Concept ACK on doing required trivial refactors before moving chunks of code.

@NicolasDorier
Copy link
Contributor Author

I'm doing a big PR on #8339 that is still work in progress.
My goal is to make it smaller by doing trivial stuff I come accross while doing it, then I will rebase on top of it.

@dcousens
Copy link
Contributor

utACK 4358252

@NicolasDorier
Copy link
Contributor Author

@dcousens updated the commit, I forgot GetLegacySigopsCount

@jtimon
Copy link
Contributor

jtimon commented Jul 15, 2016

Concept ACK on doing required trivial refactors before moving chunks of code.

Why is that? Why can't #8329 , for example, happen before this?

Regarding the PR, I would prefer to move to plain C fors to move towards C rather than towards C++11 (I mean for libconsensus code only). But I don't care enough to nack.

@NicolasDorier
Copy link
Contributor Author

I would prefer C++ 11, only because I'm a spoiled kid using high level language like C# and even with C++11 I feel at the stone age. :(

I don't think it make sense to move something in consensus/* which can't yet be compiled into libconsensus. But I'm not feeling strongly about it neither.

@maflcko
Copy link
Member

maflcko commented Jul 15, 2016

Why is that? Why can't #8329 , for example, happen before this?

Haven't seen the other pull is already open. I have no strong opinion on which should go first. My comment was meant as a general guideline in case the more disruptive pull may not be uncontroversial enough to merge immediately and the trivial improvement can go in right now. Also note that the plan was to get rid of some boost stuff in 0.14, anyway. We could even do the replacement for the whole file ... hides .

@jtimon
Copy link
Contributor

jtimon commented Jul 15, 2016

Oh, personally I like the new loop more, and I'm very used to classes. Most of my experience is with C++, java and python, not C. But apparently some analysis tools are much more mature for C than for C++ and we could potentially benefit from them for consensus code if it was C. Maybe @gmaxwell can say more about this. In any case, was not a nack.

@jtimon
Copy link
Contributor

jtimon commented Jul 15, 2016

@MarcoFalke well, I was asking on the general guideline. It makes sense to open both options because we don't know what's going to be merged first. That's what I've been doing so far: any changes after a moveonly have been mostly ignored and the moveonlies themselves, separated or not, have been delayed forever. With the exception of this PR and #8341 all "dumb fixes" have been already done.
We need to make new consensus functions to be populated with code from main, mostly from connectBlock. But those functions will need to call existing consensus functions. Therefore either we move before doing that or we introduce a circular dependency between the new consensus file and main that won't be resolved until the existing consensus functions are moved out of main.
Plus people would have a place to write new consensus functions like, say SequenceLocks() better than main.
Sorry, maybe we should discuss this in #8329

@dcousens
Copy link
Contributor

dcousens commented Jul 15, 2016

@jtimon there is so much that would have to change to make libconsensus C only. This for-loop change does not change that in any way.
If a dedicated effort begins, when libconsensus is actually separated, to make it solely C, I'm sure these loops will be the simplest to change.

@jtimon
Copy link
Contributor

jtimon commented Jul 15, 2016

@dcousens agreed, while we keep adding classes to the consensus code, these lines are not a concern. I still would have preferred to do this with the old style loops ages ago.

src/main.cpp Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you using CTxIn& here and CTxOut& below instead of auto& as in other changes? Is there any reason for this I do not see?

@luke-jr
Copy link
Member

luke-jr commented Jul 15, 2016

utACK (and don't mind using auto where @paveljanik suggests)

This for loop cannot be C period - it's using classes. C++11 loops make sense.

@NicolasDorier
Copy link
Contributor Author

@paveljanik good catch, I just updated commit to use auto everywhere.

@paveljanik
Copy link
Contributor

ACK a3e1984

@btcdrak
Copy link
Contributor

btcdrak commented Jul 16, 2016

ACK a3e1984

@jtimon
Copy link
Contributor

jtimon commented Jul 16, 2016

Upgrade from non-nack to utACK a3e1984

@maflcko
Copy link
Member

maflcko commented Jul 17, 2016

utACK a3e1984

@laanwj
Copy link
Member

laanwj commented Jul 18, 2016

@jtimon We've switched the project to c++11 just so that the code can use c++11, please don't come up with any lousy excuses not to. If you want to port the consensus code to some other language later that should not affect how development is done in this project.

utACK a3e1984 (after .13 split-off)

@laanwj laanwj merged commit a3e1984 into bitcoin:master Jul 21, 2016
laanwj added a commit that referenced this pull request Jul 21, 2016
a3e1984 Consensus: Trivial transform BOOST_FOREACH into for loop (NicolasDorier)
codablock pushed a commit to codablock/dash that referenced this pull request Jan 8, 2018
…or loop

a3e1984 Consensus: Trivial transform BOOST_FOREACH into for loop (NicolasDorier)
vecopay pushed a commit to vecopay/veco that referenced this pull request Dec 16, 2018
…H into for loop

dashpay/dash@a3e1984 Consensus: Trivial transform BOOST_FOREACH into for loop (NicolasDorier)
andvgal pushed a commit to energicryptocurrency/gen2-energi that referenced this pull request Jan 6, 2019
…or loop

a3e1984 Consensus: Trivial transform BOOST_FOREACH into for loop (NicolasDorier)
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants