ethereum / go-ethereum

Go implementation of the Ethereum protocol
https://geth.ethereum.org
GNU Lesser General Public License v3.0
47.45k stars 20.08k forks source link

Feature request: EthClient support for SubscribePendingTransactions #19607

Closed Sexual closed 5 years ago

Sexual commented 5 years ago

There is a comment with a "todo" for this. Any plans on implementing it?

adamschmideg commented 5 years ago

Referring to https://github.com/ethereum/go-ethereum/blob/master/ethclient/ethclient.go#L444

holiman commented 5 years ago

No, no plans on that. It's very unclear what the caller would expect. Transactions are internally shuffled between pending and queued quite a lot, and at any time a couple of hundred transactions may be moved from one to the other. and then back again a few seconds later.

Or is the caller interested in the transactions from the next pending block? Those are re-evaluated about every three seconds, and not really nice either.

So, no. Do you have a usecase that you want support for? If so, please elaborate.

Sexual commented 5 years ago

@holiman To simplify our use case, we want to detect when an address receives a transaction/payment before it has confirmed.

Currently, our JS implementation uses web3.eth.filter('pending'), but the new version utilizes Go. We've tried a "hacky" implementation using the below function, and whilst it seemed to work on the Ropsten network, on the main net it would be really delayed.

func (ec *Client) SubscribePendingTransactions(ctx context.Context, ch chan<- string) (ethereum.Subscription, error) {
    return ec.c.EthSubscribe(ctx, ch, "newPendingTransactions")
}
karalabe commented 5 years ago

There are a few interesting corner cases here that we'd need to consider:

no-response[bot] commented 5 years ago

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have more relevant information or answers to our questions so that we can investigate further.