In the interactive JavaScript console of geth, I have added some JS snippets(filters) through the loadScript() command and I need to remove/stop executing those filters. Is there any way to do this without restarting the geth instance?

I have the following filters loaded. None of them contain a watch function:

  1. A filter to mine only when there are pending transactions.
  2. A filter to check if a transaction was directed to a specific account and print some details.

Is there a way to identify and start/stop these filters?

  • I wish you had elaborated how /what is your filter about, it would have helped,however I have given and answer @varm – Abhiram mishra Jun 30 '16 at 13:53
  • Added more details @TheNeoNoirDeveloper – galahad Jun 30 '16 at 14:13

Yes,You could use the stopWatching() function to each of the filters when you want them to stop functioning.

var filter = <your filter code>;
//now you want to stop them being functional

Will do what you want.

Running eth.filter() command on the JavaScript console gives a list of all the filters along with the unique filterIDs. The stopWatching() function can be invoked with each of those filterIDs to disable that filter.

  • Thank you. But my filters do not have a watch function. Even if there was a watch function, how would I identify each filter and stop it if there are multiple filters? – galahad Jun 30 '16 at 13:56
  • Even if you don't have a watch associated, the stopWatching() would invalidate your filter @varm. And each filter has a property called filterId, much like an address. For a developer he could create a map of filters and run through each of them and invoke stopWatching() on each to make them invalidate. – Abhiram mishra Jun 30 '16 at 14:08
  • Updated the answer @varm and see my earlier comment on filter id – Abhiram mishra Jun 30 '16 at 14:19
  • 1
    Is there any command/option to set/get the filterID? – galahad Jul 11 '16 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.