Skip to content

Conversation

morcos
Copy link
Contributor

@morcos morcos commented Jun 16, 2015

The GetPriority calculation in CTxMemPoolEntry is incorrect. Instead of a more complicated and extensive fix which may be unnecessary, just rename the function and document its current behavior.

@laanwj
Copy link
Member

laanwj commented Jun 17, 2015

Thanks, better documentation is always welcome.
utACK.

@jonasschnelli
Copy link
Contributor

utACK.

Short, unclear variable- and function names and missing comments are probably one of the main obstacle for new contributors to better understand the code.

@luke-jr
Copy link
Member

luke-jr commented Jun 23, 2015

I didn't understand these comments... until I read the code. Not sure how to make it clearer, though.

@penguin1333
Copy link

@luke-jr Same story here.

@ashleyholman
Copy link
Contributor

I just realised this bug effects my pull request #6331 because I am relying on GetPriority() to give correct results.

How about fixing the bug? I don't think it needs a complicated fix. Just change GetPriority to calculate the priority of each of the inputs. For unconfirmed inputs, they count as 0. It's a more expensive calculation than the current method, but with my PR the calculation call will only need to be done once each time the active chain changes, and then the result is cached in CTxMemPoolEntry.

I'm happy to include a fix in my PR if people agree.

@morcos
Copy link
Contributor Author

morcos commented Jun 25, 2015

Hmm. I actually think that would be too expensive to do it directly. I had an idea for how to keep an on-the-fly calculation that would be more efficient. I wouldn't mind implementing it or suggesting it for you to implement, but the big IF here is whether all this complication is necessary. Even if this priority calculation were cheap, is looping the entire mempool on every block to update priorities something we actually want to do?

I'd be more in favor of ditching the priority sorting and free transaction inclusion policy altogether. I'm not sure what purpose it serves especially as blocks are closer to getting full.

@ashleyholman
Copy link
Contributor

edit: I get your point now.. dropping the priority calculation altogether would definitely simplify things.

Aside from that.. what was your idea for more efficient on-the-fly priority calculation? I had thought about using the current 'delta' technique but making it correct by tracking the confirmation state of the inputs, but that sounds quite complex to implement.

Intuitively I thought that a recalcing the priorities of all mempool inputs would be fairly fast, but I'll measure it on my crappy vm-inside-old-macbook and see how long it takes.

@morcos
Copy link
Contributor Author

morcos commented Jun 30, 2015

@ashleyholman. yes that was my idea. when a block comes in, you know which transactions in the mempool depend on each of the newly confirmed transactions, so you can just go update the current priority of those transactions and give them a new calculated priority, the height it was calculated at, and new delta for future priorities. Maybe I'll take a pass at it...

@morcos
Copy link
Contributor Author

morcos commented Jun 30, 2015

@ashleyholman See #6357 for what I had in mind....

@morcos
Copy link
Contributor Author

morcos commented Nov 14, 2015

Closing this in favor of at least #7008

@morcos morcos closed this Nov 14, 2015
@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.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants