1

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?

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

1 Answer 1

2

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
 filter.stopWatching();

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.

4
  • 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
    Commented Jun 30, 2016 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. Commented Jun 30, 2016 at 14:08
  • Updated the answer @varm and see my earlier comment on filter id Commented Jun 30, 2016 at 14:19
  • 1
    Is there any command/option to set/get the filterID?
    – galahad
    Commented Jul 11, 2016 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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