Skip to content

Commit

Permalink
Deprecate RxJsonChainTipClient
Browse files Browse the repository at this point in the history
* Have RxBitcoinClient directly implement ChainTipService, RxJsonRpcClient
* Have PollingChainTipService directly implement ChainTipService, ChainTipClient, RxJsonRpcClient
* Have PollingChainTipServiceImpl directly implement ChainTipService
  • Loading branch information
msgilligan committed Sep 23, 2023
1 parent 95419e0 commit c90bb8c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
import io.reactivex.rxjava3.core.Maybe;
import io.reactivex.rxjava3.core.Observable;
import org.consensusj.bitcoin.json.pojo.ChainTip;
import org.consensusj.bitcoin.jsonrpc.ChainTipClient;
import org.consensusj.bitcoin.rx.ChainTipService;
import org.consensusj.rx.jsonrpc.RxJsonRpcClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

//TODO: Merge with PollingChainTipServiceImpl
/**
* Interface with {@link PollingChainTipService#pollForDistinctChainTip()} method.
*/
public interface PollingChainTipService extends RxJsonChainTipClient {
public interface PollingChainTipService extends ChainTipService, ChainTipClient, RxJsonRpcClient {
Logger log = LoggerFactory.getLogger(PollingChainTipService.class);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.reactivex.rxjava3.processors.BehaviorProcessor;
import io.reactivex.rxjava3.processors.FlowableProcessor;
import org.consensusj.bitcoin.jsonrpc.BitcoinClient;
import org.consensusj.bitcoin.rx.ChainTipService;
import org.consensusj.jsonrpc.JsonRpcStatusException;
import org.reactivestreams.Publisher;
import org.slf4j.Logger;
Expand All @@ -18,11 +19,12 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

//TODO: Merge with PollingChainTipService
/**
* Implementation of {@link PollingChainTipService} using a {@link BitcoinClient} and a polling interval.
* This can be used as a fallback if ZeroMQ is not available
*/
public class PollingChainTipServiceImpl implements Closeable, PollingChainTipService {
public class PollingChainTipServiceImpl implements ChainTipService, PollingChainTipService, Closeable {
private static final Logger log = LoggerFactory.getLogger(PollingChainTipServiceImpl.class);
private final BitcoinClient client;
private final Observable<Long> interval;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
import org.consensusj.bitcoin.jsonrpc.BitcoinExtendedClient;
import org.consensusj.bitcoin.rx.ChainTipService;
import org.consensusj.bitcoin.rx.zeromq.RxBitcoinZmqService;
import org.consensusj.rx.jsonrpc.RxJsonRpcClient;

import javax.net.ssl.SSLContext;
import java.net.URI;

/**
* A {@link BitcoinClient} enhanced with Reactive features. Can use either ZeroMQ or polling
* to implement {@link RxJsonChainTipClient}.
* to implement {@link ChainTipService}.
* <p>
* TODO: answer the below questions
* <p>
Expand All @@ -23,7 +24,7 @@
* Should this class be renamed to {@code RxBitcoinJsonRpcClient} and the {@code RxBitcoinClient} interface be moved
* to {@code cj-btc-rx?}
*/
public class RxBitcoinClient extends BitcoinExtendedClient implements RxJsonChainTipClient {
public class RxBitcoinClient extends BitcoinExtendedClient implements ChainTipService, RxJsonRpcClient {
private final ChainTipService chainTipService;

public RxBitcoinClient(Network network, URI server, String rpcuser, String rpcpassword) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.consensusj.bitcoin.rx.jsonrpc;

import io.reactivex.rxjava3.core.Flowable;
import org.consensusj.bitcoin.jsonrpc.ChainTipClient;
import org.consensusj.bitcoin.rx.ChainTipService;
import org.consensusj.jsonrpc.AsyncSupport;
import org.consensusj.rx.jsonrpc.RxJsonRpcClient;
Expand All @@ -12,7 +11,8 @@
/**
* A JSON-RPC client interface that provides ChainTipService
*/
public interface RxJsonChainTipClient extends ChainTipService, ChainTipClient, RxJsonRpcClient {
@Deprecated
public interface RxJsonChainTipClient extends ChainTipService, RxJsonRpcClient {

/**
* Repeatedly once-per-new-block poll a method
Expand Down

0 comments on commit c90bb8c

Please sign in to comment.