mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-14 19:25:51 +00:00
Rename variable peers to peerGroup, as the name can be misleading.
This commit is contained in:
parent
e036f8174a
commit
c927f0238b
@ -61,12 +61,12 @@ public class RestoreFromSeed {
|
||||
// Setting up the BlochChain, the BlocksStore and connecting to the network.
|
||||
SPVBlockStore chainStore = new SPVBlockStore(params, chainFile);
|
||||
BlockChain chain = new BlockChain(params, chainStore);
|
||||
PeerGroup peers = new PeerGroup(params, chain);
|
||||
peers.addPeerDiscovery(new DnsDiscovery(params));
|
||||
PeerGroup peerGroup = new PeerGroup(params, chain);
|
||||
peerGroup.addPeerDiscovery(new DnsDiscovery(params));
|
||||
|
||||
// Now we need to hook the wallet up to the blockchain and the peers. This registers event listeners that notify our wallet about new transactions.
|
||||
chain.addWallet(wallet);
|
||||
peers.addWallet(wallet);
|
||||
peerGroup.addWallet(wallet);
|
||||
|
||||
DownloadProgressTracker bListener = new DownloadProgressTracker() {
|
||||
@Override
|
||||
@ -76,8 +76,8 @@ public class RestoreFromSeed {
|
||||
};
|
||||
|
||||
// Now we re-download the blockchain. This replays the chain into the wallet. Once this is completed our wallet should know of all its transactions and print the correct balance.
|
||||
peers.start();
|
||||
peers.startBlockChainDownload(bListener);
|
||||
peerGroup.start();
|
||||
peerGroup.startBlockChainDownload(bListener);
|
||||
|
||||
bListener.await();
|
||||
|
||||
@ -85,6 +85,6 @@ public class RestoreFromSeed {
|
||||
System.out.println(wallet.toString());
|
||||
|
||||
// shutting down again
|
||||
peers.stop();
|
||||
peerGroup.stop();
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public class WalletTool {
|
||||
private static File walletFile;
|
||||
private static BlockStore store;
|
||||
private static AbstractBlockChain chain;
|
||||
private static PeerGroup peers;
|
||||
private static PeerGroup peerGroup;
|
||||
private static Wallet wallet;
|
||||
private static File chainFileName;
|
||||
private static ValidationMode mode;
|
||||
@ -506,7 +506,7 @@ public class WalletTool {
|
||||
|
||||
private static void rotate() throws BlockStoreException {
|
||||
setup();
|
||||
peers.start();
|
||||
peerGroup.start();
|
||||
// Set a key rotation time and possibly broadcast the resulting maintenance transactions.
|
||||
long rotationTimeSecs = Utils.currentTimeSeconds();
|
||||
if (options.has(dateFlag)) {
|
||||
@ -633,13 +633,13 @@ public class WalletTool {
|
||||
}
|
||||
|
||||
setup();
|
||||
peers.start();
|
||||
peerGroup.start();
|
||||
// Wait for peers to connect, the tx to be sent to one of them and for it to be propagated across the
|
||||
// network. Once propagation is complete and we heard the transaction back from all our peers, it will
|
||||
// be committed to the wallet.
|
||||
peers.broadcastTransaction(t).future().get();
|
||||
peerGroup.broadcastTransaction(t).future().get();
|
||||
// Hack for regtest/single peer mode, as we're about to shut down and won't get an ACK from the remote end.
|
||||
List<Peer> peerList = peers.getConnectedPeers();
|
||||
List<Peer> peerList = peerGroup.getConnectedPeers();
|
||||
if (peerList.size() == 1)
|
||||
peerList.get(0).ping().get();
|
||||
} catch (BlockStoreException e) {
|
||||
@ -750,13 +750,13 @@ public class WalletTool {
|
||||
}
|
||||
|
||||
setup();
|
||||
peers.start();
|
||||
peerGroup.start();
|
||||
// Wait for peers to connect, the tx to be sent to one of them and for it to be propagated across the
|
||||
// network. Once propagation is complete and we heard the transaction back from all our peers, it will
|
||||
// be committed to the wallet.
|
||||
peers.broadcastTransaction(req.tx).future().get();
|
||||
peerGroup.broadcastTransaction(req.tx).future().get();
|
||||
// Hack for regtest/single peer mode, as we're about to shut down and won't get an ACK from the remote end.
|
||||
List<Peer> peerList = peers.getConnectedPeers();
|
||||
List<Peer> peerList = peerGroup.getConnectedPeers();
|
||||
if (peerList.size() == 1)
|
||||
peerList.get(0).ping().get();
|
||||
} catch (BlockStoreException e) {
|
||||
@ -856,13 +856,13 @@ public class WalletTool {
|
||||
}
|
||||
|
||||
setup();
|
||||
peers.start();
|
||||
peerGroup.start();
|
||||
// Wait for peers to connect, the tx to be sent to one of them and for it to be propagated across the
|
||||
// network. Once propagation is complete and we heard the transaction back from all our peers, it will
|
||||
// be committed to the wallet.
|
||||
peers.broadcastTransaction(req.tx).future().get();
|
||||
peerGroup.broadcastTransaction(req.tx).future().get();
|
||||
// Hack for regtest/single peer mode, as we're about to shut down and won't get an ACK from the remote end.
|
||||
List<Peer> peerList = peers.getConnectedPeers();
|
||||
List<Peer> peerList = peerGroup.getConnectedPeers();
|
||||
if (peerList.size() == 1)
|
||||
peerList.get(0).ping().get();
|
||||
} catch (BlockStoreException e) {
|
||||
@ -959,13 +959,13 @@ public class WalletTool {
|
||||
}
|
||||
|
||||
setup();
|
||||
peers.start();
|
||||
peerGroup.start();
|
||||
// Wait for peers to connect, the tx to be sent to one of them and for it to be propagated across the
|
||||
// network. Once propagation is complete and we heard the transaction back from all our peers, it will
|
||||
// be committed to the wallet.
|
||||
peers.broadcastTransaction(req.tx).future().get();
|
||||
peerGroup.broadcastTransaction(req.tx).future().get();
|
||||
// Hack for regtest/single peer mode, as we're about to shut down and won't get an ACK from the remote end.
|
||||
List<Peer> peerList = peers.getConnectedPeers();
|
||||
List<Peer> peerList = peerGroup.getConnectedPeers();
|
||||
if (peerList.size() == 1)
|
||||
peerList.get(0).ping().get();
|
||||
} catch (BlockStoreException e) {
|
||||
@ -1073,8 +1073,8 @@ public class WalletTool {
|
||||
ListenableFuture<PaymentProtocol.Ack> future = session.sendPayment(ImmutableList.of(req.tx), null, null);
|
||||
if (future == null) {
|
||||
// No payment_url for submission so, broadcast and wait.
|
||||
peers.start();
|
||||
peers.broadcastTransaction(req.tx).future().get();
|
||||
peerGroup.start();
|
||||
peerGroup.broadcastTransaction(req.tx).future().get();
|
||||
} else {
|
||||
PaymentProtocol.Ack ack = future.get();
|
||||
wallet.commitTx(req.tx);
|
||||
@ -1128,7 +1128,7 @@ public class WalletTool {
|
||||
break;
|
||||
|
||||
case BLOCK:
|
||||
peers.addBlocksDownloadedEventListener(new BlocksDownloadedEventListener() {
|
||||
peerGroup.addBlocksDownloadedEventListener(new BlocksDownloadedEventListener() {
|
||||
@Override
|
||||
public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) {
|
||||
// Check if we already ran. This can happen if a block being received triggers download of more
|
||||
@ -1154,8 +1154,8 @@ public class WalletTool {
|
||||
break;
|
||||
|
||||
}
|
||||
if (!peers.isRunning())
|
||||
peers.startAsync();
|
||||
if (!peerGroup.isRunning())
|
||||
peerGroup.startAsync();
|
||||
try {
|
||||
latch.await();
|
||||
} catch (InterruptedException e) {
|
||||
@ -1200,19 +1200,19 @@ public class WalletTool {
|
||||
}
|
||||
// This will ensure the wallet is saved when it changes.
|
||||
wallet.autosaveToFile(walletFile, 5, TimeUnit.SECONDS, null);
|
||||
if (peers == null) {
|
||||
peers = new PeerGroup(params, chain);
|
||||
if (peerGroup == null) {
|
||||
peerGroup = new PeerGroup(params, chain);
|
||||
}
|
||||
peers.setUserAgent("WalletTool", "1.0");
|
||||
peerGroup.setUserAgent("WalletTool", "1.0");
|
||||
if (params == RegTestParams.get())
|
||||
peers.setMinBroadcastConnections(1);
|
||||
peers.addWallet(wallet);
|
||||
peerGroup.setMinBroadcastConnections(1);
|
||||
peerGroup.addWallet(wallet);
|
||||
if (options.has("peers")) {
|
||||
String peersFlag = (String) options.valueOf("peers");
|
||||
String[] peerAddrs = peersFlag.split(",");
|
||||
for (String peer : peerAddrs) {
|
||||
try {
|
||||
peers.addAddress(new PeerAddress(params, InetAddress.getByName(peer)));
|
||||
peerGroup.addAddress(new PeerAddress(params, InetAddress.getByName(peer)));
|
||||
} catch (UnknownHostException e) {
|
||||
System.err.println("Could not understand peer domain name/IP address: " + peer + ": " + e.getMessage());
|
||||
System.exit(1);
|
||||
@ -1226,8 +1226,8 @@ public class WalletTool {
|
||||
setup();
|
||||
int startTransactions = wallet.getTransactions(true).size();
|
||||
DownloadProgressTracker listener = new DownloadProgressTracker();
|
||||
peers.start();
|
||||
peers.startBlockChainDownload(listener);
|
||||
peerGroup.start();
|
||||
peerGroup.startBlockChainDownload(listener);
|
||||
try {
|
||||
listener.await();
|
||||
} catch (InterruptedException e) {
|
||||
@ -1246,9 +1246,9 @@ public class WalletTool {
|
||||
|
||||
private static void shutdown() {
|
||||
try {
|
||||
if (peers == null) return; // setup() never called so nothing to do.
|
||||
if (peers.isRunning())
|
||||
peers.stop();
|
||||
if (peerGroup == null) return; // setup() never called so nothing to do.
|
||||
if (peerGroup.isRunning())
|
||||
peerGroup.stop();
|
||||
saveWallet(walletFile);
|
||||
store.close();
|
||||
wallet = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user