I know that the state of the txpool of a geth node can be queried using the txpool API. However, I was wondering if it is somehow possible to subscribe to new transactions entering a geth node's txpool, possibly on a websockets or local socket rpc connection? I'd like to write the program that subscribes to new txpool transactions in Go as well.
I discovered this subscription in go-ethereum internally, but it doesn't look like it's exposed, unfortunately.
Note that I'm not only talking about local pending transactions (answered here), but all transactions arriving to the txpool.
Background: I'd like to do research on frontrunning. The authors of the Flash Boys 2.0 paper released their geth fork on github, which they used to observe gas auctions in the txpool. However, using a fork is not as reusable and maintainable than having the possibility to extend geth's API so that external applications can subscribe to txpool udpates.
pendingTransactions
subscription on theethclient
API. It seems to be available (sometimes) wiht JS web3 though, see Eugene's answer.