mirror of
https://github.com/Qortal/qortal.git
synced 2025-04-23 19:37:51 +00:00
Make sure to set Peer.isDataPeer() to false as well as true, to prevent bugs due to object reuse.
Also designate a peer as a "data peer" when making an outbound connection to request data from it.
This commit is contained in:
parent
1d7203a6fb
commit
aaa0b25106
@ -338,6 +338,7 @@ public class Network {
|
|||||||
// Add this signature to the list of pending requests for this peer
|
// Add this signature to the list of pending requests for this peer
|
||||||
LOGGER.info("Making connection to peer {} to request files for signature {}...", peerAddressString, Base58.encode(signature));
|
LOGGER.info("Making connection to peer {} to request files for signature {}...", peerAddressString, Base58.encode(signature));
|
||||||
Peer peer = new Peer(peerData);
|
Peer peer = new Peer(peerData);
|
||||||
|
peer.setIsDataPeer(true);
|
||||||
peer.addPendingSignatureRequest(signature);
|
peer.addPendingSignatureRequest(signature);
|
||||||
return this.connectPeer(peer);
|
return this.connectPeer(peer);
|
||||||
// If connection (and handshake) is successful, data will automatically be requested
|
// If connection (and handshake) is successful, data will automatically be requested
|
||||||
@ -698,6 +699,7 @@ public class Network {
|
|||||||
// Pick candidate
|
// Pick candidate
|
||||||
PeerData peerData = peers.get(peerIndex);
|
PeerData peerData = peers.get(peerIndex);
|
||||||
Peer newPeer = new Peer(peerData);
|
Peer newPeer = new Peer(peerData);
|
||||||
|
newPeer.setIsDataPeer(false);
|
||||||
|
|
||||||
// Update connection attempt info
|
// Update connection attempt info
|
||||||
peerData.setLastAttempted(now);
|
peerData.setLastAttempted(now);
|
||||||
|
@ -121,9 +121,9 @@ public class ChannelAcceptTask implements Task {
|
|||||||
|
|
||||||
newPeer = new Peer(socketChannel);
|
newPeer = new Peer(socketChannel);
|
||||||
if (isDataPeer) {
|
if (isDataPeer) {
|
||||||
newPeer.setIsDataPeer(true);
|
|
||||||
newPeer.setMaxConnectionAge(Settings.getInstance().getMaxDataPeerConnectionTime() * 1000L);
|
newPeer.setMaxConnectionAge(Settings.getInstance().getMaxDataPeerConnectionTime() * 1000L);
|
||||||
}
|
}
|
||||||
|
newPeer.setIsDataPeer(isDataPeer);
|
||||||
network.addConnectedPeer(newPeer);
|
network.addConnectedPeer(newPeer);
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user