Integrate with dataDb init commands and grpc service updates.
On the rust side, we now have access to the init DB commands. On the Go side we have time available for blocks
This commit is contained in:
parent
57630f8eba
commit
a871c5e476
|
@ -11,7 +11,7 @@ import org.junit.Assert.assertNotNull
|
||||||
import org.junit.BeforeClass
|
import org.junit.BeforeClass
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import rpc.CompactFormats
|
import cash.z.wallet.sdk.rpc.CompactFormats
|
||||||
|
|
||||||
class SynchronizerTest {
|
class SynchronizerTest {
|
||||||
@get:Rule
|
@get:Rule
|
||||||
|
|
|
@ -16,9 +16,9 @@ import io.grpc.ManagedChannel
|
||||||
import io.grpc.ManagedChannelBuilder
|
import io.grpc.ManagedChannelBuilder
|
||||||
import org.junit.*
|
import org.junit.*
|
||||||
import org.junit.Assert.*
|
import org.junit.Assert.*
|
||||||
import rpc.CompactTxStreamerGrpc
|
import cash.z.wallet.sdk.rpc.CompactTxStreamerGrpc
|
||||||
import rpc.Service
|
import cash.z.wallet.sdk.rpc.Service
|
||||||
import rpc.Service.*
|
import cash.z.wallet.sdk.rpc.Service.*
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
class GlueIntegrationTest {
|
class GlueIntegrationTest {
|
||||||
|
@ -49,15 +49,17 @@ class GlueIntegrationTest {
|
||||||
while (result.hasNext()) {
|
while (result.hasNext()) {
|
||||||
val compactBlock = result.next()
|
val compactBlock = result.next()
|
||||||
dao.insert(CompactBlock(compactBlock.height.toInt(), compactBlock.toByteArray()))
|
dao.insert(CompactBlock(compactBlock.height.toInt(), compactBlock.toByteArray()))
|
||||||
System.err.println("stored block at height: ${compactBlock.height}")
|
System.err.println("stored block at height: ${compactBlock.height} with time ${compactBlock.time}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun scanData() {
|
private fun scanData() {
|
||||||
|
val dbFileName = "/data/user/0/cash.z.wallet.sdk.test/databases/new-data-glue.db"
|
||||||
|
converter.initDataDb(dbFileName)
|
||||||
Log.e("tezt", "scanning blocks...")
|
Log.e("tezt", "scanning blocks...")
|
||||||
val result = converter.scanBlocks(
|
val result = converter.scanBlocks(
|
||||||
cacheDbPath,
|
cacheDbPath,
|
||||||
"/data/user/0/cash.z.wallet.sdk.test/databases/data-glue.db",
|
dbFileName,
|
||||||
"dummyseed".toByteArray(),
|
"dummyseed".toByteArray(),
|
||||||
373070
|
373070
|
||||||
)
|
)
|
||||||
|
@ -75,7 +77,7 @@ class GlueIntegrationTest {
|
||||||
// db
|
// db
|
||||||
private lateinit var dao: CompactBlockDao
|
private lateinit var dao: CompactBlockDao
|
||||||
private lateinit var db: CompactBlockDb
|
private lateinit var db: CompactBlockDb
|
||||||
private const val cacheDbName = "dummy-cache-glue.db"
|
private const val cacheDbName = "new-dummy-cache-glue.db"
|
||||||
private const val cacheDbPath = "/data/user/0/cash.z.wallet.sdk.test/databases/$cacheDbName"
|
private const val cacheDbPath = "/data/user/0/cash.z.wallet.sdk.test/databases/$cacheDbName"
|
||||||
|
|
||||||
// grpc
|
// grpc
|
||||||
|
|
|
@ -16,9 +16,9 @@ import io.grpc.ManagedChannel
|
||||||
import io.grpc.ManagedChannelBuilder
|
import io.grpc.ManagedChannelBuilder
|
||||||
import org.junit.*
|
import org.junit.*
|
||||||
import org.junit.Assert.*
|
import org.junit.Assert.*
|
||||||
import rpc.CompactTxStreamerGrpc
|
import cash.z.wallet.sdk.rpc.CompactTxStreamerGrpc
|
||||||
import rpc.Service
|
import cash.z.wallet.sdk.rpc.Service
|
||||||
import rpc.Service.*
|
import cash.z.wallet.sdk.rpc.Service.*
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
class GlueSetupIntegrationTest {
|
class GlueSetupIntegrationTest {
|
||||||
|
|
|
@ -22,15 +22,28 @@ class JniConverterTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testScanBlocks() {
|
fun testScanBlocks() {
|
||||||
|
converter.initDataDb("/data/user/0/cash.z.wallet.sdk.test/databases/data2.db")
|
||||||
// note: for this to work, the db file below must be uploaded to the device. Eventually, this test will be self-contained and remove that requirement.
|
// note: for this to work, the db file below must be uploaded to the device. Eventually, this test will be self-contained and remove that requirement.
|
||||||
val result = converter.scanBlocks(
|
val result = converter.scanBlocks(
|
||||||
"/data/user/0/cash.z.wallet.sdk.test/databases/dummy-cache.db",
|
"/data/user/0/cash.z.wallet.sdk.test/databases/dummy-cache.db",
|
||||||
"/data/user/0/cash.z.wallet.sdk.test/databases/data.db",
|
"/data/user/0/cash.z.wallet.sdk.test/databases/data2.db",
|
||||||
"dummyseed".toByteArray(),
|
"dummyseed".toByteArray(),
|
||||||
343900
|
343900
|
||||||
)
|
)
|
||||||
// Thread.sleep(15 * DateUtils.MINUTE_IN_MILLIS)
|
// Thread.sleep(15 * DateUtils.MINUTE_IN_MILLIS)
|
||||||
assertEquals("Invalid number of results", 2, 3)
|
assertEquals("Invalid number of results", 3, 3)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testSend() {
|
||||||
|
converter.sendToAddress(
|
||||||
|
"/data/user/0/cash.z.wallet.sdk.test/databases/data2.db",
|
||||||
|
"dummyseed".toByteArray(),
|
||||||
|
"ztestsapling1fg82ar8y8whjfd52l0xcq0w3n7nn7cask2scp9rp27njeurr72ychvud57s9tu90fdqgwdt07lg",
|
||||||
|
210_000,
|
||||||
|
"/data/user/0/cash.z.wallet.sdk.test/databases/sapling-spend.params",
|
||||||
|
"/data/user/0/cash.z.wallet.sdk.test/databases/sapling-output.params"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -1,532 +0,0 @@
|
||||||
package rpc;
|
|
||||||
|
|
||||||
import static io.grpc.MethodDescriptor.generateFullMethodName;
|
|
||||||
import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
|
|
||||||
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
|
|
||||||
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
|
|
||||||
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
|
|
||||||
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
|
|
||||||
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
|
|
||||||
import static io.grpc.stub.ClientCalls.futureUnaryCall;
|
|
||||||
import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
|
|
||||||
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
|
|
||||||
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
|
|
||||||
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
|
|
||||||
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
|
|
||||||
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
@javax.annotation.Generated(
|
|
||||||
value = "by gRPC proto compiler (version 1.17.1)",
|
|
||||||
comments = "Source: service.proto")
|
|
||||||
public final class CompactTxStreamerGrpc {
|
|
||||||
|
|
||||||
private CompactTxStreamerGrpc() {}
|
|
||||||
|
|
||||||
public static final String SERVICE_NAME = "rpc.CompactTxStreamer";
|
|
||||||
|
|
||||||
// Static method descriptors that strictly reflect the proto.
|
|
||||||
private static volatile io.grpc.MethodDescriptor<rpc.Service.ChainSpec,
|
|
||||||
rpc.Service.BlockID> getGetLatestBlockMethod;
|
|
||||||
|
|
||||||
@io.grpc.stub.annotations.RpcMethod(
|
|
||||||
fullMethodName = SERVICE_NAME + '/' + "GetLatestBlock",
|
|
||||||
requestType = rpc.Service.ChainSpec.class,
|
|
||||||
responseType = rpc.Service.BlockID.class,
|
|
||||||
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
|
|
||||||
public static io.grpc.MethodDescriptor<rpc.Service.ChainSpec,
|
|
||||||
rpc.Service.BlockID> getGetLatestBlockMethod() {
|
|
||||||
io.grpc.MethodDescriptor<rpc.Service.ChainSpec, rpc.Service.BlockID> getGetLatestBlockMethod;
|
|
||||||
if ((getGetLatestBlockMethod = CompactTxStreamerGrpc.getGetLatestBlockMethod) == null) {
|
|
||||||
synchronized (CompactTxStreamerGrpc.class) {
|
|
||||||
if ((getGetLatestBlockMethod = CompactTxStreamerGrpc.getGetLatestBlockMethod) == null) {
|
|
||||||
CompactTxStreamerGrpc.getGetLatestBlockMethod = getGetLatestBlockMethod =
|
|
||||||
io.grpc.MethodDescriptor.<rpc.Service.ChainSpec, rpc.Service.BlockID>newBuilder()
|
|
||||||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
|
|
||||||
.setFullMethodName(generateFullMethodName(
|
|
||||||
"rpc.CompactTxStreamer", "GetLatestBlock"))
|
|
||||||
.setSampledToLocalTracing(true)
|
|
||||||
.setRequestMarshaller(io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(
|
|
||||||
rpc.Service.ChainSpec.getDefaultInstance()))
|
|
||||||
.setResponseMarshaller(io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(
|
|
||||||
rpc.Service.BlockID.getDefaultInstance()))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return getGetLatestBlockMethod;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static volatile io.grpc.MethodDescriptor<rpc.Service.BlockID,
|
|
||||||
rpc.CompactFormats.CompactBlock> getGetBlockMethod;
|
|
||||||
|
|
||||||
@io.grpc.stub.annotations.RpcMethod(
|
|
||||||
fullMethodName = SERVICE_NAME + '/' + "GetBlock",
|
|
||||||
requestType = rpc.Service.BlockID.class,
|
|
||||||
responseType = rpc.CompactFormats.CompactBlock.class,
|
|
||||||
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
|
|
||||||
public static io.grpc.MethodDescriptor<rpc.Service.BlockID,
|
|
||||||
rpc.CompactFormats.CompactBlock> getGetBlockMethod() {
|
|
||||||
io.grpc.MethodDescriptor<rpc.Service.BlockID, rpc.CompactFormats.CompactBlock> getGetBlockMethod;
|
|
||||||
if ((getGetBlockMethod = CompactTxStreamerGrpc.getGetBlockMethod) == null) {
|
|
||||||
synchronized (CompactTxStreamerGrpc.class) {
|
|
||||||
if ((getGetBlockMethod = CompactTxStreamerGrpc.getGetBlockMethod) == null) {
|
|
||||||
CompactTxStreamerGrpc.getGetBlockMethod = getGetBlockMethod =
|
|
||||||
io.grpc.MethodDescriptor.<rpc.Service.BlockID, rpc.CompactFormats.CompactBlock>newBuilder()
|
|
||||||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
|
|
||||||
.setFullMethodName(generateFullMethodName(
|
|
||||||
"rpc.CompactTxStreamer", "GetBlock"))
|
|
||||||
.setSampledToLocalTracing(true)
|
|
||||||
.setRequestMarshaller(io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(
|
|
||||||
rpc.Service.BlockID.getDefaultInstance()))
|
|
||||||
.setResponseMarshaller(io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(
|
|
||||||
rpc.CompactFormats.CompactBlock.getDefaultInstance()))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return getGetBlockMethod;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static volatile io.grpc.MethodDescriptor<rpc.Service.BlockRange,
|
|
||||||
rpc.CompactFormats.CompactBlock> getGetBlockRangeMethod;
|
|
||||||
|
|
||||||
@io.grpc.stub.annotations.RpcMethod(
|
|
||||||
fullMethodName = SERVICE_NAME + '/' + "GetBlockRange",
|
|
||||||
requestType = rpc.Service.BlockRange.class,
|
|
||||||
responseType = rpc.CompactFormats.CompactBlock.class,
|
|
||||||
methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
|
|
||||||
public static io.grpc.MethodDescriptor<rpc.Service.BlockRange,
|
|
||||||
rpc.CompactFormats.CompactBlock> getGetBlockRangeMethod() {
|
|
||||||
io.grpc.MethodDescriptor<rpc.Service.BlockRange, rpc.CompactFormats.CompactBlock> getGetBlockRangeMethod;
|
|
||||||
if ((getGetBlockRangeMethod = CompactTxStreamerGrpc.getGetBlockRangeMethod) == null) {
|
|
||||||
synchronized (CompactTxStreamerGrpc.class) {
|
|
||||||
if ((getGetBlockRangeMethod = CompactTxStreamerGrpc.getGetBlockRangeMethod) == null) {
|
|
||||||
CompactTxStreamerGrpc.getGetBlockRangeMethod = getGetBlockRangeMethod =
|
|
||||||
io.grpc.MethodDescriptor.<rpc.Service.BlockRange, rpc.CompactFormats.CompactBlock>newBuilder()
|
|
||||||
.setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
|
|
||||||
.setFullMethodName(generateFullMethodName(
|
|
||||||
"rpc.CompactTxStreamer", "GetBlockRange"))
|
|
||||||
.setSampledToLocalTracing(true)
|
|
||||||
.setRequestMarshaller(io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(
|
|
||||||
rpc.Service.BlockRange.getDefaultInstance()))
|
|
||||||
.setResponseMarshaller(io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(
|
|
||||||
rpc.CompactFormats.CompactBlock.getDefaultInstance()))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return getGetBlockRangeMethod;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static volatile io.grpc.MethodDescriptor<rpc.Service.TxFilter,
|
|
||||||
rpc.Service.RawTransaction> getGetTransactionMethod;
|
|
||||||
|
|
||||||
@io.grpc.stub.annotations.RpcMethod(
|
|
||||||
fullMethodName = SERVICE_NAME + '/' + "GetTransaction",
|
|
||||||
requestType = rpc.Service.TxFilter.class,
|
|
||||||
responseType = rpc.Service.RawTransaction.class,
|
|
||||||
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
|
|
||||||
public static io.grpc.MethodDescriptor<rpc.Service.TxFilter,
|
|
||||||
rpc.Service.RawTransaction> getGetTransactionMethod() {
|
|
||||||
io.grpc.MethodDescriptor<rpc.Service.TxFilter, rpc.Service.RawTransaction> getGetTransactionMethod;
|
|
||||||
if ((getGetTransactionMethod = CompactTxStreamerGrpc.getGetTransactionMethod) == null) {
|
|
||||||
synchronized (CompactTxStreamerGrpc.class) {
|
|
||||||
if ((getGetTransactionMethod = CompactTxStreamerGrpc.getGetTransactionMethod) == null) {
|
|
||||||
CompactTxStreamerGrpc.getGetTransactionMethod = getGetTransactionMethod =
|
|
||||||
io.grpc.MethodDescriptor.<rpc.Service.TxFilter, rpc.Service.RawTransaction>newBuilder()
|
|
||||||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
|
|
||||||
.setFullMethodName(generateFullMethodName(
|
|
||||||
"rpc.CompactTxStreamer", "GetTransaction"))
|
|
||||||
.setSampledToLocalTracing(true)
|
|
||||||
.setRequestMarshaller(io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(
|
|
||||||
rpc.Service.TxFilter.getDefaultInstance()))
|
|
||||||
.setResponseMarshaller(io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(
|
|
||||||
rpc.Service.RawTransaction.getDefaultInstance()))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return getGetTransactionMethod;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static volatile io.grpc.MethodDescriptor<rpc.Service.RawTransaction,
|
|
||||||
rpc.Service.SendResponse> getSendTransactionMethod;
|
|
||||||
|
|
||||||
@io.grpc.stub.annotations.RpcMethod(
|
|
||||||
fullMethodName = SERVICE_NAME + '/' + "SendTransaction",
|
|
||||||
requestType = rpc.Service.RawTransaction.class,
|
|
||||||
responseType = rpc.Service.SendResponse.class,
|
|
||||||
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
|
|
||||||
public static io.grpc.MethodDescriptor<rpc.Service.RawTransaction,
|
|
||||||
rpc.Service.SendResponse> getSendTransactionMethod() {
|
|
||||||
io.grpc.MethodDescriptor<rpc.Service.RawTransaction, rpc.Service.SendResponse> getSendTransactionMethod;
|
|
||||||
if ((getSendTransactionMethod = CompactTxStreamerGrpc.getSendTransactionMethod) == null) {
|
|
||||||
synchronized (CompactTxStreamerGrpc.class) {
|
|
||||||
if ((getSendTransactionMethod = CompactTxStreamerGrpc.getSendTransactionMethod) == null) {
|
|
||||||
CompactTxStreamerGrpc.getSendTransactionMethod = getSendTransactionMethod =
|
|
||||||
io.grpc.MethodDescriptor.<rpc.Service.RawTransaction, rpc.Service.SendResponse>newBuilder()
|
|
||||||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
|
|
||||||
.setFullMethodName(generateFullMethodName(
|
|
||||||
"rpc.CompactTxStreamer", "SendTransaction"))
|
|
||||||
.setSampledToLocalTracing(true)
|
|
||||||
.setRequestMarshaller(io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(
|
|
||||||
rpc.Service.RawTransaction.getDefaultInstance()))
|
|
||||||
.setResponseMarshaller(io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(
|
|
||||||
rpc.Service.SendResponse.getDefaultInstance()))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return getSendTransactionMethod;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new async stub that supports all call types for the service
|
|
||||||
*/
|
|
||||||
public static CompactTxStreamerStub newStub(io.grpc.Channel channel) {
|
|
||||||
return new CompactTxStreamerStub(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new blocking-style stub that supports unary and streaming output calls on the service
|
|
||||||
*/
|
|
||||||
public static CompactTxStreamerBlockingStub newBlockingStub(
|
|
||||||
io.grpc.Channel channel) {
|
|
||||||
return new CompactTxStreamerBlockingStub(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new ListenableFuture-style stub that supports unary calls on the service
|
|
||||||
*/
|
|
||||||
public static CompactTxStreamerFutureStub newFutureStub(
|
|
||||||
io.grpc.Channel channel) {
|
|
||||||
return new CompactTxStreamerFutureStub(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public static abstract class CompactTxStreamerImplBase implements io.grpc.BindableService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public void getLatestBlock(rpc.Service.ChainSpec request,
|
|
||||||
io.grpc.stub.StreamObserver<rpc.Service.BlockID> responseObserver) {
|
|
||||||
asyncUnimplementedUnaryCall(getGetLatestBlockMethod(), responseObserver);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public void getBlock(rpc.Service.BlockID request,
|
|
||||||
io.grpc.stub.StreamObserver<rpc.CompactFormats.CompactBlock> responseObserver) {
|
|
||||||
asyncUnimplementedUnaryCall(getGetBlockMethod(), responseObserver);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public void getBlockRange(rpc.Service.BlockRange request,
|
|
||||||
io.grpc.stub.StreamObserver<rpc.CompactFormats.CompactBlock> responseObserver) {
|
|
||||||
asyncUnimplementedUnaryCall(getGetBlockRangeMethod(), responseObserver);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public void getTransaction(rpc.Service.TxFilter request,
|
|
||||||
io.grpc.stub.StreamObserver<rpc.Service.RawTransaction> responseObserver) {
|
|
||||||
asyncUnimplementedUnaryCall(getGetTransactionMethod(), responseObserver);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public void sendTransaction(rpc.Service.RawTransaction request,
|
|
||||||
io.grpc.stub.StreamObserver<rpc.Service.SendResponse> responseObserver) {
|
|
||||||
asyncUnimplementedUnaryCall(getSendTransactionMethod(), responseObserver);
|
|
||||||
}
|
|
||||||
|
|
||||||
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
|
|
||||||
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
|
|
||||||
.addMethod(
|
|
||||||
getGetLatestBlockMethod(),
|
|
||||||
asyncUnaryCall(
|
|
||||||
new MethodHandlers<
|
|
||||||
rpc.Service.ChainSpec,
|
|
||||||
rpc.Service.BlockID>(
|
|
||||||
this, METHODID_GET_LATEST_BLOCK)))
|
|
||||||
.addMethod(
|
|
||||||
getGetBlockMethod(),
|
|
||||||
asyncUnaryCall(
|
|
||||||
new MethodHandlers<
|
|
||||||
rpc.Service.BlockID,
|
|
||||||
rpc.CompactFormats.CompactBlock>(
|
|
||||||
this, METHODID_GET_BLOCK)))
|
|
||||||
.addMethod(
|
|
||||||
getGetBlockRangeMethod(),
|
|
||||||
asyncServerStreamingCall(
|
|
||||||
new MethodHandlers<
|
|
||||||
rpc.Service.BlockRange,
|
|
||||||
rpc.CompactFormats.CompactBlock>(
|
|
||||||
this, METHODID_GET_BLOCK_RANGE)))
|
|
||||||
.addMethod(
|
|
||||||
getGetTransactionMethod(),
|
|
||||||
asyncUnaryCall(
|
|
||||||
new MethodHandlers<
|
|
||||||
rpc.Service.TxFilter,
|
|
||||||
rpc.Service.RawTransaction>(
|
|
||||||
this, METHODID_GET_TRANSACTION)))
|
|
||||||
.addMethod(
|
|
||||||
getSendTransactionMethod(),
|
|
||||||
asyncUnaryCall(
|
|
||||||
new MethodHandlers<
|
|
||||||
rpc.Service.RawTransaction,
|
|
||||||
rpc.Service.SendResponse>(
|
|
||||||
this, METHODID_SEND_TRANSACTION)))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public static final class CompactTxStreamerStub extends io.grpc.stub.AbstractStub<CompactTxStreamerStub> {
|
|
||||||
private CompactTxStreamerStub(io.grpc.Channel channel) {
|
|
||||||
super(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
private CompactTxStreamerStub(io.grpc.Channel channel,
|
|
||||||
io.grpc.CallOptions callOptions) {
|
|
||||||
super(channel, callOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
@java.lang.Override
|
|
||||||
protected CompactTxStreamerStub build(io.grpc.Channel channel,
|
|
||||||
io.grpc.CallOptions callOptions) {
|
|
||||||
return new CompactTxStreamerStub(channel, callOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public void getLatestBlock(rpc.Service.ChainSpec request,
|
|
||||||
io.grpc.stub.StreamObserver<rpc.Service.BlockID> responseObserver) {
|
|
||||||
asyncUnaryCall(
|
|
||||||
getChannel().newCall(getGetLatestBlockMethod(), getCallOptions()), request, responseObserver);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public void getBlock(rpc.Service.BlockID request,
|
|
||||||
io.grpc.stub.StreamObserver<rpc.CompactFormats.CompactBlock> responseObserver) {
|
|
||||||
asyncUnaryCall(
|
|
||||||
getChannel().newCall(getGetBlockMethod(), getCallOptions()), request, responseObserver);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public void getBlockRange(rpc.Service.BlockRange request,
|
|
||||||
io.grpc.stub.StreamObserver<rpc.CompactFormats.CompactBlock> responseObserver) {
|
|
||||||
asyncServerStreamingCall(
|
|
||||||
getChannel().newCall(getGetBlockRangeMethod(), getCallOptions()), request, responseObserver);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public void getTransaction(rpc.Service.TxFilter request,
|
|
||||||
io.grpc.stub.StreamObserver<rpc.Service.RawTransaction> responseObserver) {
|
|
||||||
asyncUnaryCall(
|
|
||||||
getChannel().newCall(getGetTransactionMethod(), getCallOptions()), request, responseObserver);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public void sendTransaction(rpc.Service.RawTransaction request,
|
|
||||||
io.grpc.stub.StreamObserver<rpc.Service.SendResponse> responseObserver) {
|
|
||||||
asyncUnaryCall(
|
|
||||||
getChannel().newCall(getSendTransactionMethod(), getCallOptions()), request, responseObserver);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public static final class CompactTxStreamerBlockingStub extends io.grpc.stub.AbstractStub<CompactTxStreamerBlockingStub> {
|
|
||||||
private CompactTxStreamerBlockingStub(io.grpc.Channel channel) {
|
|
||||||
super(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
private CompactTxStreamerBlockingStub(io.grpc.Channel channel,
|
|
||||||
io.grpc.CallOptions callOptions) {
|
|
||||||
super(channel, callOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
@java.lang.Override
|
|
||||||
protected CompactTxStreamerBlockingStub build(io.grpc.Channel channel,
|
|
||||||
io.grpc.CallOptions callOptions) {
|
|
||||||
return new CompactTxStreamerBlockingStub(channel, callOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public rpc.Service.BlockID getLatestBlock(rpc.Service.ChainSpec request) {
|
|
||||||
return blockingUnaryCall(
|
|
||||||
getChannel(), getGetLatestBlockMethod(), getCallOptions(), request);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public rpc.CompactFormats.CompactBlock getBlock(rpc.Service.BlockID request) {
|
|
||||||
return blockingUnaryCall(
|
|
||||||
getChannel(), getGetBlockMethod(), getCallOptions(), request);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public java.util.Iterator<rpc.CompactFormats.CompactBlock> getBlockRange(
|
|
||||||
rpc.Service.BlockRange request) {
|
|
||||||
return blockingServerStreamingCall(
|
|
||||||
getChannel(), getGetBlockRangeMethod(), getCallOptions(), request);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public rpc.Service.RawTransaction getTransaction(rpc.Service.TxFilter request) {
|
|
||||||
return blockingUnaryCall(
|
|
||||||
getChannel(), getGetTransactionMethod(), getCallOptions(), request);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public rpc.Service.SendResponse sendTransaction(rpc.Service.RawTransaction request) {
|
|
||||||
return blockingUnaryCall(
|
|
||||||
getChannel(), getSendTransactionMethod(), getCallOptions(), request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public static final class CompactTxStreamerFutureStub extends io.grpc.stub.AbstractStub<CompactTxStreamerFutureStub> {
|
|
||||||
private CompactTxStreamerFutureStub(io.grpc.Channel channel) {
|
|
||||||
super(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
private CompactTxStreamerFutureStub(io.grpc.Channel channel,
|
|
||||||
io.grpc.CallOptions callOptions) {
|
|
||||||
super(channel, callOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
@java.lang.Override
|
|
||||||
protected CompactTxStreamerFutureStub build(io.grpc.Channel channel,
|
|
||||||
io.grpc.CallOptions callOptions) {
|
|
||||||
return new CompactTxStreamerFutureStub(channel, callOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public com.google.common.util.concurrent.ListenableFuture<rpc.Service.BlockID> getLatestBlock(
|
|
||||||
rpc.Service.ChainSpec request) {
|
|
||||||
return futureUnaryCall(
|
|
||||||
getChannel().newCall(getGetLatestBlockMethod(), getCallOptions()), request);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public com.google.common.util.concurrent.ListenableFuture<rpc.CompactFormats.CompactBlock> getBlock(
|
|
||||||
rpc.Service.BlockID request) {
|
|
||||||
return futureUnaryCall(
|
|
||||||
getChannel().newCall(getGetBlockMethod(), getCallOptions()), request);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public com.google.common.util.concurrent.ListenableFuture<rpc.Service.RawTransaction> getTransaction(
|
|
||||||
rpc.Service.TxFilter request) {
|
|
||||||
return futureUnaryCall(
|
|
||||||
getChannel().newCall(getGetTransactionMethod(), getCallOptions()), request);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public com.google.common.util.concurrent.ListenableFuture<rpc.Service.SendResponse> sendTransaction(
|
|
||||||
rpc.Service.RawTransaction request) {
|
|
||||||
return futureUnaryCall(
|
|
||||||
getChannel().newCall(getSendTransactionMethod(), getCallOptions()), request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final int METHODID_GET_LATEST_BLOCK = 0;
|
|
||||||
private static final int METHODID_GET_BLOCK = 1;
|
|
||||||
private static final int METHODID_GET_BLOCK_RANGE = 2;
|
|
||||||
private static final int METHODID_GET_TRANSACTION = 3;
|
|
||||||
private static final int METHODID_SEND_TRANSACTION = 4;
|
|
||||||
|
|
||||||
private static final class MethodHandlers<Req, Resp> implements
|
|
||||||
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
|
|
||||||
io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
|
|
||||||
io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
|
|
||||||
io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
|
|
||||||
private final CompactTxStreamerImplBase serviceImpl;
|
|
||||||
private final int methodId;
|
|
||||||
|
|
||||||
MethodHandlers(CompactTxStreamerImplBase serviceImpl, int methodId) {
|
|
||||||
this.serviceImpl = serviceImpl;
|
|
||||||
this.methodId = methodId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@java.lang.Override
|
|
||||||
@java.lang.SuppressWarnings("unchecked")
|
|
||||||
public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
|
|
||||||
switch (methodId) {
|
|
||||||
case METHODID_GET_LATEST_BLOCK:
|
|
||||||
serviceImpl.getLatestBlock((rpc.Service.ChainSpec) request,
|
|
||||||
(io.grpc.stub.StreamObserver<rpc.Service.BlockID>) responseObserver);
|
|
||||||
break;
|
|
||||||
case METHODID_GET_BLOCK:
|
|
||||||
serviceImpl.getBlock((rpc.Service.BlockID) request,
|
|
||||||
(io.grpc.stub.StreamObserver<rpc.CompactFormats.CompactBlock>) responseObserver);
|
|
||||||
break;
|
|
||||||
case METHODID_GET_BLOCK_RANGE:
|
|
||||||
serviceImpl.getBlockRange((rpc.Service.BlockRange) request,
|
|
||||||
(io.grpc.stub.StreamObserver<rpc.CompactFormats.CompactBlock>) responseObserver);
|
|
||||||
break;
|
|
||||||
case METHODID_GET_TRANSACTION:
|
|
||||||
serviceImpl.getTransaction((rpc.Service.TxFilter) request,
|
|
||||||
(io.grpc.stub.StreamObserver<rpc.Service.RawTransaction>) responseObserver);
|
|
||||||
break;
|
|
||||||
case METHODID_SEND_TRANSACTION:
|
|
||||||
serviceImpl.sendTransaction((rpc.Service.RawTransaction) request,
|
|
||||||
(io.grpc.stub.StreamObserver<rpc.Service.SendResponse>) responseObserver);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new AssertionError();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@java.lang.Override
|
|
||||||
@java.lang.SuppressWarnings("unchecked")
|
|
||||||
public io.grpc.stub.StreamObserver<Req> invoke(
|
|
||||||
io.grpc.stub.StreamObserver<Resp> responseObserver) {
|
|
||||||
switch (methodId) {
|
|
||||||
default:
|
|
||||||
throw new AssertionError();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
|
|
||||||
|
|
||||||
public static io.grpc.ServiceDescriptor getServiceDescriptor() {
|
|
||||||
io.grpc.ServiceDescriptor result = serviceDescriptor;
|
|
||||||
if (result == null) {
|
|
||||||
synchronized (CompactTxStreamerGrpc.class) {
|
|
||||||
result = serviceDescriptor;
|
|
||||||
if (result == null) {
|
|
||||||
serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
|
|
||||||
.addMethod(getGetLatestBlockMethod())
|
|
||||||
.addMethod(getGetBlockMethod())
|
|
||||||
.addMethod(getGetBlockRangeMethod())
|
|
||||||
.addMethod(getGetTransactionMethod())
|
|
||||||
.addMethod(getSendTransactionMethod())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -2,17 +2,15 @@ package cash.z.wallet.sdk.data
|
||||||
|
|
||||||
import cash.z.wallet.sdk.ext.debug
|
import cash.z.wallet.sdk.ext.debug
|
||||||
import cash.z.wallet.sdk.ext.toBlockRange
|
import cash.z.wallet.sdk.ext.toBlockRange
|
||||||
import io.grpc.ManagedChannel
|
import cash.z.wallet.sdk.rpc.CompactFormats.CompactBlock
|
||||||
|
import cash.z.wallet.sdk.rpc.CompactTxStreamerGrpc
|
||||||
|
import cash.z.wallet.sdk.rpc.CompactTxStreamerGrpc.CompactTxStreamerBlockingStub
|
||||||
|
import cash.z.wallet.sdk.rpc.Service
|
||||||
import io.grpc.ManagedChannelBuilder
|
import io.grpc.ManagedChannelBuilder
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.Dispatchers.IO
|
import kotlinx.coroutines.Dispatchers.IO
|
||||||
import kotlinx.coroutines.NonCancellable.isActive
|
|
||||||
import kotlinx.coroutines.channels.BroadcastChannel
|
import kotlinx.coroutines.channels.BroadcastChannel
|
||||||
import kotlinx.coroutines.channels.ReceiveChannel
|
import kotlinx.coroutines.channels.ReceiveChannel
|
||||||
import rpc.CompactFormats.CompactBlock
|
|
||||||
import rpc.CompactTxStreamerGrpc
|
|
||||||
import rpc.CompactTxStreamerGrpc.CompactTxStreamerBlockingStub
|
|
||||||
import rpc.Service
|
|
||||||
import java.io.Closeable
|
import java.io.Closeable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,7 +10,7 @@ import cash.z.wallet.sdk.jni.JniConverter
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.channels.ConflatedBroadcastChannel
|
import kotlinx.coroutines.channels.ConflatedBroadcastChannel
|
||||||
import kotlinx.coroutines.channels.ReceiveChannel
|
import kotlinx.coroutines.channels.ReceiveChannel
|
||||||
import rpc.CompactFormats
|
import cash.z.wallet.sdk.rpc.CompactFormats
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Downloads compact blocks to the database and then scans them for transactions
|
* Downloads compact blocks to the database and then scans them for transactions
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package cash.z.wallet.sdk.ext
|
package cash.z.wallet.sdk.ext
|
||||||
|
|
||||||
import rpc.Service
|
import cash.z.wallet.sdk.rpc.Service
|
||||||
|
|
||||||
inline fun Long.toBlockHeight(): Service.BlockID = Service.BlockID.newBuilder().setHeight(this).build()
|
inline fun Long.toBlockHeight(): Service.BlockID = Service.BlockID.newBuilder().setHeight(this).build()
|
||||||
inline fun LongRange.toBlockRange(): Service.BlockRange =
|
inline fun LongRange.toBlockRange(): Service.BlockRange =
|
||||||
|
|
|
@ -35,7 +35,8 @@ class JniConverter {
|
||||||
value: Long,
|
value: Long,
|
||||||
memo: String,
|
memo: String,
|
||||||
spendParams: String,
|
spendParams: String,
|
||||||
outputParams: String): Long
|
outputParams: String
|
||||||
|
): Long
|
||||||
|
|
||||||
external fun initLogs()
|
external fun initLogs()
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
package cash.z.wallet.sdk.rpc;
|
package cash.z.wallet.sdk.rpc;
|
||||||
option go_package = "walletrpc";
|
option go_package = "walletrpc";
|
||||||
package rpc;
|
|
||||||
|
|
||||||
// Remember that proto3 fields are all optional. A field that is not present will be set to its zero value.
|
// Remember that proto3 fields are all optional. A field that is not present will be set to its zero value.
|
||||||
// bytes fields of hashes are in canonical little-endian format.
|
// bytes fields of hashes are in canonical little-endian format.
|
||||||
|
@ -45,4 +44,4 @@ message CompactOutput {
|
||||||
bytes cmu = 1;
|
bytes cmu = 1;
|
||||||
bytes epk = 2;
|
bytes epk = 2;
|
||||||
bytes ciphertext = 3;
|
bytes ciphertext = 3;
|
||||||
}
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
package cash.z.wallet.sdk.rpc;
|
package cash.z.wallet.sdk.rpc;
|
||||||
option go_package = "walletrpc";
|
option go_package = "walletrpc";
|
||||||
package rpc;
|
|
||||||
|
|
||||||
import "compact_formats.proto";
|
import "compact_formats.proto";
|
||||||
|
|
||||||
|
@ -47,4 +46,4 @@ service CompactTxStreamer {
|
||||||
rpc GetBlockRange(BlockRange) returns (stream CompactBlock) {}
|
rpc GetBlockRange(BlockRange) returns (stream CompactBlock) {}
|
||||||
rpc GetTransaction(TxFilter) returns (RawTransaction) {}
|
rpc GetTransaction(TxFilter) returns (RawTransaction) {}
|
||||||
rpc SendTransaction(RawTransaction) returns (SendResponse) {}
|
rpc SendTransaction(RawTransaction) returns (SendResponse) {}
|
||||||
}
|
}
|
Loading…
Reference in New Issue