mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-14 11:15:51 +00:00
Fix bug in FetchBlock introduced by peergroup merge
This commit is contained in:
parent
71931ccb76
commit
f68edc80cc
@ -69,6 +69,14 @@ public class Peer {
|
|||||||
this.eventListeners = new ArrayList<PeerEventListener>();
|
this.eventListeners = new ArrayList<PeerEventListener>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a peer that handles the given network connection and reads/writes from the given block chain. Note that
|
||||||
|
* communication won't occur until you call connect().
|
||||||
|
*/
|
||||||
|
public Peer(NetworkParameters params, PeerAddress address, BlockChain blockChain) {
|
||||||
|
this(params, address, 0, blockChain);
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void addEventListener(PeerEventListener listener) {
|
public synchronized void addEventListener(PeerEventListener listener) {
|
||||||
eventListeners.add(listener);
|
eventListeners.add(listener);
|
||||||
}
|
}
|
||||||
|
@ -29,12 +29,18 @@ import java.util.concurrent.Future;
|
|||||||
public class FetchBlock {
|
public class FetchBlock {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
System.out.println("Connecting to node");
|
System.out.println("Connecting to node");
|
||||||
final NetworkParameters params = NetworkParameters.prodNet();
|
final NetworkParameters params = NetworkParameters.testNet();
|
||||||
NetworkConnection conn = new NetworkConnection(InetAddress.getLocalHost(), params, 0, 60000);
|
|
||||||
BlockStore blockStore = new MemoryBlockStore(params);
|
BlockStore blockStore = new MemoryBlockStore(params);
|
||||||
BlockChain chain = new BlockChain(params, blockStore);
|
BlockChain chain = new BlockChain(params, blockStore);
|
||||||
Peer peer = new Peer(params, conn, chain);
|
final Peer peer = new Peer(params, new PeerAddress(InetAddress.getLocalHost()), chain);
|
||||||
peer.start();
|
peer.connect();
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
peer.run();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
|
||||||
Sha256Hash blockHash = new Sha256Hash(args[0]);
|
Sha256Hash blockHash = new Sha256Hash(args[0]);
|
||||||
Future<Block> future = peer.getBlock(blockHash);
|
Future<Block> future = peer.getBlock(blockHash);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user