mirror of
https://github.com/status-im/ethereumj-personal.git
synced 2025-02-17 22:27:13 +00:00
implement EthereumListenerAdapter for Block / Transaction filter.
This commit is contained in:
parent
ee842e3a81
commit
50ee6adb5b
@ -113,7 +113,7 @@ public final class JsonRpcServer {
|
|||||||
this.dispatcher.register(new shh_getFilterChanges(this.ethereum));
|
this.dispatcher.register(new shh_getFilterChanges(this.ethereum));
|
||||||
this.dispatcher.register(new shh_getMessages(this.ethereum));
|
this.dispatcher.register(new shh_getMessages(this.ethereum));
|
||||||
|
|
||||||
FilterManager.getInstance();
|
ethereum.addListener(FilterManager.getInstance());
|
||||||
org.ethereum.android.jsonrpc.whisper.FilterManager.getInstance();
|
org.ethereum.android.jsonrpc.whisper.FilterManager.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,19 +2,21 @@ package org.ethereum.android.jsonrpc.filter;
|
|||||||
|
|
||||||
import net.minidev.json.JSONArray;
|
import net.minidev.json.JSONArray;
|
||||||
|
|
||||||
|
import org.ethereum.core.Block;
|
||||||
|
import org.ethereum.core.Transaction;
|
||||||
|
import org.ethereum.core.TransactionReceipt;
|
||||||
import org.ethereum.facade.Ethereum;
|
import org.ethereum.facade.Ethereum;
|
||||||
|
import org.ethereum.listener.EthereumListenerAdapter;
|
||||||
|
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/*
|
public class FilterManager extends EthereumListenerAdapter {
|
||||||
This class must receive notification from -core about new log, Block, Transaction. Right now I not see the way todo that.
|
|
||||||
TODO: ask advice from Roman about how to send notification to this class.
|
|
||||||
*/
|
|
||||||
public class FilterManager {
|
|
||||||
|
|
||||||
protected static FilterManager instance = null;
|
protected static FilterManager instance = null;
|
||||||
|
|
||||||
@ -49,7 +51,19 @@ public class FilterManager {
|
|||||||
}, TimeUnit.MINUTES.toMillis(1));
|
}, TimeUnit.MINUTES.toMillis(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processEvent(Object data) {
|
@Override
|
||||||
|
public void onBlock(Block block, List<TransactionReceipt> receipts) {
|
||||||
|
processEvent(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPendingTransactionsReceived(Set<Transaction> transactions) {
|
||||||
|
for(Transaction tx : transactions) {
|
||||||
|
processEvent(tx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processEvent(Object data) {
|
||||||
synchronized (filters) {
|
synchronized (filters) {
|
||||||
for (Map.Entry<Integer, FilterBase> item : filters.entrySet()) {
|
for (Map.Entry<Integer, FilterBase> item : filters.entrySet()) {
|
||||||
item.getValue().processEvent(data);
|
item.getValue().processEvent(data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user