3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-13 02:35:52 +00:00

Remove deprecated PeerConnectionEventListener.

Use PeerConnectedEventListener, PeerDiscoveredEventListener and PeerDisconnectedEventListener instead.
This commit is contained in:
Andreas Schildbach 2019-02-20 18:39:12 +01:00
parent 74e3c3306f
commit eaf7955436
4 changed files with 2 additions and 107 deletions

View File

@ -1,42 +0,0 @@
/*
* Copyright 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bitcoinj.core.listeners;
import org.bitcoinj.core.*;
import java.util.*;
/**
* Deprecated: implement the more specific event listener interfaces instead to fill out only what you need
*/
@Deprecated
public abstract class AbstractPeerConnectionEventListener implements PeerConnectionEventListener {
@Override
public void onPeersDiscovered(Set<PeerAddress> peerAddresses) {
// Do nothing
}
@Override
public void onPeerConnected(Peer peer, int peerCount) {
// Do nothing
}
@Override
public void onPeerDisconnected(Peer peer, int peerCount) {
// Do nothing
}
}

View File

@ -1,41 +0,0 @@
/*
* Copyright 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bitcoinj.core.listeners;
import org.bitcoinj.core.Peer;
import org.bitcoinj.core.PeerGroup;
/**
* <p>Implementors can listen to events like peer discovery, connect or disconnects.</p>
*
* @deprecated Use the single event interfaces instead
*/
@Deprecated
public interface PeerConnectionEventListener extends PeerConnectedEventListener,
PeerDiscoveredEventListener, PeerDisconnectedEventListener {
/**
* Called when a peer is disconnected. Note that this won't be called if the listener is registered on a
* {@link PeerGroup} and the group is in the process of shutting down. If this listener is registered to a
* {@link Peer} instead of a {@link PeerGroup}, peerCount will always be 0. This handler can be called without
* a corresponding invocation of onPeerConnected if the initial connection is never successful.
*
* @param peer
* @param peerCount the total number of connected peers
*/
void onPeerDisconnected(Peer peer, int peerCount);
}

View File

@ -28,7 +28,8 @@ import java.util.Set;
* this class using JNI on the native side, thus several instances of this can point to different actual
* native implementations.
*/
public class NativePeerEventListener implements PeerConnectionEventListener, PeerDataEventListener, OnTransactionBroadcastListener {
public class NativePeerEventListener implements PeerConnectedEventListener, PeerDiscoveredEventListener,
PeerDisconnectedEventListener, PeerDataEventListener, OnTransactionBroadcastListener {
public long ptr;
@Override

View File

@ -105,29 +105,6 @@ public class PeerTest extends TestWithNetworkConnections {
writeTarget = connect(peer, peerVersion);
}
@Test
public void testAddConnectedEventListener() throws Exception {
connect();
PeerConnectedEventListener listener = new AbstractPeerConnectionEventListener() {
};
assertFalse(peer.removeConnectedEventListener(listener));
peer.addConnectedEventListener(listener);
assertTrue(peer.removeConnectedEventListener(listener));
assertFalse(peer.removeConnectedEventListener(listener));
}
@Test
public void testAddDisconnectedEventListener() throws Exception {
connect();
PeerDisconnectedEventListener listener = new AbstractPeerConnectionEventListener() {
};
assertFalse(peer.removeDisconnectedEventListener(listener));
peer.addDisconnectedEventListener(listener);
assertTrue(peer.removeDisconnectedEventListener(listener));
assertFalse(peer.removeDisconnectedEventListener(listener));
}
// Check that it runs through the event loop and shut down correctly
@Test
public void shutdown() throws Exception {