From 77769b9e224ec08e8f6fafea297480bcd86755c2 Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Thu, 5 Oct 2023 23:02:53 -0700 Subject: [PATCH] Upgrade to ConsensusJ 0.7.0-alpha3 * Use JsonRpcTransport.getDefaultSSLContext() to get default SSL context * Reflect JsonRpcClient as base class for RPC clients * ChainTipPublisher replaces Publisher * BTCTestSupport moved from Groovy to Java and changed package --- CHANGELOG.adoc | 4 ++++ gradle.properties | 2 +- .../src/main/java/foundation/omni/rpc/OmniClient.java | 5 +++-- .../main/java/foundation/omni/rpc/OmniProxyMethods.java | 6 +++--- .../foundation/omni/netapi/omnicore/OmniCoreClient.java | 5 +++-- .../omni/netapi/omniwallet/OmniwalletAbstractClient.java | 9 ++++----- .../groovy/foundation/omni/test/OmniTestSupport.groovy | 2 +- 7 files changed, 19 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 7a3274ba..3eeaeaf0 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -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 diff --git a/gradle.properties b/gradle.properties index 5b168c8e..18e369a5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/omnij-jsonrpc/src/main/java/foundation/omni/rpc/OmniClient.java b/omnij-jsonrpc/src/main/java/foundation/omni/rpc/OmniClient.java index d624a688..ce8fcf98 100644 --- a/omnij-jsonrpc/src/main/java/foundation/omni/rpc/OmniClient.java +++ b/omnij-jsonrpc/src/main/java/foundation/omni/rpc/OmniClient.java @@ -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; @@ -60,7 +61,7 @@ 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) { @@ -68,7 +69,7 @@ public OmniClient(SSLContext sslContext, Network network, URI server, String rpc } 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) { diff --git a/omnij-jsonrpc/src/main/java/foundation/omni/rpc/OmniProxyMethods.java b/omnij-jsonrpc/src/main/java/foundation/omni/rpc/OmniProxyMethods.java index de111cc7..4c36195e 100644 --- a/omnij-jsonrpc/src/main/java/foundation/omni/rpc/OmniProxyMethods.java +++ b/omnij-jsonrpc/src/main/java/foundation/omni/rpc/OmniProxyMethods.java @@ -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; @@ -26,7 +26,7 @@ /** * Interface with default methods implementing omniproxy RPCs. */ -public interface OmniProxyMethods extends JacksonRpcClient { +public interface OmniProxyMethods extends JsonRpcClient { Logger log = LoggerFactory.getLogger(OmniProxyMethods.class); AddressParser addressParser = AddressParser.getDefault(); @@ -37,7 +37,7 @@ public interface OmniProxyMethods extends JacksonRpcClient { boolean isOmniProxyServer(); private List omniProxyListPropertiesSync() throws IOException { - JavaType javaType = getMapper().getTypeFactory().constructCollectionType(List.class, OmniPropertyInfo.class); + JavaType javaType = collectionTypeForClasses(List.class, OmniPropertyInfo.class); return send("omniproxy.listproperties", javaType); } diff --git a/omnij-net-api/src/main/java/foundation/omni/netapi/omnicore/OmniCoreClient.java b/omnij-net-api/src/main/java/foundation/omni/netapi/omnicore/OmniCoreClient.java index 1af3d1da..ff00421f 100644 --- a/omnij-net-api/src/main/java/foundation/omni/netapi/omnicore/OmniCoreClient.java +++ b/omnij-net-api/src/main/java/foundation/omni/netapi/omnicore/OmniCoreClient.java @@ -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; @@ -261,11 +262,11 @@ public Single> richList(CurrencyID id, int @Override public Publisher> richListUpdates(CurrencyID id, int n) { - return client.pollOnNewBlock(() -> client.omniProxyGetRichListSync(id, n)); + return client.pollOnNewBlockAsync(() -> client.omniProxyGetRichList(id, n)); } @Override - public Publisher chainTipPublisher() { + public ChainTipPublisher chainTipPublisher() { return client.chainTipPublisher(); } diff --git a/omnij-net-api/src/main/java/foundation/omni/netapi/omniwallet/OmniwalletAbstractClient.java b/omnij-net-api/src/main/java/foundation/omni/netapi/omniwallet/OmniwalletAbstractClient.java index cbc313e0..56311806 100644 --- a/omnij-net-api/src/main/java/foundation/omni/netapi/omniwallet/OmniwalletAbstractClient.java +++ b/omnij-net-api/src/main/java/foundation/omni/netapi/omniwallet/OmniwalletAbstractClient.java @@ -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; @@ -181,9 +181,9 @@ public ConsensusSnapshot createSnapshot(CurrencyID id, int blockHeight, SortedMa } @Override - public Publisher chainTipPublisher() { + public ChainTipPublisher chainTipPublisher() { start(); - return chainTipProcessor; + return ChainTipPublisher.of(chainTipProcessor); } private ChainTip revisionInfoToChainTip(RevisionInfo info) { @@ -191,8 +191,7 @@ private ChainTip revisionInfoToChainTip(RevisionInfo info) { } /** - * 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. */ diff --git a/omnij-rpc/src/main/groovy/foundation/omni/test/OmniTestSupport.groovy b/omnij-rpc/src/main/groovy/foundation/omni/test/OmniTestSupport.groovy index f0cb23bd..f3778223 100644 --- a/omnij-rpc/src/main/groovy/foundation/omni/test/OmniTestSupport.groovy +++ b/omnij-rpc/src/main/groovy/foundation/omni/test/OmniTestSupport.groovy @@ -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