Bitcoin Forum
May 08, 2024, 02:55:48 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Q: How removing transactions from mempool works  (Read 1026 times)
1t0ph20 (OP)
Newbie
*
Offline Offline

Activity: 16
Merit: 7


View Profile
April 07, 2017, 05:22:02 PM
Merited by ABCbits (1)
 #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.
1715180148
Hero Member
*
Offline Offline

Posts: 1715180148

View Profile Personal Message (Offline)

Ignore
1715180148
Reply with quote  #2

1715180148
Report to moderator
1715180148
Hero Member
*
Offline Offline

Posts: 1715180148

View Profile Personal Message (Offline)

Ignore
1715180148
Reply with quote  #2

1715180148
Report to moderator
1715180148
Hero Member
*
Offline Offline

Posts: 1715180148

View Profile Personal Message (Offline)

Ignore
1715180148
Reply with quote  #2

1715180148
Report to moderator
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3388
Merit: 6631


Just writing some code


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 (OP)
Newbie
*
Offline Offline

Activity: 16
Merit: 7


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
*
expert
Offline Offline

Activity: 3388
Merit: 6631


Just writing some code


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:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!