blob: 7af6f56e77e81620657fed3e851779ea60dac5d1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
var Filter = function(options) {
this.callbacks = {};
this.seed = Math.floor(Math.random() * 1000000);
this.options = options;
eth.registerFilter(options, this.seed);
};
Filter.prototype.changed = function(callback) {
var cbseed = Math.floor(Math.random() * 1000000);
eth.registerFilterCallback(this.seed, cbseed);
var self = this;
message.connect(function(messages, seed, callbackSeed) {
if(seed == self.seed && callbackSeed == cbseed) {
callback.call(self, messages);
}
});
};
Filter.prototype.uninstall = function() {
eth.uninstallFilter(this.seed)
}
Filter.prototype.messages = function() {
return JSON.parse(eth.messages(this.options))
}
|