Skip to content
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

internal: get pending and queued transaction by address #22992

Merged
merged 3 commits into from
Jul 13, 2021

Conversation

markya0616
Copy link
Contributor

We can call Content() to get all pending and queued transactions, but the response is really large...
This pull request implements an API to filter the pending/queued transactions by an address.

Copy link
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

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

This seems very wasteful to retrieve all that data just to throw away most of it. I think if you wanted to get thins functionality in, we should add a PendingFrom and QueuedFrom into the txpool where we can retrieve only the data we need.

@karalabe
Copy link
Member

karalabe commented Jun 4, 2021

Or to keep it consistent with te current API, ContentFrom

@markya0616
Copy link
Contributor Author

@karalabe Thanks for your review. The PR is updated.

internal/ethapi/api.go Outdated Show resolved Hide resolved
Comment on lines 147 to 148
"pending": make(map[string]*RPCTransaction),
"queued": make(map[string]*RPCTransaction),
Copy link
Contributor

Choose a reason for hiding this comment

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

You re-make these later on, so these one just get overwritten

@holiman
Copy link
Contributor

holiman commented Jun 7, 2021

Looking at it a bit more closely, I think this is what Peter meant. When you call TxpoolContent, it goes down into this method:

func (pool *TxPool) Content() (map[common.Address]types.Transactions, map[common.Address]types.Transactions) {
	pool.mu.Lock()
	defer pool.mu.Unlock()

	pending := make(map[common.Address]types.Transactions)
	for addr, list := range pool.pending {
		pending[addr] = list.Flatten()
	}
	queued := make(map[common.Address]types.Transactions)
	for addr, list := range pool.queue {
		queued[addr] = list.Flatten()
	}
	return pending, queued
}

You could instead define a new method which doesn't even bother with all the addresses that aren't what you're looking for, and save a lot of work.

@markya0616
Copy link
Contributor Author

@holiman, thanks for your review. I refined my PR based on your comments. :)

Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!
(caveat: I haven't tested it yet)

@markya0616
Copy link
Contributor Author

@karalabe Do you have any thoughts about this PR?

1 similar comment
@markya0616
Copy link
Contributor Author

@karalabe Do you have any thoughts about this PR?

@karalabe karalabe added this to the 1.10.5 milestone Jul 13, 2021
Copy link
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

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

LGTM

@karalabe karalabe merged commit c49e065 into ethereum:master Jul 13, 2021
sidhujag pushed a commit to sidhujag/go-ethereum that referenced this pull request Jul 28, 2021
* core, eth, internal, les, light: get pending and queued transaction by address

* core: tiny nitpick fixes

* light: tiny nitpick

Co-authored-by: mark <mark@amis.com>
Co-authored-by: Péter Szilágyi <peterke@gmail.com>
atif-konasl pushed a commit to frozeman/pandora-execution-engine that referenced this pull request Oct 15, 2021
* core, eth, internal, les, light: get pending and queued transaction by address

* core: tiny nitpick fixes

* light: tiny nitpick

Co-authored-by: mark <mark@amis.com>
Co-authored-by: Péter Szilágyi <peterke@gmail.com>
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Aug 26, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Aug 26, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 2, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 6, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 9, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 9, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 9, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 12, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 12, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 19, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 19, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 19, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 21, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 22, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 22, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 23, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 23, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 26, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 26, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 27, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 9, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 17, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 18, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 25, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 25, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 29, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 30, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 31, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 31, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants