Skip to content

Commit

Permalink
WIP latest consensusj snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
msgilligan committed Oct 5, 2023
1 parent b21d8ad commit 662d061
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
omnijVersion = 0.7.0-alpha2
omnijVersion = 0.7.0-SNAPSHOT

useMavenLocal = false
useMavenLocal = true

bitcoinjVersion = 0.17-alpha2
consensusjVersion = 0.7.0-alpha2
consensusjVersion = 0.7.0-SNAPSHOT
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 662d061

Please sign in to comment.