Skip to content

Commit

Permalink
Upgrade to ConsensusJ 0.7.0-alpha3
Browse files Browse the repository at this point in the history
* Use JsonRpcTransport.getDefaultSSLContext() to get default SSL context
* Reflect JsonRpcClient<JavaType> as base class for RPC clients
* ChainTipPublisher replaces Publisher<ChainTip>
* BTCTestSupport moved from Groovy to Java and changed package
  • Loading branch information
msgilligan committed Oct 6, 2023
1 parent b719e00 commit 77769b9
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Released: Forthcoming

The 0.7.0 release of **OmniJ** will require the forthcoming **ConsensusJ** 0.7.0 and **bitcoinj** v0.17 (currently in alpha release.) There will likely be multiple alpha releases of OmniJ and ConsensusJ as bitcoinj is updated.

=== Dependency Updates

* ConsensusJ 0.7.0-alpha3

=== Build/Test Updates

* Gradle 8.4
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ omnijVersion = 0.7.0-SNAPSHOT
useMavenLocal = false

bitcoinjVersion = 0.17-alpha2
consensusjVersion = 0.7.0-alpha2
consensusjVersion = 0.7.0-alpha3
slf4jVersion = 2.0.7
groovyVersion = 4.0.14
spockVersion = 2.3-groovy-4.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.consensusj.bitcoin.jsonrpc.bitcoind.BitcoinConfFile;
import org.consensusj.bitcoin.rx.jsonrpc.RxBitcoinClient;
import org.consensusj.jsonrpc.JsonRpcException;
import org.consensusj.jsonrpc.JsonRpcTransport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -60,15 +61,15 @@ public OmniClient(RpcConfig config) {
}

public OmniClient(Network network, URI server, String rpcuser, String rpcpassword) {
this(getDefaultSSLContext(), network, server, rpcuser, rpcpassword, false, false);
this(JsonRpcTransport.getDefaultSSLContext(), network, server, rpcuser, rpcpassword, false, false);
}

public OmniClient(SSLContext sslContext, Network network, URI server, String rpcuser, String rpcpassword, boolean useZmq) {
this(sslContext, network, server, rpcuser, rpcpassword, useZmq, false);
}

public OmniClient(Network network, URI server, String rpcuser, String rpcpassword, boolean useZmq, boolean isOmniProxy) {
this(getDefaultSSLContext(), network, server, rpcuser, rpcpassword, useZmq, isOmniProxy);
this(JsonRpcTransport.getDefaultSSLContext(), network, server, rpcuser, rpcpassword, useZmq, isOmniProxy);
}

public OmniClient(SSLContext sslContext, Network network, URI server, String rpcuser, String rpcpassword, boolean useZmq, boolean isOmniProxy) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.bitcoinj.base.AddressParser;
import org.bitcoinj.base.Sha256Hash;
import org.consensusj.analytics.service.TokenRichList;
import org.consensusj.jsonrpc.JacksonRpcClient;
import org.consensusj.jsonrpc.JsonRpcClient;
import org.consensusj.jsonrpc.JsonRpcException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -26,7 +26,7 @@
/**
* Interface with default methods implementing omniproxy RPCs.
*/
public interface OmniProxyMethods extends JacksonRpcClient {
public interface OmniProxyMethods extends JsonRpcClient<JavaType> {
Logger log = LoggerFactory.getLogger(OmniProxyMethods.class);
AddressParser addressParser = AddressParser.getDefault();

Expand All @@ -37,7 +37,7 @@ public interface OmniProxyMethods extends JacksonRpcClient {
boolean isOmniProxyServer();

private List<OmniPropertyInfo> omniProxyListPropertiesSync() throws IOException {
JavaType javaType = getMapper().getTypeFactory().constructCollectionType(List.class, OmniPropertyInfo.class);
JavaType javaType = collectionTypeForClasses(List.class, OmniPropertyInfo.class);
return send("omniproxy.listproperties", javaType);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import foundation.omni.rpc.OmniClient;
import org.consensusj.bitcoin.json.pojo.ChainTip;
import org.consensusj.bitcoin.json.pojo.bitcore.AddressBalanceInfo;
import org.consensusj.bitcoin.rx.ChainTipPublisher;
import org.consensusj.jsonrpc.JsonRpcException;
import org.consensusj.jsonrpc.JsonRpcStatusException;
import foundation.omni.CurrencyID;
Expand Down Expand Up @@ -261,11 +262,11 @@ public Single<TokenRichList<OmniValue, CurrencyID>> richList(CurrencyID id, int

@Override
public Publisher<TokenRichList<OmniValue, CurrencyID>> richListUpdates(CurrencyID id, int n) {
return client.pollOnNewBlock(() -> client.omniProxyGetRichListSync(id, n));
return client.pollOnNewBlockAsync(() -> client.omniProxyGetRichList(id, n));
}

@Override
public Publisher<ChainTip> chainTipPublisher() {
public ChainTipPublisher chainTipPublisher() {
return client.chainTipPublisher();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.bitcoinj.base.Address;
import org.bitcoinj.base.Network;
import org.consensusj.bitcoin.json.pojo.ChainTip;
import org.consensusj.bitcoin.rx.jsonrpc.PollingChainTipService;
import org.consensusj.bitcoin.rx.ChainTipPublisher;
import org.reactivestreams.Publisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -181,18 +181,17 @@ public ConsensusSnapshot createSnapshot(CurrencyID id, int blockHeight, SortedMa
}

@Override
public Publisher<ChainTip> chainTipPublisher() {
public ChainTipPublisher chainTipPublisher() {
start();
return chainTipProcessor;
return ChainTipPublisher.of(chainTipProcessor);
}

private ChainTip revisionInfoToChainTip(RevisionInfo info) {
return new ChainTip(info.getLastBlock(), info.getBlockHash(), 0, "active");
}

/**
* Using a polling interval provided by {@link PollingChainTipService#getPollingInterval()} provide a
* stream of distinct {@link ChainTip}s.
* Use polling to provide a stream of distinct {@link ChainTip}s.
*
* @return A stream of distinct {@code ChainTip}s.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package foundation.omni.test

import foundation.omni.net.MoneyMan
import foundation.omni.rpc.test.OmniTestClientAccessor
import org.consensusj.bitcoin.jsonrpc.groovy.test.BTCTestSupport
import org.consensusj.bitcoin.jsonrpc.test.BTCTestSupport
import foundation.omni.Ecosystem
import foundation.omni.OmniDivisibleValue
import foundation.omni.OmniValue
Expand Down

0 comments on commit 77769b9

Please sign in to comment.