Skip to content

Conversation

mariodian
Copy link
Contributor

Pass Consensus::Params& to ReceivedBlockTransactions() as requested in #7829

@TheBlueMatt
Copy link
Contributor

utACK. Want to mark ReceivedBlockTransactions static while you're at it?

@mariodian
Copy link
Contributor Author

@TheBlueMatt sure. Should I soft reset the commit and add the new change within a single commit?

@TheBlueMatt
Copy link
Contributor

Doesnt matter either way, I think.

@mariodian mariodian force-pushed the consensusparams-receivedblocktransactions branch from 5fbaec1 to 25660e9 Compare April 13, 2017 14:38
@paveljanik
Copy link
Contributor

ACK 25660e9

@jtimon
Copy link
Contributor

jtimon commented Apr 20, 2017

ACK 25660e9
Added to the list in #7829
If you feel like doing more functions in one go, maybe I can close #10227 (sorry I didn't see this before opening it, you need to "ping @jtimon" to get the promised review faster). Just by equaling it I would be more than happy to close #10227, but it occurs to me that I didn't do an exhaustive search on all the functions in validation.o that could be made static (independently on whether they use CChainParams or Consensus::Params or not). If you do that, I bet not only nobody will complain for increasing the scope of a PR with 3 acks but people will actually praise you (at least I will) for every new function that can be static you find apart from the 3 in #10227.
I think it's also a more interesting and rewarding task than what #7829 proposes alone.

EDIT: or maybe a separated PR for that makes more sense, I'm not sure

@mariodian
Copy link
Contributor Author

mariodian commented Apr 21, 2017

@jtimon this was the first time I was looking at a C++ code so my understanding of the language is next to zero. However, the similar pattern all the static functions seem to have is that they're only called within the same file. If that's the case (?) then I'll be able to do it (perhaps in a separate PR as you suggested).

@jtimon
Copy link
Contributor

jtimon commented Apr 21, 2017

Yes, static functions are only called from the same file. So for searching more functions in validation.cpp that could be static, it's more about grep than about C++ (and as said feel free to copy from #10227 ).
Either way I already acked this PR as it is, but would be happy to review more.

@mariodian
Copy link
Contributor Author

ping @jtimon

Made other methods static (not sure about FILE* OpenDiskFile() and FILE* OpenUndoFile() though).

Also copied #10227 and added parameter chainparams to FlushStateToDisk().

laanwj added a commit that referenced this pull request Apr 21, 2017
25660e9 pass Consensus::Params& to ReceivedBlockTransactions() (Mario Dian)

Tree-SHA512: d3a5b19d93313e4bda622b322bc9cbfb7e31486010eac40fca6eea9703f814f9667f778122ba7366bb304482a2c03e2e3325083beecac374751692361952e467
@jtimon
Copy link
Contributor

jtimon commented Apr 21, 2017

Yeah, it seems OpenDiskFile and OpenUndoFile are only called from validation.cpp and can be static too.

EDIT: also it seems @laanwj added one commit here by mistake.

@@ -281,23 +281,6 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
double GuessVerificationProgress(const ChainTxData& data, CBlockIndex* pindex);

/**
* Prune block and undo files (blk???.dat and undo???.dat) so that the disk space used is less than a user-defined target.
Copy link
Contributor

Choose a reason for hiding this comment

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

The documentation you are removing from here, you could move to the cpp with the function definition

@@ -183,8 +183,8 @@ enum FlushStateMode {
};

// See definition for documentation
bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode, int nManualPruneHeight=0);
void FindFilesToPruneManual(std::set<int>& setFilesToPrune, int nManualPruneHeight);
bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode, int nManualPruneHeight=0, const CChainParams& chainParams);
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that nManualPruneHeight is optional, the new CChainParams parameter (which is not) should come before it, for example, CChainParams can be the first parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right

@mariodian mariodian force-pushed the consensusparams-receivedblocktransactions branch 5 times, most recently from 8bc88d9 to a0a57e1 Compare April 21, 2017 18:45
@mariodian
Copy link
Contributor Author

@jtimon oh, I "accidentally" soft reset my first commit instead of fixingup the last one so everything is in the single commit now. Sorry, I haven't worked with git for quite a long time.

@jtimon
Copy link
Contributor

jtimon commented Apr 21, 2017

Mhmm, squashing in one commit is fine, what I mean is you also added a commit that doesn't belong here:
"Merge branch 'master' into consensusparams-receivedblocktransactions" 8b23dfd
Here's what you can do to fix this: rebase -i origin/master and remove that commit from the list.

@mariodian mariodian force-pushed the consensusparams-receivedblocktransactions branch from 8b23dfd to a0a57e1 Compare April 21, 2017 20:08
@jtimon
Copy link
Contributor

jtimon commented Apr 27, 2017

Needs rebase. EDIT: Also, perhaps changing the tittle name now that it does more things?

@mariodian mariodian changed the title pass Consensus::Params& to ReceivedBlockTransactions() pass Consensus::Params& to functions in validation.cpp and make them static Apr 27, 2017
@mariodian
Copy link
Contributor Author

@jtimon I changed the title.

Before I break anything while rebasing, is the following all that is needed?

git checkout consensusparams-receivedblocktransactions
git rebase master
git checkout master
git merge consensusparams-receivedblocktransactions

Thank you.

@jtimon
Copy link
Contributor

jtimon commented Apr 27, 2017

what I would usually do:

git checkout consensusparams-receivedblocktransactions
git fetch origin
git rebase -i origin/master
git push jtimon +consensusparams-receivedblocktransactions

Instead of jtimon, you need to use something else pointing to you repository
For example, in my bitcoin./git/config I have (among other things):

[remote "origin"]
	url = github:bitcoin/bitcoin.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[remote "jtimon"]
	url = github:jtimon/bitcoin.git
	fetch = +refs/heads/*:refs/remotes/jtimon/*

Using -i (for interactive) it's not very useful in this case because it is only one commit and the rebase will stop in it for the conflict anyway, but you can try to replace s/pick/edit/ or s/pick/reword/ to experiment with it. You can also use it for squash commits or remove them, I use interactive rebase all the time.

@mariodian mariodian force-pushed the consensusparams-receivedblocktransactions branch from a0a57e1 to cf8243b Compare April 27, 2017 18:18
@jtimon
Copy link
Contributor

jtimon commented May 19, 2017

Needs rebase

@mariodian mariodian force-pushed the consensusparams-receivedblocktransactions branch from af8be93 to 1dfdd81 Compare May 21, 2017 15:50
@mariodian mariodian force-pushed the consensusparams-receivedblocktransactions branch 2 times, most recently from d5eba1b to 1fe4f4c Compare June 1, 2017 13:58
@jtimon
Copy link
Contributor

jtimon commented Jun 1, 2017

needs rebase again

@mariodian mariodian force-pushed the consensusparams-receivedblocktransactions branch from 1fe4f4c to aba9780 Compare June 2, 2017 06:20
@@ -186,8 +186,11 @@ enum FlushStateMode {
};

// See definition for documentation
bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode, int nManualPruneHeight=0);
void FindFilesToPruneManual(std::set<int>& setFilesToPrune, int nManualPruneHeight);
bool static FlushStateToDisk(const CChainParams& chainParams, CValidationState &state, FlushStateMode mode, int nManualPruneHeight=0);
Copy link
Member

Choose a reason for hiding this comment

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

static bool iso bool static would be more consistent with other uses of static in the code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. Changed it.

Fix bugs as per PR comment

Change bool static to static bool
@mariodian mariodian force-pushed the consensusparams-receivedblocktransactions branch from aba9780 to 24980a3 Compare June 6, 2017 14:21
@laanwj laanwj merged commit 24980a3 into bitcoin:master Jun 6, 2017
laanwj added a commit that referenced this pull request Jun 6, 2017
…and make them static

24980a3 Make functions in validation.cpp static and pass chainparams (Mario Dian)

Tree-SHA512: 2d1b7b0ffd851317ed522911c1b6592855376c5cbc65d71ec0f8aa507eb6caef21b0709b3692255f1d719662db7447579c10df02f6ef4cd35fcb0bdf2e653af6
@mariodian mariodian deleted the consensusparams-receivedblocktransactions branch June 25, 2017 06:36
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request May 21, 2019
…ions()

25660e9 pass Consensus::Params& to ReceivedBlockTransactions() (Mario Dian)

Tree-SHA512: d3a5b19d93313e4bda622b322bc9cbfb7e31486010eac40fca6eea9703f814f9667f778122ba7366bb304482a2c03e2e3325083beecac374751692361952e467
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request May 22, 2019
…ions()

25660e9 pass Consensus::Params& to ReceivedBlockTransactions() (Mario Dian)

Tree-SHA512: d3a5b19d93313e4bda622b322bc9cbfb7e31486010eac40fca6eea9703f814f9667f778122ba7366bb304482a2c03e2e3325083beecac374751692361952e467
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request May 22, 2019
…ions()

25660e9 pass Consensus::Params& to ReceivedBlockTransactions() (Mario Dian)

Tree-SHA512: d3a5b19d93313e4bda622b322bc9cbfb7e31486010eac40fca6eea9703f814f9667f778122ba7366bb304482a2c03e2e3325083beecac374751692361952e467
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request May 22, 2019
…ions()

25660e9 pass Consensus::Params& to ReceivedBlockTransactions() (Mario Dian)

Tree-SHA512: d3a5b19d93313e4bda622b322bc9cbfb7e31486010eac40fca6eea9703f814f9667f778122ba7366bb304482a2c03e2e3325083beecac374751692361952e467
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request May 23, 2019
…ions()

25660e9 pass Consensus::Params& to ReceivedBlockTransactions() (Mario Dian)

Tree-SHA512: d3a5b19d93313e4bda622b322bc9cbfb7e31486010eac40fca6eea9703f814f9667f778122ba7366bb304482a2c03e2e3325083beecac374751692361952e467
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request May 23, 2019
…ions()

25660e9 pass Consensus::Params& to ReceivedBlockTransactions() (Mario Dian)

Tree-SHA512: d3a5b19d93313e4bda622b322bc9cbfb7e31486010eac40fca6eea9703f814f9667f778122ba7366bb304482a2c03e2e3325083beecac374751692361952e467
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request May 28, 2019
…ions()

25660e9 pass Consensus::Params& to ReceivedBlockTransactions() (Mario Dian)

Tree-SHA512: d3a5b19d93313e4bda622b322bc9cbfb7e31486010eac40fca6eea9703f814f9667f778122ba7366bb304482a2c03e2e3325083beecac374751692361952e467
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request May 28, 2019
…ions()

25660e9 pass Consensus::Params& to ReceivedBlockTransactions() (Mario Dian)

Tree-SHA512: d3a5b19d93313e4bda622b322bc9cbfb7e31486010eac40fca6eea9703f814f9667f778122ba7366bb304482a2c03e2e3325083beecac374751692361952e467
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request May 28, 2019
…on.cpp and make them static

24980a3 Make functions in validation.cpp static and pass chainparams (Mario Dian)

Tree-SHA512: 2d1b7b0ffd851317ed522911c1b6592855376c5cbc65d71ec0f8aa507eb6caef21b0709b3692255f1d719662db7447579c10df02f6ef4cd35fcb0bdf2e653af6
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 8, 2019
…on.cpp and make them static

24980a3 Make functions in validation.cpp static and pass chainparams (Mario Dian)

Tree-SHA512: 2d1b7b0ffd851317ed522911c1b6592855376c5cbc65d71ec0f8aa507eb6caef21b0709b3692255f1d719662db7447579c10df02f6ef4cd35fcb0bdf2e653af6
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 8, 2019
…on.cpp and make them static

24980a3 Make functions in validation.cpp static and pass chainparams (Mario Dian)

Tree-SHA512: 2d1b7b0ffd851317ed522911c1b6592855376c5cbc65d71ec0f8aa507eb6caef21b0709b3692255f1d719662db7447579c10df02f6ef4cd35fcb0bdf2e653af6

fix

Signed-off-by: Pasta <Pasta@dash.org>

add param

Signed-off-by: Pasta <Pasta@dash.org>
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 10, 2019
…on.cpp and make them static

24980a3 Make functions in validation.cpp static and pass chainparams (Mario Dian)

Tree-SHA512: 2d1b7b0ffd851317ed522911c1b6592855376c5cbc65d71ec0f8aa507eb6caef21b0709b3692255f1d719662db7447579c10df02f6ef4cd35fcb0bdf2e653af6

fix

Signed-off-by: Pasta <Pasta@dash.org>

add param

Signed-off-by: Pasta <Pasta@dash.org>
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 10, 2019
…on.cpp and make them static

24980a3 Make functions in validation.cpp static and pass chainparams (Mario Dian)

Tree-SHA512: 2d1b7b0ffd851317ed522911c1b6592855376c5cbc65d71ec0f8aa507eb6caef21b0709b3692255f1d719662db7447579c10df02f6ef4cd35fcb0bdf2e653af6

fix

Signed-off-by: Pasta <Pasta@dash.org>

add param

Signed-off-by: Pasta <Pasta@dash.org>
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 10, 2019
…on.cpp and make them static

24980a3 Make functions in validation.cpp static and pass chainparams (Mario Dian)

Tree-SHA512: 2d1b7b0ffd851317ed522911c1b6592855376c5cbc65d71ec0f8aa507eb6caef21b0709b3692255f1d719662db7447579c10df02f6ef4cd35fcb0bdf2e653af6

fix

Signed-off-by: Pasta <Pasta@dash.org>

add param

Signed-off-by: Pasta <Pasta@dash.org>
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 11, 2019
…on.cpp and make them static

24980a3 Make functions in validation.cpp static and pass chainparams (Mario Dian)

Tree-SHA512: 2d1b7b0ffd851317ed522911c1b6592855376c5cbc65d71ec0f8aa507eb6caef21b0709b3692255f1d719662db7447579c10df02f6ef4cd35fcb0bdf2e653af6

fix

Signed-off-by: Pasta <Pasta@dash.org>

add param

Signed-off-by: Pasta <Pasta@dash.org>
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 11, 2019
…on.cpp and make them static

24980a3 Make functions in validation.cpp static and pass chainparams (Mario Dian)

Tree-SHA512: 2d1b7b0ffd851317ed522911c1b6592855376c5cbc65d71ec0f8aa507eb6caef21b0709b3692255f1d719662db7447579c10df02f6ef4cd35fcb0bdf2e653af6

fix

Signed-off-by: Pasta <Pasta@dash.org>

add param

Signed-off-by: Pasta <Pasta@dash.org>
barrystyle pushed a commit to PACGlobalOfficial/PAC that referenced this pull request Jan 22, 2020
…on.cpp and make them static

24980a3 Make functions in validation.cpp static and pass chainparams (Mario Dian)

Tree-SHA512: 2d1b7b0ffd851317ed522911c1b6592855376c5cbc65d71ec0f8aa507eb6caef21b0709b3692255f1d719662db7447579c10df02f6ef4cd35fcb0bdf2e653af6

fix

Signed-off-by: Pasta <Pasta@dash.org>

add param

Signed-off-by: Pasta <Pasta@dash.org>
@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.

7 participants