mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-15 11:45:51 +00:00
Peer: Make GetDataRequest immutable.
This commit is contained in:
parent
efc8eecd4c
commit
0d9b732e60
@ -137,8 +137,12 @@ public class Peer extends PeerSocketHandler {
|
|||||||
// When an API user explicitly requests a block or transaction from a peer, the InventoryItem is put here
|
// When an API user explicitly requests a block or transaction from a peer, the InventoryItem is put here
|
||||||
// whilst waiting for the response. Is not used for downloads Peer generates itself.
|
// whilst waiting for the response. Is not used for downloads Peer generates itself.
|
||||||
private static class GetDataRequest {
|
private static class GetDataRequest {
|
||||||
Sha256Hash hash;
|
public GetDataRequest(Sha256Hash hash, SettableFuture future) {
|
||||||
SettableFuture future;
|
this.hash = hash;
|
||||||
|
this.future = future;
|
||||||
|
}
|
||||||
|
final Sha256Hash hash;
|
||||||
|
final SettableFuture future;
|
||||||
}
|
}
|
||||||
// TODO: The types/locking should be rationalised a bit.
|
// TODO: The types/locking should be rationalised a bit.
|
||||||
private final CopyOnWriteArrayList<GetDataRequest> getDataFutures;
|
private final CopyOnWriteArrayList<GetDataRequest> getDataFutures;
|
||||||
@ -809,9 +813,7 @@ public class Peer extends PeerSocketHandler {
|
|||||||
log.info("{}: Requesting {} transactions for dep resolution", getAddress(), needToRequest.size());
|
log.info("{}: Requesting {} transactions for dep resolution", getAddress(), needToRequest.size());
|
||||||
for (Sha256Hash hash : needToRequest) {
|
for (Sha256Hash hash : needToRequest) {
|
||||||
getdata.addTransaction(hash);
|
getdata.addTransaction(hash);
|
||||||
GetDataRequest req = new GetDataRequest();
|
GetDataRequest req = new GetDataRequest(hash, SettableFuture.create());
|
||||||
req.hash = hash;
|
|
||||||
req.future = SettableFuture.create();
|
|
||||||
futures.add(req.future);
|
futures.add(req.future);
|
||||||
getDataFutures.add(req);
|
getDataFutures.add(req);
|
||||||
}
|
}
|
||||||
@ -1225,9 +1227,7 @@ public class Peer extends PeerSocketHandler {
|
|||||||
private ListenableFuture sendSingleGetData(GetDataMessage getdata) {
|
private ListenableFuture sendSingleGetData(GetDataMessage getdata) {
|
||||||
// This does not need to be locked.
|
// This does not need to be locked.
|
||||||
Preconditions.checkArgument(getdata.getItems().size() == 1);
|
Preconditions.checkArgument(getdata.getItems().size() == 1);
|
||||||
GetDataRequest req = new GetDataRequest();
|
GetDataRequest req = new GetDataRequest(getdata.getItems().get(0).hash, SettableFuture.create());
|
||||||
req.future = SettableFuture.create();
|
|
||||||
req.hash = getdata.getItems().get(0).hash;
|
|
||||||
getDataFutures.add(req);
|
getDataFutures.add(req);
|
||||||
sendMessage(getdata);
|
sendMessage(getdata);
|
||||||
return req.future;
|
return req.future;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user