mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-07 06:44:16 +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>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
eventListeners.add(listener);
|
||||
}
|
||||
|
@ -29,12 +29,18 @@ import java.util.concurrent.Future;
|
||||
public class FetchBlock {
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println("Connecting to node");
|
||||
final NetworkParameters params = NetworkParameters.prodNet();
|
||||
NetworkConnection conn = new NetworkConnection(InetAddress.getLocalHost(), params, 0, 60000);
|
||||
final NetworkParameters params = NetworkParameters.testNet();
|
||||
|
||||
BlockStore blockStore = new MemoryBlockStore(params);
|
||||
BlockChain chain = new BlockChain(params, blockStore);
|
||||
Peer peer = new Peer(params, conn, chain);
|
||||
peer.start();
|
||||
final Peer peer = new Peer(params, new PeerAddress(InetAddress.getLocalHost()), chain);
|
||||
peer.connect();
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
peer.run();
|
||||
}
|
||||
}).start();
|
||||
|
||||
Sha256Hash blockHash = new Sha256Hash(args[0]);
|
||||
Future<Block> future = peer.getBlock(blockHash);
|
||||
|
Loading…
Reference in New Issue
Block a user