-
Notifications
You must be signed in to change notification settings - Fork 592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chain: optimize mempool memory usage for RPC clients #896
Conversation
If we can use `gettxspendingprevout` to check the mempool spend of an input, there's no need to maintain the large `inputs` map anymore.
This commit creates a new method `getTxSpendingPrevOut` that's used by both ZMQ and RPC clients to lookup mempool spend for a given input.
dfe82b8
to
f2da461
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🐠
@@ -236,6 +247,11 @@ func (m *mempool) containsTx(hash chainhash.Hash) bool { | |||
// | |||
// NOTE: must be used inside a lock. | |||
func (m *mempool) containsInput(op wire.OutPoint) (chainhash.Hash, bool) { | |||
// TODO(yy): port `getprevout` to bitcoind and use it here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this occur on a higher level rn? Or you mean pulling down that check into the mempool logic itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so mempool already has an rpc client in m.cfg.client
, which can be used to call the rpc method. If we use it here, then both zmq and rpc clients can use this containsInput
to do the lookup without checking hasPrevRPC
flag.
chain: optimize mempool memory usage for RPC clients
chain: optimize mempool memory usage for RPC clients
This PR makes the RPC client to use
gettxspendingprevout
to look up mempool spend for a given output, such that the internalinputs
can be removed, which can save us quite some memory usage.