Bitcoin Forum
May 23, 2018, 07:16:38 PM *
News: Latest stable version of Bitcoin Core: 0.16.0  [Torrent]. (New!)
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Q: How removing transactions from mempool works  (Read 930 times)
1t0ph20
Newbie
*
Offline Offline

Activity: 16
Merit: 0


View Profile
April 07, 2017, 05:22:02 PM
 #1

Hello!

Quick question: A block is solved and propagated through the network. When a node validates a block, it must remove the valid transactions out of its mempool.

Is this "removal" process a linear operation? Meaning if you need to remove 1000 txns included in the block from 14000 txns in your mempool, you need to search through worst case all 140000 txns?
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1527102998
Hero Member
*
Offline Offline

Posts: 1527102998

View Profile Personal Message (Offline)

Ignore
1527102998
Reply with quote  #2

1527102998
Report to moderator
1527102998
Hero Member
*
Offline Offline

Posts: 1527102998

View Profile Personal Message (Offline)

Ignore
1527102998
Reply with quote  #2

1527102998
Report to moderator
achow101
Moderator
Legendary
*
Offline Offline

Activity: 1414
Merit: 1329


3F1Y9yquzvY6RWvKbw2n2zeo9V5mvBhADU


View Profile WWW
April 07, 2017, 05:35:01 PM
 #2

The mempool does not have a defined structure; it depends entirely on how you implement it. You can implement it poorly and have it be very inefficient, or implement it well and have it be very efficient.

The way that Bitcoin Core implements the mempool can be found here (along with a big comment describing what is going on): https://github.com/bitcoin/bitcoin/blob/86f7d5b69bb72b85d71c32329cc43e80897ce348/src/txmempool.h#L330

1t0ph20
Newbie
*
Offline Offline

Activity: 16
Merit: 0


View Profile
April 07, 2017, 05:53:12 PM
 #3

I see.

So if you receive a block that has a transaction in it that was not in your mempool but was included in the block, does that transaction get added to your mempool and then shortly removed once you finish validating the block?

achow101
Moderator
Legendary
*
Offline Offline

Activity: 1414
Merit: 1329


3F1Y9yquzvY6RWvKbw2n2zeo9V5mvBhADU


View Profile WWW
April 07, 2017, 06:09:46 PM
 #4

I see.

So if you receive a block that has a transaction in it that was not in your mempool but was included in the block, does that transaction get added to your mempool and then shortly removed once you finish validating the block?
No, that would be unnecessary.

Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!