mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-11-02 05:27:17 +00:00
Restore some deprecated backwards compatibility glue for the event listener changes.
This commit is contained in:
@@ -17,26 +17,18 @@
|
||||
|
||||
package org.bitcoinj.core;
|
||||
|
||||
import org.bitcoinj.core.listeners.NewBestBlockListener;
|
||||
import org.bitcoinj.core.listeners.ReorganizeListener;
|
||||
import org.bitcoinj.core.listeners.TransactionReceivedInBlockListener;
|
||||
import org.bitcoinj.store.BlockStore;
|
||||
import org.bitcoinj.store.BlockStoreException;
|
||||
import org.bitcoinj.utils.ListenerRegistration;
|
||||
import org.bitcoinj.utils.Threading;
|
||||
import org.bitcoinj.utils.VersionTally;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.google.common.util.concurrent.SettableFuture;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.google.common.base.*;
|
||||
import com.google.common.collect.*;
|
||||
import com.google.common.util.concurrent.*;
|
||||
import org.bitcoinj.core.listeners.*;
|
||||
import org.bitcoinj.store.*;
|
||||
import org.bitcoinj.utils.*;
|
||||
import org.slf4j.*;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.locks.*;
|
||||
|
||||
import static com.google.common.base.Preconditions.*;
|
||||
|
||||
@@ -208,6 +200,27 @@ public abstract class AbstractBlockChain {
|
||||
removeTransactionReceivedListener(wallet);
|
||||
}
|
||||
|
||||
/** Replaced with more specific listener methods: use them instead. */
|
||||
@Deprecated @SuppressWarnings("deprecation")
|
||||
public void addListener(BlockChainListener listener) {
|
||||
addListener(listener, Threading.USER_THREAD);
|
||||
}
|
||||
|
||||
/** Replaced with more specific listener methods: use them instead. */
|
||||
@Deprecated
|
||||
public void addListener(BlockChainListener listener, Executor executor) {
|
||||
addReorganizeListener(executor, listener);
|
||||
addNewBestBlockListener(executor, listener);
|
||||
addTransactionReceivedListener(executor, listener);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void removeListener(BlockChainListener listener) {
|
||||
removeReorganizeListener(listener);
|
||||
removeNewBestBlockListener(listener);
|
||||
removeTransactionReceivedListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a {@link NewBestBlockListener} listener to the chain.
|
||||
*/
|
||||
|
||||
@@ -18,9 +18,8 @@ package org.bitcoinj.core;
|
||||
|
||||
import com.google.common.base.*;
|
||||
import com.google.common.base.Objects;
|
||||
import org.bitcoinj.core.listeners.*;
|
||||
import org.bitcoinj.net.StreamConnection;
|
||||
import org.bitcoinj.core.listeners.PeerConnectionEventListener;
|
||||
import org.bitcoinj.core.listeners.PeerDataEventListener;
|
||||
import org.bitcoinj.store.BlockStore;
|
||||
import org.bitcoinj.store.BlockStoreException;
|
||||
import org.bitcoinj.utils.ListenerRegistration;
|
||||
@@ -245,6 +244,26 @@ public class Peer extends PeerSocketHandler {
|
||||
this.versionMessage.appendToSubVer(thisSoftwareName, thisSoftwareVersion, null);
|
||||
}
|
||||
|
||||
/** Deprecated: use the more specific event handler methods instead */
|
||||
@Deprecated @SuppressWarnings("deprecation")
|
||||
public void addEventListener(AbstractPeerEventListener listener) {
|
||||
addEventListener(listener, Threading.USER_THREAD);
|
||||
}
|
||||
|
||||
/** Deprecated: use the more specific event handler methods instead */
|
||||
@Deprecated
|
||||
public void addEventListener(AbstractPeerEventListener listener, Executor executor) {
|
||||
addConnectionEventListener(executor, listener);
|
||||
addDataEventListener(executor, listener);
|
||||
}
|
||||
|
||||
/** Deprecated: use the more specific event handler methods instead */
|
||||
@Deprecated
|
||||
public void removeEventListener(AbstractPeerEventListener listener) {
|
||||
removeConnectionEventListener(listener);
|
||||
removeDataEventListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the given object as an event listener that will be invoked on the user thread. Note that listeners
|
||||
* added this way will <b>not</b> receive {@link PeerEventListener#getData(Peer, GetDataMessage)} or
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.bitcoinj.core.listeners;
|
||||
|
||||
import org.bitcoinj.core.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* For backwards compatibility only. Implements the block chain listener interfaces. Use the more specific interfaces
|
||||
* instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public class AbstractBlockChainListener implements BlockChainListener {
|
||||
@Override
|
||||
public void notifyNewBestBlock(StoredBlock block) throws VerificationException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reorganize(StoredBlock splitPoint, List<StoredBlock> oldBlocks, List<StoredBlock> newBlocks) throws VerificationException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveFromBlock(Transaction tx, StoredBlock block, BlockChain.NewBlockType blockType, int relativityOffset) throws VerificationException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean notifyTransactionIsInBlock(Sha256Hash txHash, StoredBlock block, BlockChain.NewBlockType blockType, int relativityOffset) throws VerificationException {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -16,15 +16,15 @@
|
||||
|
||||
package org.bitcoinj.core.listeners;
|
||||
|
||||
import org.bitcoinj.core.Peer;
|
||||
import java.util.Set;
|
||||
import org.bitcoinj.core.PeerAddress;
|
||||
import org.bitcoinj.core.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Convenience implementation of {@link PeerEventListener}.
|
||||
* 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
|
||||
|
||||
@@ -26,8 +26,9 @@ import javax.annotation.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Convenience implementation of {@link PeerEventListener}.
|
||||
* Deprecated: implement the more specific event listener interfaces instead to fill out only what you need
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class AbstractPeerDataEventListener implements PeerDataEventListener {
|
||||
@Override
|
||||
public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) {
|
||||
|
||||
@@ -28,8 +28,9 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Convenience implementation of {@link PeerEventListener}.
|
||||
* Deprecated: implement the more specific event listener interfaces instead to fill out only what you need
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class AbstractPeerEventListener extends AbstractPeerDataEventListener implements PeerConnectionEventListener {
|
||||
@Override
|
||||
public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) {
|
||||
|
||||
@@ -26,8 +26,9 @@ import org.bitcoinj.wallet.AbstractKeyChainEventListener;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Convenience implementation of {@link WalletEventListener}.
|
||||
* Deprecated: implement the more specific event listener interfaces instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class AbstractWalletEventListener extends AbstractKeyChainEventListener implements WalletEventListener {
|
||||
@Override
|
||||
public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package org.bitcoinj.core.listeners;
|
||||
|
||||
/**
|
||||
* Old interface for backwards compatibility. Implement the more specific interfaces instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface BlockChainListener extends NewBestBlockListener, TransactionReceivedInBlockListener, ReorganizeListener {
|
||||
}
|
||||
Reference in New Issue
Block a user