diff --git a/build.gradle b/build.gradle index ce07d733..bd2b57a7 100644 --- a/build.gradle +++ b/build.gradle @@ -5,8 +5,10 @@ buildscript { 'targetSdkVersion': 28 ] ext.versions = [ + 'architectureComponents': '2.0.0', + 'grpc':'1.17.1', 'kotlin': '1.3.10', - 'architectureComponents': '2.0.0' + 'coroutines': '1.1.0' ] repositories { google() @@ -17,6 +19,7 @@ buildscript { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}" classpath "com.github.ben-manes:gradle-versions-plugin:0.20.0" classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' + classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.7" } } @@ -25,6 +28,7 @@ apply plugin: 'com.android.library' apply plugin: "kotlin-android-extensions" apply plugin: "kotlin-android" apply plugin: 'kotlin-kapt' +apply plugin: 'com.google.protobuf' apply plugin: 'com.github.ben-manes.versions' apply plugin: 'com.github.dcendents.android-maven' @@ -34,6 +38,7 @@ version = '1.2.4' repositories { google() jcenter() + mavenCentral() } android { @@ -42,9 +47,10 @@ android { defaultConfig { minSdkVersion 16 targetSdkVersion 28 - versionCode = 1_02_03 - versionName = "1.2.3" + versionCode = 1_03_00 + versionName = "1.3.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + multiDexEnabled false } buildTypes { @@ -56,7 +62,10 @@ android { sourceSets { main { java { - srcDirs "build/generated/source/wire" + srcDirs "build/generated/source/grpc" + } + proto { + srcDir 'src/main/proto' } } } @@ -66,29 +75,60 @@ android { } } +clean { + delete "$project.projectDir/src/generated/source/grpc" +} + + +protobuf { + generatedFilesBaseDir = "$projectDir/src/generated/source/grpc" + protoc { artifact = 'com.google.protobuf:protoc:3.6.1' } + plugins { + javalite { artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0" } + grpc { artifact = "io.grpc:protoc-gen-grpc-java:${versions.grpc}" } + } + generateProtoTasks { + all().each { task -> + task.plugins { + javalite {} + grpc { // Options added to --grpc_out + option 'lite' } + } + } + } +} + dependencies { - // Square - api "com.squareup.wire:wire-runtime:2.2.0" + implementation 'androidx.appcompat:appcompat:1.0.2' + implementation 'androidx.multidex:multidex:2.0.1' // Architecture components implementation "androidx.lifecycle:lifecycle-runtime:${versions.architectureComponents}" implementation "androidx.lifecycle:lifecycle-extensions:${versions.architectureComponents}" implementation "androidx.room:room-runtime:${versions.architectureComponents}" + implementation "androidx.room:room-common:${versions.architectureComponents}" kapt "androidx.lifecycle:lifecycle-compiler:${versions.architectureComponents}" kapt "androidx.room:room-compiler:${versions.architectureComponents}" - // Other + // kotlin implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}" - implementation "com.android.support:appcompat-v7:28.0.0" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:${versions.coroutines}" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:${versions.coroutines}" + + // grpc-java + implementation "io.grpc:grpc-okhttp:${versions.grpc}" + implementation "io.grpc:grpc-protobuf-lite:${versions.grpc}" + implementation "io.grpc:grpc-stub:${versions.grpc}" + implementation 'javax.annotation:javax.annotation-api:1.2' // Tests testImplementation "junit:junit:4.12" - androidTestImplementation "androidx.test:runner:1.1.0" - androidTestImplementation "androidx.test.espresso:espresso-core:3.1.0" - androidTestImplementation "androidx.test:core:1.0.0" + androidTestImplementation "androidx.test:runner:1.1.1" + androidTestImplementation "androidx.test.espresso:espresso-core:3.1.1" + androidTestImplementation "androidx.test:core:1.1.0" androidTestImplementation "androidx.arch.core:core-testing:${versions.architectureComponents}" } -preBuild.dependsOn generateProtobufClasses +preBuild.dependsOn includeDirBugFix preBuild.dependsOn copyAllJniLibs \ No newline at end of file diff --git a/custom-tasks.gradle b/custom-tasks.gradle index 75cffee8..92ffdbcd 100644 --- a/custom-tasks.gradle +++ b/custom-tasks.gradle @@ -1,5 +1,6 @@ -def protoSrcDir = "src/main/proto" -def protoDestDir = "build/generated/source/wire" +//def protoSrcDir = "src/main/proto" +//def protoDestDir = "build/generated/source/grpc" +def protoIncludeDir = "build/extracted-include-protos/main" def jniSrcDir = "src/main/rust" def jniDestDir = "build/rust/target" @@ -11,36 +12,64 @@ def libArm64Dir = "src/main/jniLibs/arm64-v8a" def libArmeabiFile = "build/rust/target/armv7-linux-androideabi/release/$libFile" def libArmeabiDir = "src/main/jniLibs/armeabi-v7a" -buildscript { - dependencies { - classpath("com.squareup.wire:wire-compiler:2.2.0") - } - repositories { - mavenCentral() - } -} +//buildscript { +// dependencies { +// classpath("com.squareup.wire:wire-compiler:2.2.0") +// } +// repositories { +// mavenCentral() +// } +//} -tasks.register("generateProtobufClasses") { +//tasks.register("generateGrpcClasses") { +// doFirst { +// println("**** CREATING PROTOS ****") +// delete(protoDestDir) +// mkdir(protoDestDir) +// } +// description = "Generate Java classes from protocol buffer (.proto) schema files for use with grpc" +// +// fileTree(dir: protoSrcDir, include: '**/*.proto').each { File file -> +// doLast { +// javaexec { +// main = "com.squareup.wire.WireCompiler" +// classpath = buildscript.configurations.classpath +// args = ["--proto_path=$protoSrcDir", "--java_out=$protoDestDir", file.path] +// } +// } +// } +// inputs.files(fileTree(dir: protoSrcDir, include: '**/*.proto')) +// outputs.files(fileTree(dir: protoDestDir, include: '**')) +//} + +//tasks.register("generateProtobufClasses") { +// doFirst { +// println("**** CREATING PROTOS ****") +// delete(protoDestDir) +// mkdir(protoDestDir) +// } +// description = "Generate Java classes from protocol buffer (.proto) schema files for use with Square's Wire library" +// +// fileTree(dir: protoSrcDir, include: '**/*.proto').each { File file -> +// doLast { +// javaexec { +// main = "com.squareup.wire.WireCompiler" +// classpath = buildscript.configurations.classpath +// args = ["--proto_path=$protoSrcDir", "--java_out=$protoDestDir", file.path] +// } +// } +// } +// inputs.files(fileTree(dir: protoSrcDir, include: '**/*.proto')) +// outputs.files(fileTree(dir: protoDestDir, include: '**')) +//} +tasks.register("includeDirBugFix") { doFirst { - println("**** CREATING PROTOS ****") - delete(protoDestDir) - mkdir(protoDestDir) + mkdir(protoIncludeDir) } - description = "Generate Java classes from protocol buffer (.proto) schema files for use with Square's Wire library" - - fileTree(dir: protoSrcDir, include: '**/*.proto').each { File file -> - doLast { - javaexec { - main = "com.squareup.wire.WireCompiler" - classpath = buildscript.configurations.classpath - args = ["--proto_path=$protoSrcDir", "--java_out=$protoDestDir", file.path] - } - } - } - inputs.files(fileTree(dir: protoSrcDir, include: '**/*.proto')) - outputs.files(fileTree(dir: protoDestDir, include: '**')) } +// TODO: run these in paralell with the worker API: https://guides.gradle.org/using-the-worker-api/ +// note: this will require modifying the build script and having 3 separate calls tasks.register("generateJniLibs") { doFirst { println("**** CREATING JNI LIBS ****") diff --git a/src/androidTest/java/cash/z/wallet/sdk/data/CompactBlockDownloaderTest.kt b/src/androidTest/java/cash/z/wallet/sdk/data/CompactBlockDownloaderTest.kt new file mode 100644 index 00000000..24a38e35 --- /dev/null +++ b/src/androidTest/java/cash/z/wallet/sdk/data/CompactBlockDownloaderTest.kt @@ -0,0 +1,66 @@ +package cash.z.wallet.sdk.data + +import android.util.Log +import androidx.arch.core.executor.testing.InstantTaskExecutorRule +import kotlinx.coroutines.* +import org.junit.AfterClass +import org.junit.Assert.assertNotNull +import org.junit.Assert.assertTrue +import org.junit.BeforeClass +import org.junit.Rule +import org.junit.Test +import rpc.CompactFormats + +class CompactBlockDownloaderTest { + @get:Rule + var instantTaskExecutorRule = InstantTaskExecutorRule() + + @Test + fun testSynchronizerExists() { + assertNotNull(downloader) + } + + @Test + fun testBlocks() = runBlocking { + msg("about to receive (is the channel Closed? ${downloader.blocks().isClosedForReceive})") + val result = downloader.blocks().receive() + msg("donezo") + assertTrue(printFailure(result), result.isSuccess) + } + + private fun printFailure(result: Result): String { + return if (result.isFailure) "result failed due to: ${result.exceptionOrNull()!!.let { "$it caused by: ${it.cause}" }}}" + else "success" + } + + @Test + fun testBlockHeight() = runBlocking { + delay(200) + val result = downloader.blocks().receive() + assertTrue(printFailure(result), result.isSuccess) + assertTrue("Unexpected height value", result.getOrThrow().height > 300000) + } + + companion object { + val job = Job() + val testScope = CoroutineScope(Dispatchers.IO + job) + val downloader = CompactBlockDownloader(testScope) + + @BeforeClass + @JvmStatic + fun setup() { + downloader.start() + } + + @AfterClass + @JvmStatic + fun close() { + downloader.stop() + job.cancel() + } + + fun msg(message: String) { + Log.e("DBUG", "[${Thread.currentThread().name}] $message") + } + } +} diff --git a/src/androidTest/java/cash/z/wallet/sdk/data/SynchronizerTest.kt b/src/androidTest/java/cash/z/wallet/sdk/data/SynchronizerTest.kt new file mode 100644 index 00000000..c57c2a06 --- /dev/null +++ b/src/androidTest/java/cash/z/wallet/sdk/data/SynchronizerTest.kt @@ -0,0 +1,56 @@ +package cash.z.wallet.sdk.data + +import androidx.arch.core.executor.testing.InstantTaskExecutorRule +import androidx.test.core.app.ApplicationProvider +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job +import kotlinx.coroutines.cancel +import org.junit.AfterClass +import org.junit.Assert.assertNotNull +import org.junit.BeforeClass +import org.junit.Rule +import org.junit.Test +import rpc.CompactFormats + +class SynchronizerTest { + @get:Rule + var instantTaskExecutorRule = InstantTaskExecutorRule() + + @Test + fun testSynchronizerExists() { + assertNotNull(synchronizer) + } + + @Test + fun testBlockSaving() { +// synchronizer.saveBlocks() + } + @Test + fun testBlockScanning() { + Thread.sleep(180000L) + } + private fun printFailure(result: Result): String { + return if (result.isFailure) "result failed due to: ${result.exceptionOrNull()!!.let { "$it caused by: ${it.cause}" }}}" + else "success" + } + + companion object { + val job = Job() + val testScope = CoroutineScope(Dispatchers.IO + job) + val synchronizer = Synchronizer(ApplicationProvider.getApplicationContext(), testScope) + + @BeforeClass + @JvmStatic + fun setup() { + synchronizer.start() + } + + @AfterClass + @JvmStatic + fun close() { + synchronizer.stop() + testScope.cancel() + } + } +} diff --git a/src/androidTest/java/cash/z/wallet/sdk/db/GlueIntegrationTest.kt b/src/androidTest/java/cash/z/wallet/sdk/db/GlueIntegrationTest.kt new file mode 100644 index 00000000..e708af86 --- /dev/null +++ b/src/androidTest/java/cash/z/wallet/sdk/db/GlueIntegrationTest.kt @@ -0,0 +1,111 @@ +package cash.z.wallet.sdk.db + +import android.util.Log +import androidx.arch.core.executor.testing.InstantTaskExecutorRule +import androidx.room.Room +import androidx.room.RoomDatabase +import androidx.test.core.app.ApplicationProvider +import cash.z.wallet.sdk.dao.BlockDao +import cash.z.wallet.sdk.dao.CompactBlockDao +import cash.z.wallet.sdk.dao.NoteDao +import cash.z.wallet.sdk.dao.TransactionDao +import cash.z.wallet.sdk.ext.toBlockHeight +import cash.z.wallet.sdk.jni.JniConverter +import cash.z.wallet.sdk.vo.CompactBlock +import io.grpc.ManagedChannel +import io.grpc.ManagedChannelBuilder +import org.junit.* +import org.junit.Assert.* +import rpc.CompactTxStreamerGrpc +import rpc.Service +import rpc.Service.* +import java.util.concurrent.TimeUnit + +class GlueIntegrationTest { + @get:Rule + var instantTaskExecutorRule = InstantTaskExecutorRule() + + @Test + fun testDbExists() { + Log.e("tezt", "addData") + addData() + Log.e("tezt", "scanData") + scanData() + Log.e("tezt", "checkResults") + checkResults() + } + + private fun checkResults() { + Thread.sleep(15000L) + } + + private fun addData() { + val result = blockingStub.getBlockRange( + BlockRange.newBuilder() + .setStart(373070L.toBlockHeight()) + .setEnd(373085L.toBlockHeight()) + .build() + ) + while (result.hasNext()) { + val compactBlock = result.next() + dao.insert(CompactBlock(compactBlock.height.toInt(), compactBlock.toByteArray())) + System.err.println("stored block at height: ${compactBlock.height}") + } + } + + private fun scanData() { + Log.e("tezt", "scanning blocks...") + val result = converter.scanBlocks( + cacheDbPath, + "/data/user/0/cash.z.wallet.sdk.test/databases/data-glue.db", + "dummyseed".toByteArray(), + 373070 + ) + System.err.println("done.") + } + + fun heightOf(height: Long): Service.BlockID { + return BlockID.newBuilder().setHeight(height).build() + } + + companion object { + // jni + val converter: JniConverter = JniConverter() + + // db + private lateinit var dao: CompactBlockDao + private lateinit var db: CompactBlockDb + private const val cacheDbName = "dummy-cache-glue.db" + private const val cacheDbPath = "/data/user/0/cash.z.wallet.sdk.test/databases/$cacheDbName" + + // grpc + lateinit var blockingStub: CompactTxStreamerGrpc.CompactTxStreamerBlockingStub + + @BeforeClass + @JvmStatic + fun setup() { + converter.initLogs() + + val channel = ManagedChannelBuilder.forAddress("10.0.2.2", 9067).usePlaintext().build() + blockingStub = CompactTxStreamerGrpc.newBlockingStub(channel) + + db = Room + .databaseBuilder( + ApplicationProvider.getApplicationContext(), + CompactBlockDb::class.java, + cacheDbName + ) + .setJournalMode(RoomDatabase.JournalMode.TRUNCATE) + .fallbackToDestructiveMigration() + .build() + .apply { dao = complactBlockDao() } + } + + @AfterClass + @JvmStatic + fun close() { + db.close() + (blockingStub.channel as ManagedChannel).shutdown().awaitTermination(2000L, TimeUnit.MILLISECONDS) + } + } +} diff --git a/src/androidTest/java/cash/z/wallet/sdk/db/GlueSetupIntegrationTest.kt b/src/androidTest/java/cash/z/wallet/sdk/db/GlueSetupIntegrationTest.kt new file mode 100644 index 00000000..972a83cb --- /dev/null +++ b/src/androidTest/java/cash/z/wallet/sdk/db/GlueSetupIntegrationTest.kt @@ -0,0 +1,112 @@ +package cash.z.wallet.sdk.db + +import android.util.Log +import androidx.arch.core.executor.testing.InstantTaskExecutorRule +import androidx.room.Room +import androidx.room.RoomDatabase +import androidx.test.core.app.ApplicationProvider +import cash.z.wallet.sdk.dao.BlockDao +import cash.z.wallet.sdk.dao.CompactBlockDao +import cash.z.wallet.sdk.dao.NoteDao +import cash.z.wallet.sdk.dao.TransactionDao +import cash.z.wallet.sdk.ext.toBlockHeight +import cash.z.wallet.sdk.jni.JniConverter +import cash.z.wallet.sdk.vo.CompactBlock +import io.grpc.ManagedChannel +import io.grpc.ManagedChannelBuilder +import org.junit.* +import org.junit.Assert.* +import rpc.CompactTxStreamerGrpc +import rpc.Service +import rpc.Service.* +import java.util.concurrent.TimeUnit + +class GlueSetupIntegrationTest { + @get:Rule + var instantTaskExecutorRule = InstantTaskExecutorRule() + + @Test + fun testDbExists() { + assertNotNull(db) +// Log.e("tezt", "addData") +// addData() +// Log.e("tezt", "scanData") +// scanData() +// Log.e("tezt", "checkResults") +// checkResults() + } + + private fun checkResults() { + Thread.sleep(15000L) + } + + private fun addData() { + val result = blockingStub.getBlockRange( + BlockRange.newBuilder() + .setStart(373070L.toBlockHeight()) + .setEnd(373085L.toBlockHeight()) + .build() + ) + while (result.hasNext()) { + val compactBlock = result.next() + dao.insert(CompactBlock(compactBlock.height.toInt(), compactBlock.toByteArray())) + System.err.println("stored block at height: ${compactBlock.height}") + } + } + + private fun scanData() { + Log.e("tezt", "scanning blocks...") + val result = converter.scanBlocks( + cacheDbPath, + "/data/user/0/cash.z.wallet.sdk.test/databases/data-glue.db", + "dummyseed".toByteArray(), + 373070 + ) + System.err.println("done.") + } + + fun heightOf(height: Long): Service.BlockID { + return BlockID.newBuilder().setHeight(height).build() + } + + companion object { + // jni + val converter: JniConverter = JniConverter() + + // db + private lateinit var dao: CompactBlockDao + private lateinit var db: CompactBlockDb + private const val cacheDbName = "dummy-cache-glue.db" + private const val cacheDbPath = "/data/user/0/cash.z.wallet.sdk.test/databases/$cacheDbName" + + // grpc + lateinit var blockingStub: CompactTxStreamerGrpc.CompactTxStreamerBlockingStub + + @BeforeClass + @JvmStatic + fun setup() { + converter.initLogs() + + val channel = ManagedChannelBuilder.forAddress("10.0.2.2", 9067).usePlaintext().build() + blockingStub = CompactTxStreamerGrpc.newBlockingStub(channel) + + db = Room + .databaseBuilder( + ApplicationProvider.getApplicationContext(), + CompactBlockDb::class.java, + cacheDbName + ) + .setJournalMode(RoomDatabase.JournalMode.TRUNCATE) + .fallbackToDestructiveMigration() + .build() + .apply { dao = complactBlockDao() } + } + + @AfterClass + @JvmStatic + fun close() { + db.close() + (blockingStub.channel as ManagedChannel).shutdown().awaitTermination(2000L, TimeUnit.MILLISECONDS) + } + } +} diff --git a/src/generated/source/grpc/debug/grpc/rpc/CompactTxStreamerGrpc.java b/src/generated/source/grpc/debug/grpc/rpc/CompactTxStreamerGrpc.java new file mode 100644 index 00000000..456fe026 --- /dev/null +++ b/src/generated/source/grpc/debug/grpc/rpc/CompactTxStreamerGrpc.java @@ -0,0 +1,532 @@ +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 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 getGetLatestBlockMethod() { + io.grpc.MethodDescriptor getGetLatestBlockMethod; + if ((getGetLatestBlockMethod = CompactTxStreamerGrpc.getGetLatestBlockMethod) == null) { + synchronized (CompactTxStreamerGrpc.class) { + if ((getGetLatestBlockMethod = CompactTxStreamerGrpc.getGetLatestBlockMethod) == null) { + CompactTxStreamerGrpc.getGetLatestBlockMethod = getGetLatestBlockMethod = + io.grpc.MethodDescriptor.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 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 getGetBlockMethod() { + io.grpc.MethodDescriptor getGetBlockMethod; + if ((getGetBlockMethod = CompactTxStreamerGrpc.getGetBlockMethod) == null) { + synchronized (CompactTxStreamerGrpc.class) { + if ((getGetBlockMethod = CompactTxStreamerGrpc.getGetBlockMethod) == null) { + CompactTxStreamerGrpc.getGetBlockMethod = getGetBlockMethod = + io.grpc.MethodDescriptor.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 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 getGetBlockRangeMethod() { + io.grpc.MethodDescriptor getGetBlockRangeMethod; + if ((getGetBlockRangeMethod = CompactTxStreamerGrpc.getGetBlockRangeMethod) == null) { + synchronized (CompactTxStreamerGrpc.class) { + if ((getGetBlockRangeMethod = CompactTxStreamerGrpc.getGetBlockRangeMethod) == null) { + CompactTxStreamerGrpc.getGetBlockRangeMethod = getGetBlockRangeMethod = + io.grpc.MethodDescriptor.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 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 getGetTransactionMethod() { + io.grpc.MethodDescriptor getGetTransactionMethod; + if ((getGetTransactionMethod = CompactTxStreamerGrpc.getGetTransactionMethod) == null) { + synchronized (CompactTxStreamerGrpc.class) { + if ((getGetTransactionMethod = CompactTxStreamerGrpc.getGetTransactionMethod) == null) { + CompactTxStreamerGrpc.getGetTransactionMethod = getGetTransactionMethod = + io.grpc.MethodDescriptor.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 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 getSendTransactionMethod() { + io.grpc.MethodDescriptor getSendTransactionMethod; + if ((getSendTransactionMethod = CompactTxStreamerGrpc.getSendTransactionMethod) == null) { + synchronized (CompactTxStreamerGrpc.class) { + if ((getSendTransactionMethod = CompactTxStreamerGrpc.getSendTransactionMethod) == null) { + CompactTxStreamerGrpc.getSendTransactionMethod = getSendTransactionMethod = + io.grpc.MethodDescriptor.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 responseObserver) { + asyncUnimplementedUnaryCall(getGetLatestBlockMethod(), responseObserver); + } + + /** + */ + public void getBlock(rpc.Service.BlockID request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetBlockMethod(), responseObserver); + } + + /** + */ + public void getBlockRange(rpc.Service.BlockRange request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetBlockRangeMethod(), responseObserver); + } + + /** + */ + public void getTransaction(rpc.Service.TxFilter request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetTransactionMethod(), responseObserver); + } + + /** + */ + public void sendTransaction(rpc.Service.RawTransaction request, + io.grpc.stub.StreamObserver 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 { + 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 responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetLatestBlockMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getBlock(rpc.Service.BlockID request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetBlockMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getBlockRange(rpc.Service.BlockRange request, + io.grpc.stub.StreamObserver responseObserver) { + asyncServerStreamingCall( + getChannel().newCall(getGetBlockRangeMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getTransaction(rpc.Service.TxFilter request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetTransactionMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void sendTransaction(rpc.Service.RawTransaction request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getSendTransactionMethod(), getCallOptions()), request, responseObserver); + } + } + + /** + */ + public static final class CompactTxStreamerBlockingStub extends io.grpc.stub.AbstractStub { + 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 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 { + 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 getLatestBlock( + rpc.Service.ChainSpec request) { + return futureUnaryCall( + getChannel().newCall(getGetLatestBlockMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getBlock( + rpc.Service.BlockID request) { + return futureUnaryCall( + getChannel().newCall(getGetBlockMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getTransaction( + rpc.Service.TxFilter request) { + return futureUnaryCall( + getChannel().newCall(getGetTransactionMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture 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 implements + io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + 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 responseObserver) { + switch (methodId) { + case METHODID_GET_LATEST_BLOCK: + serviceImpl.getLatestBlock((rpc.Service.ChainSpec) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_BLOCK: + serviceImpl.getBlock((rpc.Service.BlockID) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_BLOCK_RANGE: + serviceImpl.getBlockRange((rpc.Service.BlockRange) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_TRANSACTION: + serviceImpl.getTransaction((rpc.Service.TxFilter) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_SEND_TRANSACTION: + serviceImpl.sendTransaction((rpc.Service.RawTransaction) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver 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; + } +} diff --git a/src/generated/source/grpc/debug/javalite/rpc/CompactFormats.java b/src/generated/source/grpc/debug/javalite/rpc/CompactFormats.java new file mode 100644 index 00000000..28ba9a8a --- /dev/null +++ b/src/generated/source/grpc/debug/javalite/rpc/CompactFormats.java @@ -0,0 +1,2690 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: compact_formats.proto + +package rpc; + +public final class CompactFormats { + private CompactFormats() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + public interface CompactBlockOrBuilder extends + // @@protoc_insertion_point(interface_extends:rpc.CompactBlock) + com.google.protobuf.MessageLiteOrBuilder { + + /** + *
+     * the version of this wire format, for storage
+     * 
+ * + * optional uint32 protoVersion = 1; + */ + int getProtoVersion(); + + /** + *
+     * the height of this block
+     * 
+ * + * optional uint64 height = 2; + */ + long getHeight(); + + /** + * optional bytes hash = 3; + */ + com.google.protobuf.ByteString getHash(); + + /** + * optional uint32 time = 4; + */ + int getTime(); + + /** + *
+     * (hash and time) OR (full header)
+     * 
+ * + * optional bytes header = 5; + */ + com.google.protobuf.ByteString getHeader(); + + /** + *
+     * compact transactions from this block
+     * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + java.util.List + getVtxList(); + /** + *
+     * compact transactions from this block
+     * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + rpc.CompactFormats.CompactTx getVtx(int index); + /** + *
+     * compact transactions from this block
+     * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + int getVtxCount(); + } + /** + *
+   * CompactBlock is a packaging of ONLY the data from a block that's needed to:
+   *   1. Detect a payment to your shielded Sapling address
+   *   2. Detect a spend of your shielded Sapling notes
+   *   3. Update your witnesses to generate new Sapling spend proofs.
+   * 
+ * + * Protobuf type {@code rpc.CompactBlock} + */ + public static final class CompactBlock extends + com.google.protobuf.GeneratedMessageLite< + CompactBlock, CompactBlock.Builder> implements + // @@protoc_insertion_point(message_implements:rpc.CompactBlock) + CompactBlockOrBuilder { + private CompactBlock() { + hash_ = com.google.protobuf.ByteString.EMPTY; + header_ = com.google.protobuf.ByteString.EMPTY; + vtx_ = emptyProtobufList(); + } + private int bitField0_; + public static final int PROTOVERSION_FIELD_NUMBER = 1; + private int protoVersion_; + /** + *
+     * the version of this wire format, for storage
+     * 
+ * + * optional uint32 protoVersion = 1; + */ + public int getProtoVersion() { + return protoVersion_; + } + /** + *
+     * the version of this wire format, for storage
+     * 
+ * + * optional uint32 protoVersion = 1; + */ + private void setProtoVersion(int value) { + + protoVersion_ = value; + } + /** + *
+     * the version of this wire format, for storage
+     * 
+ * + * optional uint32 protoVersion = 1; + */ + private void clearProtoVersion() { + + protoVersion_ = 0; + } + + public static final int HEIGHT_FIELD_NUMBER = 2; + private long height_; + /** + *
+     * the height of this block
+     * 
+ * + * optional uint64 height = 2; + */ + public long getHeight() { + return height_; + } + /** + *
+     * the height of this block
+     * 
+ * + * optional uint64 height = 2; + */ + private void setHeight(long value) { + + height_ = value; + } + /** + *
+     * the height of this block
+     * 
+ * + * optional uint64 height = 2; + */ + private void clearHeight() { + + height_ = 0L; + } + + public static final int HASH_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString hash_; + /** + * optional bytes hash = 3; + */ + public com.google.protobuf.ByteString getHash() { + return hash_; + } + /** + * optional bytes hash = 3; + */ + private void setHash(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + hash_ = value; + } + /** + * optional bytes hash = 3; + */ + private void clearHash() { + + hash_ = getDefaultInstance().getHash(); + } + + public static final int TIME_FIELD_NUMBER = 4; + private int time_; + /** + * optional uint32 time = 4; + */ + public int getTime() { + return time_; + } + /** + * optional uint32 time = 4; + */ + private void setTime(int value) { + + time_ = value; + } + /** + * optional uint32 time = 4; + */ + private void clearTime() { + + time_ = 0; + } + + public static final int HEADER_FIELD_NUMBER = 5; + private com.google.protobuf.ByteString header_; + /** + *
+     * (hash and time) OR (full header)
+     * 
+ * + * optional bytes header = 5; + */ + public com.google.protobuf.ByteString getHeader() { + return header_; + } + /** + *
+     * (hash and time) OR (full header)
+     * 
+ * + * optional bytes header = 5; + */ + private void setHeader(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + header_ = value; + } + /** + *
+     * (hash and time) OR (full header)
+     * 
+ * + * optional bytes header = 5; + */ + private void clearHeader() { + + header_ = getDefaultInstance().getHeader(); + } + + public static final int VTX_FIELD_NUMBER = 6; + private com.google.protobuf.Internal.ProtobufList vtx_; + /** + *
+     * compact transactions from this block
+     * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + public java.util.List getVtxList() { + return vtx_; + } + /** + *
+     * compact transactions from this block
+     * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + public java.util.List + getVtxOrBuilderList() { + return vtx_; + } + /** + *
+     * compact transactions from this block
+     * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + public int getVtxCount() { + return vtx_.size(); + } + /** + *
+     * compact transactions from this block
+     * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + public rpc.CompactFormats.CompactTx getVtx(int index) { + return vtx_.get(index); + } + /** + *
+     * compact transactions from this block
+     * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + public rpc.CompactFormats.CompactTxOrBuilder getVtxOrBuilder( + int index) { + return vtx_.get(index); + } + private void ensureVtxIsMutable() { + if (!vtx_.isModifiable()) { + vtx_ = + com.google.protobuf.GeneratedMessageLite.mutableCopy(vtx_); + } + } + + /** + *
+     * compact transactions from this block
+     * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + private void setVtx( + int index, rpc.CompactFormats.CompactTx value) { + if (value == null) { + throw new NullPointerException(); + } + ensureVtxIsMutable(); + vtx_.set(index, value); + } + /** + *
+     * compact transactions from this block
+     * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + private void setVtx( + int index, rpc.CompactFormats.CompactTx.Builder builderForValue) { + ensureVtxIsMutable(); + vtx_.set(index, builderForValue.build()); + } + /** + *
+     * compact transactions from this block
+     * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + private void addVtx(rpc.CompactFormats.CompactTx value) { + if (value == null) { + throw new NullPointerException(); + } + ensureVtxIsMutable(); + vtx_.add(value); + } + /** + *
+     * compact transactions from this block
+     * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + private void addVtx( + int index, rpc.CompactFormats.CompactTx value) { + if (value == null) { + throw new NullPointerException(); + } + ensureVtxIsMutable(); + vtx_.add(index, value); + } + /** + *
+     * compact transactions from this block
+     * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + private void addVtx( + rpc.CompactFormats.CompactTx.Builder builderForValue) { + ensureVtxIsMutable(); + vtx_.add(builderForValue.build()); + } + /** + *
+     * compact transactions from this block
+     * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + private void addVtx( + int index, rpc.CompactFormats.CompactTx.Builder builderForValue) { + ensureVtxIsMutable(); + vtx_.add(index, builderForValue.build()); + } + /** + *
+     * compact transactions from this block
+     * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + private void addAllVtx( + java.lang.Iterable values) { + ensureVtxIsMutable(); + com.google.protobuf.AbstractMessageLite.addAll( + values, vtx_); + } + /** + *
+     * compact transactions from this block
+     * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + private void clearVtx() { + vtx_ = emptyProtobufList(); + } + /** + *
+     * compact transactions from this block
+     * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + private void removeVtx(int index) { + ensureVtxIsMutable(); + vtx_.remove(index); + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (protoVersion_ != 0) { + output.writeUInt32(1, protoVersion_); + } + if (height_ != 0L) { + output.writeUInt64(2, height_); + } + if (!hash_.isEmpty()) { + output.writeBytes(3, hash_); + } + if (time_ != 0) { + output.writeUInt32(4, time_); + } + if (!header_.isEmpty()) { + output.writeBytes(5, header_); + } + for (int i = 0; i < vtx_.size(); i++) { + output.writeMessage(6, vtx_.get(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (protoVersion_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeUInt32Size(1, protoVersion_); + } + if (height_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeUInt64Size(2, height_); + } + if (!hash_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, hash_); + } + if (time_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeUInt32Size(4, time_); + } + if (!header_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(5, header_); + } + for (int i = 0; i < vtx_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(6, vtx_.get(i)); + } + memoizedSerializedSize = size; + return size; + } + + public static rpc.CompactFormats.CompactBlock parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data); + } + public static rpc.CompactFormats.CompactBlock parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data, extensionRegistry); + } + public static rpc.CompactFormats.CompactBlock parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data); + } + public static rpc.CompactFormats.CompactBlock parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data, extensionRegistry); + } + public static rpc.CompactFormats.CompactBlock parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input); + } + public static rpc.CompactFormats.CompactBlock parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input, extensionRegistry); + } + public static rpc.CompactFormats.CompactBlock parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return parseDelimitedFrom(DEFAULT_INSTANCE, input); + } + public static rpc.CompactFormats.CompactBlock parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return parseDelimitedFrom(DEFAULT_INSTANCE, input, extensionRegistry); + } + public static rpc.CompactFormats.CompactBlock parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input); + } + public static rpc.CompactFormats.CompactBlock parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input, extensionRegistry); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(rpc.CompactFormats.CompactBlock prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + /** + *
+     * CompactBlock is a packaging of ONLY the data from a block that's needed to:
+     *   1. Detect a payment to your shielded Sapling address
+     *   2. Detect a spend of your shielded Sapling notes
+     *   3. Update your witnesses to generate new Sapling spend proofs.
+     * 
+ * + * Protobuf type {@code rpc.CompactBlock} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageLite.Builder< + rpc.CompactFormats.CompactBlock, Builder> implements + // @@protoc_insertion_point(builder_implements:rpc.CompactBlock) + rpc.CompactFormats.CompactBlockOrBuilder { + // Construct using rpc.CompactFormats.CompactBlock.newBuilder() + private Builder() { + super(DEFAULT_INSTANCE); + } + + + /** + *
+       * the version of this wire format, for storage
+       * 
+ * + * optional uint32 protoVersion = 1; + */ + public int getProtoVersion() { + return instance.getProtoVersion(); + } + /** + *
+       * the version of this wire format, for storage
+       * 
+ * + * optional uint32 protoVersion = 1; + */ + public Builder setProtoVersion(int value) { + copyOnWrite(); + instance.setProtoVersion(value); + return this; + } + /** + *
+       * the version of this wire format, for storage
+       * 
+ * + * optional uint32 protoVersion = 1; + */ + public Builder clearProtoVersion() { + copyOnWrite(); + instance.clearProtoVersion(); + return this; + } + + /** + *
+       * the height of this block
+       * 
+ * + * optional uint64 height = 2; + */ + public long getHeight() { + return instance.getHeight(); + } + /** + *
+       * the height of this block
+       * 
+ * + * optional uint64 height = 2; + */ + public Builder setHeight(long value) { + copyOnWrite(); + instance.setHeight(value); + return this; + } + /** + *
+       * the height of this block
+       * 
+ * + * optional uint64 height = 2; + */ + public Builder clearHeight() { + copyOnWrite(); + instance.clearHeight(); + return this; + } + + /** + * optional bytes hash = 3; + */ + public com.google.protobuf.ByteString getHash() { + return instance.getHash(); + } + /** + * optional bytes hash = 3; + */ + public Builder setHash(com.google.protobuf.ByteString value) { + copyOnWrite(); + instance.setHash(value); + return this; + } + /** + * optional bytes hash = 3; + */ + public Builder clearHash() { + copyOnWrite(); + instance.clearHash(); + return this; + } + + /** + * optional uint32 time = 4; + */ + public int getTime() { + return instance.getTime(); + } + /** + * optional uint32 time = 4; + */ + public Builder setTime(int value) { + copyOnWrite(); + instance.setTime(value); + return this; + } + /** + * optional uint32 time = 4; + */ + public Builder clearTime() { + copyOnWrite(); + instance.clearTime(); + return this; + } + + /** + *
+       * (hash and time) OR (full header)
+       * 
+ * + * optional bytes header = 5; + */ + public com.google.protobuf.ByteString getHeader() { + return instance.getHeader(); + } + /** + *
+       * (hash and time) OR (full header)
+       * 
+ * + * optional bytes header = 5; + */ + public Builder setHeader(com.google.protobuf.ByteString value) { + copyOnWrite(); + instance.setHeader(value); + return this; + } + /** + *
+       * (hash and time) OR (full header)
+       * 
+ * + * optional bytes header = 5; + */ + public Builder clearHeader() { + copyOnWrite(); + instance.clearHeader(); + return this; + } + + /** + *
+       * compact transactions from this block
+       * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + public java.util.List getVtxList() { + return java.util.Collections.unmodifiableList( + instance.getVtxList()); + } + /** + *
+       * compact transactions from this block
+       * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + public int getVtxCount() { + return instance.getVtxCount(); + }/** + *
+       * compact transactions from this block
+       * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + public rpc.CompactFormats.CompactTx getVtx(int index) { + return instance.getVtx(index); + } + /** + *
+       * compact transactions from this block
+       * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + public Builder setVtx( + int index, rpc.CompactFormats.CompactTx value) { + copyOnWrite(); + instance.setVtx(index, value); + return this; + } + /** + *
+       * compact transactions from this block
+       * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + public Builder setVtx( + int index, rpc.CompactFormats.CompactTx.Builder builderForValue) { + copyOnWrite(); + instance.setVtx(index, builderForValue); + return this; + } + /** + *
+       * compact transactions from this block
+       * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + public Builder addVtx(rpc.CompactFormats.CompactTx value) { + copyOnWrite(); + instance.addVtx(value); + return this; + } + /** + *
+       * compact transactions from this block
+       * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + public Builder addVtx( + int index, rpc.CompactFormats.CompactTx value) { + copyOnWrite(); + instance.addVtx(index, value); + return this; + } + /** + *
+       * compact transactions from this block
+       * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + public Builder addVtx( + rpc.CompactFormats.CompactTx.Builder builderForValue) { + copyOnWrite(); + instance.addVtx(builderForValue); + return this; + } + /** + *
+       * compact transactions from this block
+       * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + public Builder addVtx( + int index, rpc.CompactFormats.CompactTx.Builder builderForValue) { + copyOnWrite(); + instance.addVtx(index, builderForValue); + return this; + } + /** + *
+       * compact transactions from this block
+       * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + public Builder addAllVtx( + java.lang.Iterable values) { + copyOnWrite(); + instance.addAllVtx(values); + return this; + } + /** + *
+       * compact transactions from this block
+       * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + public Builder clearVtx() { + copyOnWrite(); + instance.clearVtx(); + return this; + } + /** + *
+       * compact transactions from this block
+       * 
+ * + * repeated .rpc.CompactTx vtx = 6; + */ + public Builder removeVtx(int index) { + copyOnWrite(); + instance.removeVtx(index); + return this; + } + + // @@protoc_insertion_point(builder_scope:rpc.CompactBlock) + } + protected final Object dynamicMethod( + com.google.protobuf.GeneratedMessageLite.MethodToInvoke method, + Object arg0, Object arg1) { + switch (method) { + case NEW_MUTABLE_INSTANCE: { + return new rpc.CompactFormats.CompactBlock(); + } + case IS_INITIALIZED: { + return DEFAULT_INSTANCE; + } + case MAKE_IMMUTABLE: { + vtx_.makeImmutable(); + return null; + } + case NEW_BUILDER: { + return new Builder(); + } + case VISIT: { + Visitor visitor = (Visitor) arg0; + rpc.CompactFormats.CompactBlock other = (rpc.CompactFormats.CompactBlock) arg1; + protoVersion_ = visitor.visitInt(protoVersion_ != 0, protoVersion_, + other.protoVersion_ != 0, other.protoVersion_); + height_ = visitor.visitLong(height_ != 0L, height_, + other.height_ != 0L, other.height_); + hash_ = visitor.visitByteString(hash_ != com.google.protobuf.ByteString.EMPTY, hash_, + other.hash_ != com.google.protobuf.ByteString.EMPTY, other.hash_); + time_ = visitor.visitInt(time_ != 0, time_, + other.time_ != 0, other.time_); + header_ = visitor.visitByteString(header_ != com.google.protobuf.ByteString.EMPTY, header_, + other.header_ != com.google.protobuf.ByteString.EMPTY, other.header_); + vtx_= visitor.visitList(vtx_, other.vtx_); + if (visitor == com.google.protobuf.GeneratedMessageLite.MergeFromVisitor + .INSTANCE) { + bitField0_ |= other.bitField0_; + } + return this; + } + case MERGE_FROM_STREAM: { + com.google.protobuf.CodedInputStream input = + (com.google.protobuf.CodedInputStream) arg0; + com.google.protobuf.ExtensionRegistryLite extensionRegistry = + (com.google.protobuf.ExtensionRegistryLite) arg1; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 8: { + + protoVersion_ = input.readUInt32(); + break; + } + case 16: { + + height_ = input.readUInt64(); + break; + } + case 26: { + + hash_ = input.readBytes(); + break; + } + case 32: { + + time_ = input.readUInt32(); + break; + } + case 42: { + + header_ = input.readBytes(); + break; + } + case 50: { + if (!vtx_.isModifiable()) { + vtx_ = + com.google.protobuf.GeneratedMessageLite.mutableCopy(vtx_); + } + vtx_.add( + input.readMessage(rpc.CompactFormats.CompactTx.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + } + } + case GET_DEFAULT_INSTANCE: { + return DEFAULT_INSTANCE; + } + case GET_PARSER: { + if (PARSER == null) { synchronized (rpc.CompactFormats.CompactBlock.class) { + if (PARSER == null) { + PARSER = new DefaultInstanceBasedParser(DEFAULT_INSTANCE); + } + } + } + return PARSER; + } + } + throw new UnsupportedOperationException(); + } + + + // @@protoc_insertion_point(class_scope:rpc.CompactBlock) + private static final rpc.CompactFormats.CompactBlock DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new CompactBlock(); + DEFAULT_INSTANCE.makeImmutable(); + } + + public static rpc.CompactFormats.CompactBlock getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static volatile com.google.protobuf.Parser PARSER; + + public static com.google.protobuf.Parser parser() { + return DEFAULT_INSTANCE.getParserForType(); + } + } + + public interface CompactTxOrBuilder extends + // @@protoc_insertion_point(interface_extends:rpc.CompactTx) + com.google.protobuf.MessageLiteOrBuilder { + + /** + *
+     * Index and hash will allow the receiver to call out to chain
+     * explorers or other data structures to retrieve more information
+     * about this transaction.
+     * 
+ * + * optional uint64 index = 1; + */ + long getIndex(); + + /** + * optional bytes hash = 2; + */ + com.google.protobuf.ByteString getHash(); + + /** + *
+     * The transaction fee: present if server can provide. In the case of a
+     * stateless server and a transaction with transparent inputs, this will be
+     * unset because the calculation requires reference to prior transactions.
+     * in a pure-Sapling context, the fee will be calculable as:
+     *    valueBalance + (sum(vPubNew) - sum(vPubOld) - sum(tOut))
+     * 
+ * + * optional uint32 fee = 3; + */ + int getFee(); + + /** + * repeated .rpc.CompactSpend spends = 4; + */ + java.util.List + getSpendsList(); + /** + * repeated .rpc.CompactSpend spends = 4; + */ + rpc.CompactFormats.CompactSpend getSpends(int index); + /** + * repeated .rpc.CompactSpend spends = 4; + */ + int getSpendsCount(); + + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + java.util.List + getOutputsList(); + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + rpc.CompactFormats.CompactOutput getOutputs(int index); + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + int getOutputsCount(); + } + /** + * Protobuf type {@code rpc.CompactTx} + */ + public static final class CompactTx extends + com.google.protobuf.GeneratedMessageLite< + CompactTx, CompactTx.Builder> implements + // @@protoc_insertion_point(message_implements:rpc.CompactTx) + CompactTxOrBuilder { + private CompactTx() { + hash_ = com.google.protobuf.ByteString.EMPTY; + spends_ = emptyProtobufList(); + outputs_ = emptyProtobufList(); + } + private int bitField0_; + public static final int INDEX_FIELD_NUMBER = 1; + private long index_; + /** + *
+     * Index and hash will allow the receiver to call out to chain
+     * explorers or other data structures to retrieve more information
+     * about this transaction.
+     * 
+ * + * optional uint64 index = 1; + */ + public long getIndex() { + return index_; + } + /** + *
+     * Index and hash will allow the receiver to call out to chain
+     * explorers or other data structures to retrieve more information
+     * about this transaction.
+     * 
+ * + * optional uint64 index = 1; + */ + private void setIndex(long value) { + + index_ = value; + } + /** + *
+     * Index and hash will allow the receiver to call out to chain
+     * explorers or other data structures to retrieve more information
+     * about this transaction.
+     * 
+ * + * optional uint64 index = 1; + */ + private void clearIndex() { + + index_ = 0L; + } + + public static final int HASH_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString hash_; + /** + * optional bytes hash = 2; + */ + public com.google.protobuf.ByteString getHash() { + return hash_; + } + /** + * optional bytes hash = 2; + */ + private void setHash(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + hash_ = value; + } + /** + * optional bytes hash = 2; + */ + private void clearHash() { + + hash_ = getDefaultInstance().getHash(); + } + + public static final int FEE_FIELD_NUMBER = 3; + private int fee_; + /** + *
+     * The transaction fee: present if server can provide. In the case of a
+     * stateless server and a transaction with transparent inputs, this will be
+     * unset because the calculation requires reference to prior transactions.
+     * in a pure-Sapling context, the fee will be calculable as:
+     *    valueBalance + (sum(vPubNew) - sum(vPubOld) - sum(tOut))
+     * 
+ * + * optional uint32 fee = 3; + */ + public int getFee() { + return fee_; + } + /** + *
+     * The transaction fee: present if server can provide. In the case of a
+     * stateless server and a transaction with transparent inputs, this will be
+     * unset because the calculation requires reference to prior transactions.
+     * in a pure-Sapling context, the fee will be calculable as:
+     *    valueBalance + (sum(vPubNew) - sum(vPubOld) - sum(tOut))
+     * 
+ * + * optional uint32 fee = 3; + */ + private void setFee(int value) { + + fee_ = value; + } + /** + *
+     * The transaction fee: present if server can provide. In the case of a
+     * stateless server and a transaction with transparent inputs, this will be
+     * unset because the calculation requires reference to prior transactions.
+     * in a pure-Sapling context, the fee will be calculable as:
+     *    valueBalance + (sum(vPubNew) - sum(vPubOld) - sum(tOut))
+     * 
+ * + * optional uint32 fee = 3; + */ + private void clearFee() { + + fee_ = 0; + } + + public static final int SPENDS_FIELD_NUMBER = 4; + private com.google.protobuf.Internal.ProtobufList spends_; + /** + * repeated .rpc.CompactSpend spends = 4; + */ + public java.util.List getSpendsList() { + return spends_; + } + /** + * repeated .rpc.CompactSpend spends = 4; + */ + public java.util.List + getSpendsOrBuilderList() { + return spends_; + } + /** + * repeated .rpc.CompactSpend spends = 4; + */ + public int getSpendsCount() { + return spends_.size(); + } + /** + * repeated .rpc.CompactSpend spends = 4; + */ + public rpc.CompactFormats.CompactSpend getSpends(int index) { + return spends_.get(index); + } + /** + * repeated .rpc.CompactSpend spends = 4; + */ + public rpc.CompactFormats.CompactSpendOrBuilder getSpendsOrBuilder( + int index) { + return spends_.get(index); + } + private void ensureSpendsIsMutable() { + if (!spends_.isModifiable()) { + spends_ = + com.google.protobuf.GeneratedMessageLite.mutableCopy(spends_); + } + } + + /** + * repeated .rpc.CompactSpend spends = 4; + */ + private void setSpends( + int index, rpc.CompactFormats.CompactSpend value) { + if (value == null) { + throw new NullPointerException(); + } + ensureSpendsIsMutable(); + spends_.set(index, value); + } + /** + * repeated .rpc.CompactSpend spends = 4; + */ + private void setSpends( + int index, rpc.CompactFormats.CompactSpend.Builder builderForValue) { + ensureSpendsIsMutable(); + spends_.set(index, builderForValue.build()); + } + /** + * repeated .rpc.CompactSpend spends = 4; + */ + private void addSpends(rpc.CompactFormats.CompactSpend value) { + if (value == null) { + throw new NullPointerException(); + } + ensureSpendsIsMutable(); + spends_.add(value); + } + /** + * repeated .rpc.CompactSpend spends = 4; + */ + private void addSpends( + int index, rpc.CompactFormats.CompactSpend value) { + if (value == null) { + throw new NullPointerException(); + } + ensureSpendsIsMutable(); + spends_.add(index, value); + } + /** + * repeated .rpc.CompactSpend spends = 4; + */ + private void addSpends( + rpc.CompactFormats.CompactSpend.Builder builderForValue) { + ensureSpendsIsMutable(); + spends_.add(builderForValue.build()); + } + /** + * repeated .rpc.CompactSpend spends = 4; + */ + private void addSpends( + int index, rpc.CompactFormats.CompactSpend.Builder builderForValue) { + ensureSpendsIsMutable(); + spends_.add(index, builderForValue.build()); + } + /** + * repeated .rpc.CompactSpend spends = 4; + */ + private void addAllSpends( + java.lang.Iterable values) { + ensureSpendsIsMutable(); + com.google.protobuf.AbstractMessageLite.addAll( + values, spends_); + } + /** + * repeated .rpc.CompactSpend spends = 4; + */ + private void clearSpends() { + spends_ = emptyProtobufList(); + } + /** + * repeated .rpc.CompactSpend spends = 4; + */ + private void removeSpends(int index) { + ensureSpendsIsMutable(); + spends_.remove(index); + } + + public static final int OUTPUTS_FIELD_NUMBER = 5; + private com.google.protobuf.Internal.ProtobufList outputs_; + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + public java.util.List getOutputsList() { + return outputs_; + } + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + public java.util.List + getOutputsOrBuilderList() { + return outputs_; + } + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + public int getOutputsCount() { + return outputs_.size(); + } + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + public rpc.CompactFormats.CompactOutput getOutputs(int index) { + return outputs_.get(index); + } + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + public rpc.CompactFormats.CompactOutputOrBuilder getOutputsOrBuilder( + int index) { + return outputs_.get(index); + } + private void ensureOutputsIsMutable() { + if (!outputs_.isModifiable()) { + outputs_ = + com.google.protobuf.GeneratedMessageLite.mutableCopy(outputs_); + } + } + + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + private void setOutputs( + int index, rpc.CompactFormats.CompactOutput value) { + if (value == null) { + throw new NullPointerException(); + } + ensureOutputsIsMutable(); + outputs_.set(index, value); + } + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + private void setOutputs( + int index, rpc.CompactFormats.CompactOutput.Builder builderForValue) { + ensureOutputsIsMutable(); + outputs_.set(index, builderForValue.build()); + } + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + private void addOutputs(rpc.CompactFormats.CompactOutput value) { + if (value == null) { + throw new NullPointerException(); + } + ensureOutputsIsMutable(); + outputs_.add(value); + } + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + private void addOutputs( + int index, rpc.CompactFormats.CompactOutput value) { + if (value == null) { + throw new NullPointerException(); + } + ensureOutputsIsMutable(); + outputs_.add(index, value); + } + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + private void addOutputs( + rpc.CompactFormats.CompactOutput.Builder builderForValue) { + ensureOutputsIsMutable(); + outputs_.add(builderForValue.build()); + } + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + private void addOutputs( + int index, rpc.CompactFormats.CompactOutput.Builder builderForValue) { + ensureOutputsIsMutable(); + outputs_.add(index, builderForValue.build()); + } + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + private void addAllOutputs( + java.lang.Iterable values) { + ensureOutputsIsMutable(); + com.google.protobuf.AbstractMessageLite.addAll( + values, outputs_); + } + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + private void clearOutputs() { + outputs_ = emptyProtobufList(); + } + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + private void removeOutputs(int index) { + ensureOutputsIsMutable(); + outputs_.remove(index); + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (index_ != 0L) { + output.writeUInt64(1, index_); + } + if (!hash_.isEmpty()) { + output.writeBytes(2, hash_); + } + if (fee_ != 0) { + output.writeUInt32(3, fee_); + } + for (int i = 0; i < spends_.size(); i++) { + output.writeMessage(4, spends_.get(i)); + } + for (int i = 0; i < outputs_.size(); i++) { + output.writeMessage(5, outputs_.get(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (index_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeUInt64Size(1, index_); + } + if (!hash_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, hash_); + } + if (fee_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeUInt32Size(3, fee_); + } + for (int i = 0; i < spends_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, spends_.get(i)); + } + for (int i = 0; i < outputs_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, outputs_.get(i)); + } + memoizedSerializedSize = size; + return size; + } + + public static rpc.CompactFormats.CompactTx parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data); + } + public static rpc.CompactFormats.CompactTx parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data, extensionRegistry); + } + public static rpc.CompactFormats.CompactTx parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data); + } + public static rpc.CompactFormats.CompactTx parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data, extensionRegistry); + } + public static rpc.CompactFormats.CompactTx parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input); + } + public static rpc.CompactFormats.CompactTx parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input, extensionRegistry); + } + public static rpc.CompactFormats.CompactTx parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return parseDelimitedFrom(DEFAULT_INSTANCE, input); + } + public static rpc.CompactFormats.CompactTx parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return parseDelimitedFrom(DEFAULT_INSTANCE, input, extensionRegistry); + } + public static rpc.CompactFormats.CompactTx parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input); + } + public static rpc.CompactFormats.CompactTx parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input, extensionRegistry); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(rpc.CompactFormats.CompactTx prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + /** + * Protobuf type {@code rpc.CompactTx} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageLite.Builder< + rpc.CompactFormats.CompactTx, Builder> implements + // @@protoc_insertion_point(builder_implements:rpc.CompactTx) + rpc.CompactFormats.CompactTxOrBuilder { + // Construct using rpc.CompactFormats.CompactTx.newBuilder() + private Builder() { + super(DEFAULT_INSTANCE); + } + + + /** + *
+       * Index and hash will allow the receiver to call out to chain
+       * explorers or other data structures to retrieve more information
+       * about this transaction.
+       * 
+ * + * optional uint64 index = 1; + */ + public long getIndex() { + return instance.getIndex(); + } + /** + *
+       * Index and hash will allow the receiver to call out to chain
+       * explorers or other data structures to retrieve more information
+       * about this transaction.
+       * 
+ * + * optional uint64 index = 1; + */ + public Builder setIndex(long value) { + copyOnWrite(); + instance.setIndex(value); + return this; + } + /** + *
+       * Index and hash will allow the receiver to call out to chain
+       * explorers or other data structures to retrieve more information
+       * about this transaction.
+       * 
+ * + * optional uint64 index = 1; + */ + public Builder clearIndex() { + copyOnWrite(); + instance.clearIndex(); + return this; + } + + /** + * optional bytes hash = 2; + */ + public com.google.protobuf.ByteString getHash() { + return instance.getHash(); + } + /** + * optional bytes hash = 2; + */ + public Builder setHash(com.google.protobuf.ByteString value) { + copyOnWrite(); + instance.setHash(value); + return this; + } + /** + * optional bytes hash = 2; + */ + public Builder clearHash() { + copyOnWrite(); + instance.clearHash(); + return this; + } + + /** + *
+       * The transaction fee: present if server can provide. In the case of a
+       * stateless server and a transaction with transparent inputs, this will be
+       * unset because the calculation requires reference to prior transactions.
+       * in a pure-Sapling context, the fee will be calculable as:
+       *    valueBalance + (sum(vPubNew) - sum(vPubOld) - sum(tOut))
+       * 
+ * + * optional uint32 fee = 3; + */ + public int getFee() { + return instance.getFee(); + } + /** + *
+       * The transaction fee: present if server can provide. In the case of a
+       * stateless server and a transaction with transparent inputs, this will be
+       * unset because the calculation requires reference to prior transactions.
+       * in a pure-Sapling context, the fee will be calculable as:
+       *    valueBalance + (sum(vPubNew) - sum(vPubOld) - sum(tOut))
+       * 
+ * + * optional uint32 fee = 3; + */ + public Builder setFee(int value) { + copyOnWrite(); + instance.setFee(value); + return this; + } + /** + *
+       * The transaction fee: present if server can provide. In the case of a
+       * stateless server and a transaction with transparent inputs, this will be
+       * unset because the calculation requires reference to prior transactions.
+       * in a pure-Sapling context, the fee will be calculable as:
+       *    valueBalance + (sum(vPubNew) - sum(vPubOld) - sum(tOut))
+       * 
+ * + * optional uint32 fee = 3; + */ + public Builder clearFee() { + copyOnWrite(); + instance.clearFee(); + return this; + } + + /** + * repeated .rpc.CompactSpend spends = 4; + */ + public java.util.List getSpendsList() { + return java.util.Collections.unmodifiableList( + instance.getSpendsList()); + } + /** + * repeated .rpc.CompactSpend spends = 4; + */ + public int getSpendsCount() { + return instance.getSpendsCount(); + }/** + * repeated .rpc.CompactSpend spends = 4; + */ + public rpc.CompactFormats.CompactSpend getSpends(int index) { + return instance.getSpends(index); + } + /** + * repeated .rpc.CompactSpend spends = 4; + */ + public Builder setSpends( + int index, rpc.CompactFormats.CompactSpend value) { + copyOnWrite(); + instance.setSpends(index, value); + return this; + } + /** + * repeated .rpc.CompactSpend spends = 4; + */ + public Builder setSpends( + int index, rpc.CompactFormats.CompactSpend.Builder builderForValue) { + copyOnWrite(); + instance.setSpends(index, builderForValue); + return this; + } + /** + * repeated .rpc.CompactSpend spends = 4; + */ + public Builder addSpends(rpc.CompactFormats.CompactSpend value) { + copyOnWrite(); + instance.addSpends(value); + return this; + } + /** + * repeated .rpc.CompactSpend spends = 4; + */ + public Builder addSpends( + int index, rpc.CompactFormats.CompactSpend value) { + copyOnWrite(); + instance.addSpends(index, value); + return this; + } + /** + * repeated .rpc.CompactSpend spends = 4; + */ + public Builder addSpends( + rpc.CompactFormats.CompactSpend.Builder builderForValue) { + copyOnWrite(); + instance.addSpends(builderForValue); + return this; + } + /** + * repeated .rpc.CompactSpend spends = 4; + */ + public Builder addSpends( + int index, rpc.CompactFormats.CompactSpend.Builder builderForValue) { + copyOnWrite(); + instance.addSpends(index, builderForValue); + return this; + } + /** + * repeated .rpc.CompactSpend spends = 4; + */ + public Builder addAllSpends( + java.lang.Iterable values) { + copyOnWrite(); + instance.addAllSpends(values); + return this; + } + /** + * repeated .rpc.CompactSpend spends = 4; + */ + public Builder clearSpends() { + copyOnWrite(); + instance.clearSpends(); + return this; + } + /** + * repeated .rpc.CompactSpend spends = 4; + */ + public Builder removeSpends(int index) { + copyOnWrite(); + instance.removeSpends(index); + return this; + } + + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + public java.util.List getOutputsList() { + return java.util.Collections.unmodifiableList( + instance.getOutputsList()); + } + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + public int getOutputsCount() { + return instance.getOutputsCount(); + }/** + * repeated .rpc.CompactOutput outputs = 5; + */ + public rpc.CompactFormats.CompactOutput getOutputs(int index) { + return instance.getOutputs(index); + } + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + public Builder setOutputs( + int index, rpc.CompactFormats.CompactOutput value) { + copyOnWrite(); + instance.setOutputs(index, value); + return this; + } + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + public Builder setOutputs( + int index, rpc.CompactFormats.CompactOutput.Builder builderForValue) { + copyOnWrite(); + instance.setOutputs(index, builderForValue); + return this; + } + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + public Builder addOutputs(rpc.CompactFormats.CompactOutput value) { + copyOnWrite(); + instance.addOutputs(value); + return this; + } + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + public Builder addOutputs( + int index, rpc.CompactFormats.CompactOutput value) { + copyOnWrite(); + instance.addOutputs(index, value); + return this; + } + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + public Builder addOutputs( + rpc.CompactFormats.CompactOutput.Builder builderForValue) { + copyOnWrite(); + instance.addOutputs(builderForValue); + return this; + } + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + public Builder addOutputs( + int index, rpc.CompactFormats.CompactOutput.Builder builderForValue) { + copyOnWrite(); + instance.addOutputs(index, builderForValue); + return this; + } + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + public Builder addAllOutputs( + java.lang.Iterable values) { + copyOnWrite(); + instance.addAllOutputs(values); + return this; + } + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + public Builder clearOutputs() { + copyOnWrite(); + instance.clearOutputs(); + return this; + } + /** + * repeated .rpc.CompactOutput outputs = 5; + */ + public Builder removeOutputs(int index) { + copyOnWrite(); + instance.removeOutputs(index); + return this; + } + + // @@protoc_insertion_point(builder_scope:rpc.CompactTx) + } + protected final Object dynamicMethod( + com.google.protobuf.GeneratedMessageLite.MethodToInvoke method, + Object arg0, Object arg1) { + switch (method) { + case NEW_MUTABLE_INSTANCE: { + return new rpc.CompactFormats.CompactTx(); + } + case IS_INITIALIZED: { + return DEFAULT_INSTANCE; + } + case MAKE_IMMUTABLE: { + spends_.makeImmutable(); + outputs_.makeImmutable(); + return null; + } + case NEW_BUILDER: { + return new Builder(); + } + case VISIT: { + Visitor visitor = (Visitor) arg0; + rpc.CompactFormats.CompactTx other = (rpc.CompactFormats.CompactTx) arg1; + index_ = visitor.visitLong(index_ != 0L, index_, + other.index_ != 0L, other.index_); + hash_ = visitor.visitByteString(hash_ != com.google.protobuf.ByteString.EMPTY, hash_, + other.hash_ != com.google.protobuf.ByteString.EMPTY, other.hash_); + fee_ = visitor.visitInt(fee_ != 0, fee_, + other.fee_ != 0, other.fee_); + spends_= visitor.visitList(spends_, other.spends_); + outputs_= visitor.visitList(outputs_, other.outputs_); + if (visitor == com.google.protobuf.GeneratedMessageLite.MergeFromVisitor + .INSTANCE) { + bitField0_ |= other.bitField0_; + } + return this; + } + case MERGE_FROM_STREAM: { + com.google.protobuf.CodedInputStream input = + (com.google.protobuf.CodedInputStream) arg0; + com.google.protobuf.ExtensionRegistryLite extensionRegistry = + (com.google.protobuf.ExtensionRegistryLite) arg1; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 8: { + + index_ = input.readUInt64(); + break; + } + case 18: { + + hash_ = input.readBytes(); + break; + } + case 24: { + + fee_ = input.readUInt32(); + break; + } + case 34: { + if (!spends_.isModifiable()) { + spends_ = + com.google.protobuf.GeneratedMessageLite.mutableCopy(spends_); + } + spends_.add( + input.readMessage(rpc.CompactFormats.CompactSpend.parser(), extensionRegistry)); + break; + } + case 42: { + if (!outputs_.isModifiable()) { + outputs_ = + com.google.protobuf.GeneratedMessageLite.mutableCopy(outputs_); + } + outputs_.add( + input.readMessage(rpc.CompactFormats.CompactOutput.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + } + } + case GET_DEFAULT_INSTANCE: { + return DEFAULT_INSTANCE; + } + case GET_PARSER: { + if (PARSER == null) { synchronized (rpc.CompactFormats.CompactTx.class) { + if (PARSER == null) { + PARSER = new DefaultInstanceBasedParser(DEFAULT_INSTANCE); + } + } + } + return PARSER; + } + } + throw new UnsupportedOperationException(); + } + + + // @@protoc_insertion_point(class_scope:rpc.CompactTx) + private static final rpc.CompactFormats.CompactTx DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new CompactTx(); + DEFAULT_INSTANCE.makeImmutable(); + } + + public static rpc.CompactFormats.CompactTx getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static volatile com.google.protobuf.Parser PARSER; + + public static com.google.protobuf.Parser parser() { + return DEFAULT_INSTANCE.getParserForType(); + } + } + + public interface CompactSpendOrBuilder extends + // @@protoc_insertion_point(interface_extends:rpc.CompactSpend) + com.google.protobuf.MessageLiteOrBuilder { + + /** + * optional bytes nf = 1; + */ + com.google.protobuf.ByteString getNf(); + } + /** + * Protobuf type {@code rpc.CompactSpend} + */ + public static final class CompactSpend extends + com.google.protobuf.GeneratedMessageLite< + CompactSpend, CompactSpend.Builder> implements + // @@protoc_insertion_point(message_implements:rpc.CompactSpend) + CompactSpendOrBuilder { + private CompactSpend() { + nf_ = com.google.protobuf.ByteString.EMPTY; + } + public static final int NF_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString nf_; + /** + * optional bytes nf = 1; + */ + public com.google.protobuf.ByteString getNf() { + return nf_; + } + /** + * optional bytes nf = 1; + */ + private void setNf(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + nf_ = value; + } + /** + * optional bytes nf = 1; + */ + private void clearNf() { + + nf_ = getDefaultInstance().getNf(); + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!nf_.isEmpty()) { + output.writeBytes(1, nf_); + } + } + + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (!nf_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, nf_); + } + memoizedSerializedSize = size; + return size; + } + + public static rpc.CompactFormats.CompactSpend parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data); + } + public static rpc.CompactFormats.CompactSpend parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data, extensionRegistry); + } + public static rpc.CompactFormats.CompactSpend parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data); + } + public static rpc.CompactFormats.CompactSpend parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data, extensionRegistry); + } + public static rpc.CompactFormats.CompactSpend parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input); + } + public static rpc.CompactFormats.CompactSpend parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input, extensionRegistry); + } + public static rpc.CompactFormats.CompactSpend parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return parseDelimitedFrom(DEFAULT_INSTANCE, input); + } + public static rpc.CompactFormats.CompactSpend parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return parseDelimitedFrom(DEFAULT_INSTANCE, input, extensionRegistry); + } + public static rpc.CompactFormats.CompactSpend parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input); + } + public static rpc.CompactFormats.CompactSpend parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input, extensionRegistry); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(rpc.CompactFormats.CompactSpend prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + /** + * Protobuf type {@code rpc.CompactSpend} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageLite.Builder< + rpc.CompactFormats.CompactSpend, Builder> implements + // @@protoc_insertion_point(builder_implements:rpc.CompactSpend) + rpc.CompactFormats.CompactSpendOrBuilder { + // Construct using rpc.CompactFormats.CompactSpend.newBuilder() + private Builder() { + super(DEFAULT_INSTANCE); + } + + + /** + * optional bytes nf = 1; + */ + public com.google.protobuf.ByteString getNf() { + return instance.getNf(); + } + /** + * optional bytes nf = 1; + */ + public Builder setNf(com.google.protobuf.ByteString value) { + copyOnWrite(); + instance.setNf(value); + return this; + } + /** + * optional bytes nf = 1; + */ + public Builder clearNf() { + copyOnWrite(); + instance.clearNf(); + return this; + } + + // @@protoc_insertion_point(builder_scope:rpc.CompactSpend) + } + protected final Object dynamicMethod( + com.google.protobuf.GeneratedMessageLite.MethodToInvoke method, + Object arg0, Object arg1) { + switch (method) { + case NEW_MUTABLE_INSTANCE: { + return new rpc.CompactFormats.CompactSpend(); + } + case IS_INITIALIZED: { + return DEFAULT_INSTANCE; + } + case MAKE_IMMUTABLE: { + return null; + } + case NEW_BUILDER: { + return new Builder(); + } + case VISIT: { + Visitor visitor = (Visitor) arg0; + rpc.CompactFormats.CompactSpend other = (rpc.CompactFormats.CompactSpend) arg1; + nf_ = visitor.visitByteString(nf_ != com.google.protobuf.ByteString.EMPTY, nf_, + other.nf_ != com.google.protobuf.ByteString.EMPTY, other.nf_); + if (visitor == com.google.protobuf.GeneratedMessageLite.MergeFromVisitor + .INSTANCE) { + } + return this; + } + case MERGE_FROM_STREAM: { + com.google.protobuf.CodedInputStream input = + (com.google.protobuf.CodedInputStream) arg0; + com.google.protobuf.ExtensionRegistryLite extensionRegistry = + (com.google.protobuf.ExtensionRegistryLite) arg1; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + + nf_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + } + } + case GET_DEFAULT_INSTANCE: { + return DEFAULT_INSTANCE; + } + case GET_PARSER: { + if (PARSER == null) { synchronized (rpc.CompactFormats.CompactSpend.class) { + if (PARSER == null) { + PARSER = new DefaultInstanceBasedParser(DEFAULT_INSTANCE); + } + } + } + return PARSER; + } + } + throw new UnsupportedOperationException(); + } + + + // @@protoc_insertion_point(class_scope:rpc.CompactSpend) + private static final rpc.CompactFormats.CompactSpend DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new CompactSpend(); + DEFAULT_INSTANCE.makeImmutable(); + } + + public static rpc.CompactFormats.CompactSpend getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static volatile com.google.protobuf.Parser PARSER; + + public static com.google.protobuf.Parser parser() { + return DEFAULT_INSTANCE.getParserForType(); + } + } + + public interface CompactOutputOrBuilder extends + // @@protoc_insertion_point(interface_extends:rpc.CompactOutput) + com.google.protobuf.MessageLiteOrBuilder { + + /** + * optional bytes cmu = 1; + */ + com.google.protobuf.ByteString getCmu(); + + /** + * optional bytes epk = 2; + */ + com.google.protobuf.ByteString getEpk(); + + /** + * optional bytes ciphertext = 3; + */ + com.google.protobuf.ByteString getCiphertext(); + } + /** + * Protobuf type {@code rpc.CompactOutput} + */ + public static final class CompactOutput extends + com.google.protobuf.GeneratedMessageLite< + CompactOutput, CompactOutput.Builder> implements + // @@protoc_insertion_point(message_implements:rpc.CompactOutput) + CompactOutputOrBuilder { + private CompactOutput() { + cmu_ = com.google.protobuf.ByteString.EMPTY; + epk_ = com.google.protobuf.ByteString.EMPTY; + ciphertext_ = com.google.protobuf.ByteString.EMPTY; + } + public static final int CMU_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString cmu_; + /** + * optional bytes cmu = 1; + */ + public com.google.protobuf.ByteString getCmu() { + return cmu_; + } + /** + * optional bytes cmu = 1; + */ + private void setCmu(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + cmu_ = value; + } + /** + * optional bytes cmu = 1; + */ + private void clearCmu() { + + cmu_ = getDefaultInstance().getCmu(); + } + + public static final int EPK_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString epk_; + /** + * optional bytes epk = 2; + */ + public com.google.protobuf.ByteString getEpk() { + return epk_; + } + /** + * optional bytes epk = 2; + */ + private void setEpk(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + epk_ = value; + } + /** + * optional bytes epk = 2; + */ + private void clearEpk() { + + epk_ = getDefaultInstance().getEpk(); + } + + public static final int CIPHERTEXT_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString ciphertext_; + /** + * optional bytes ciphertext = 3; + */ + public com.google.protobuf.ByteString getCiphertext() { + return ciphertext_; + } + /** + * optional bytes ciphertext = 3; + */ + private void setCiphertext(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ciphertext_ = value; + } + /** + * optional bytes ciphertext = 3; + */ + private void clearCiphertext() { + + ciphertext_ = getDefaultInstance().getCiphertext(); + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!cmu_.isEmpty()) { + output.writeBytes(1, cmu_); + } + if (!epk_.isEmpty()) { + output.writeBytes(2, epk_); + } + if (!ciphertext_.isEmpty()) { + output.writeBytes(3, ciphertext_); + } + } + + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (!cmu_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, cmu_); + } + if (!epk_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, epk_); + } + if (!ciphertext_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, ciphertext_); + } + memoizedSerializedSize = size; + return size; + } + + public static rpc.CompactFormats.CompactOutput parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data); + } + public static rpc.CompactFormats.CompactOutput parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data, extensionRegistry); + } + public static rpc.CompactFormats.CompactOutput parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data); + } + public static rpc.CompactFormats.CompactOutput parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data, extensionRegistry); + } + public static rpc.CompactFormats.CompactOutput parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input); + } + public static rpc.CompactFormats.CompactOutput parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input, extensionRegistry); + } + public static rpc.CompactFormats.CompactOutput parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return parseDelimitedFrom(DEFAULT_INSTANCE, input); + } + public static rpc.CompactFormats.CompactOutput parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return parseDelimitedFrom(DEFAULT_INSTANCE, input, extensionRegistry); + } + public static rpc.CompactFormats.CompactOutput parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input); + } + public static rpc.CompactFormats.CompactOutput parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input, extensionRegistry); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(rpc.CompactFormats.CompactOutput prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + /** + * Protobuf type {@code rpc.CompactOutput} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageLite.Builder< + rpc.CompactFormats.CompactOutput, Builder> implements + // @@protoc_insertion_point(builder_implements:rpc.CompactOutput) + rpc.CompactFormats.CompactOutputOrBuilder { + // Construct using rpc.CompactFormats.CompactOutput.newBuilder() + private Builder() { + super(DEFAULT_INSTANCE); + } + + + /** + * optional bytes cmu = 1; + */ + public com.google.protobuf.ByteString getCmu() { + return instance.getCmu(); + } + /** + * optional bytes cmu = 1; + */ + public Builder setCmu(com.google.protobuf.ByteString value) { + copyOnWrite(); + instance.setCmu(value); + return this; + } + /** + * optional bytes cmu = 1; + */ + public Builder clearCmu() { + copyOnWrite(); + instance.clearCmu(); + return this; + } + + /** + * optional bytes epk = 2; + */ + public com.google.protobuf.ByteString getEpk() { + return instance.getEpk(); + } + /** + * optional bytes epk = 2; + */ + public Builder setEpk(com.google.protobuf.ByteString value) { + copyOnWrite(); + instance.setEpk(value); + return this; + } + /** + * optional bytes epk = 2; + */ + public Builder clearEpk() { + copyOnWrite(); + instance.clearEpk(); + return this; + } + + /** + * optional bytes ciphertext = 3; + */ + public com.google.protobuf.ByteString getCiphertext() { + return instance.getCiphertext(); + } + /** + * optional bytes ciphertext = 3; + */ + public Builder setCiphertext(com.google.protobuf.ByteString value) { + copyOnWrite(); + instance.setCiphertext(value); + return this; + } + /** + * optional bytes ciphertext = 3; + */ + public Builder clearCiphertext() { + copyOnWrite(); + instance.clearCiphertext(); + return this; + } + + // @@protoc_insertion_point(builder_scope:rpc.CompactOutput) + } + protected final Object dynamicMethod( + com.google.protobuf.GeneratedMessageLite.MethodToInvoke method, + Object arg0, Object arg1) { + switch (method) { + case NEW_MUTABLE_INSTANCE: { + return new rpc.CompactFormats.CompactOutput(); + } + case IS_INITIALIZED: { + return DEFAULT_INSTANCE; + } + case MAKE_IMMUTABLE: { + return null; + } + case NEW_BUILDER: { + return new Builder(); + } + case VISIT: { + Visitor visitor = (Visitor) arg0; + rpc.CompactFormats.CompactOutput other = (rpc.CompactFormats.CompactOutput) arg1; + cmu_ = visitor.visitByteString(cmu_ != com.google.protobuf.ByteString.EMPTY, cmu_, + other.cmu_ != com.google.protobuf.ByteString.EMPTY, other.cmu_); + epk_ = visitor.visitByteString(epk_ != com.google.protobuf.ByteString.EMPTY, epk_, + other.epk_ != com.google.protobuf.ByteString.EMPTY, other.epk_); + ciphertext_ = visitor.visitByteString(ciphertext_ != com.google.protobuf.ByteString.EMPTY, ciphertext_, + other.ciphertext_ != com.google.protobuf.ByteString.EMPTY, other.ciphertext_); + if (visitor == com.google.protobuf.GeneratedMessageLite.MergeFromVisitor + .INSTANCE) { + } + return this; + } + case MERGE_FROM_STREAM: { + com.google.protobuf.CodedInputStream input = + (com.google.protobuf.CodedInputStream) arg0; + com.google.protobuf.ExtensionRegistryLite extensionRegistry = + (com.google.protobuf.ExtensionRegistryLite) arg1; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + + cmu_ = input.readBytes(); + break; + } + case 18: { + + epk_ = input.readBytes(); + break; + } + case 26: { + + ciphertext_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + } + } + case GET_DEFAULT_INSTANCE: { + return DEFAULT_INSTANCE; + } + case GET_PARSER: { + if (PARSER == null) { synchronized (rpc.CompactFormats.CompactOutput.class) { + if (PARSER == null) { + PARSER = new DefaultInstanceBasedParser(DEFAULT_INSTANCE); + } + } + } + return PARSER; + } + } + throw new UnsupportedOperationException(); + } + + + // @@protoc_insertion_point(class_scope:rpc.CompactOutput) + private static final rpc.CompactFormats.CompactOutput DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new CompactOutput(); + DEFAULT_INSTANCE.makeImmutable(); + } + + public static rpc.CompactFormats.CompactOutput getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static volatile com.google.protobuf.Parser PARSER; + + public static com.google.protobuf.Parser parser() { + return DEFAULT_INSTANCE.getParserForType(); + } + } + + + static { + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/src/generated/source/grpc/debug/javalite/rpc/Service.java b/src/generated/source/grpc/debug/javalite/rpc/Service.java new file mode 100644 index 00000000..0f981103 --- /dev/null +++ b/src/generated/source/grpc/debug/javalite/rpc/Service.java @@ -0,0 +1,2159 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: service.proto + +package rpc; + +public final class Service { + private Service() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + public interface BlockIDOrBuilder extends + // @@protoc_insertion_point(interface_extends:rpc.BlockID) + com.google.protobuf.MessageLiteOrBuilder { + + /** + * optional uint64 height = 1; + */ + long getHeight(); + + /** + * optional bytes hash = 2; + */ + com.google.protobuf.ByteString getHash(); + } + /** + *
+   * A BlockID message contains identifiers to select a block: a height or a
+   * hash. If the hash is present it takes precedence.
+   * 
+ * + * Protobuf type {@code rpc.BlockID} + */ + public static final class BlockID extends + com.google.protobuf.GeneratedMessageLite< + BlockID, BlockID.Builder> implements + // @@protoc_insertion_point(message_implements:rpc.BlockID) + BlockIDOrBuilder { + private BlockID() { + hash_ = com.google.protobuf.ByteString.EMPTY; + } + public static final int HEIGHT_FIELD_NUMBER = 1; + private long height_; + /** + * optional uint64 height = 1; + */ + public long getHeight() { + return height_; + } + /** + * optional uint64 height = 1; + */ + private void setHeight(long value) { + + height_ = value; + } + /** + * optional uint64 height = 1; + */ + private void clearHeight() { + + height_ = 0L; + } + + public static final int HASH_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString hash_; + /** + * optional bytes hash = 2; + */ + public com.google.protobuf.ByteString getHash() { + return hash_; + } + /** + * optional bytes hash = 2; + */ + private void setHash(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + hash_ = value; + } + /** + * optional bytes hash = 2; + */ + private void clearHash() { + + hash_ = getDefaultInstance().getHash(); + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (height_ != 0L) { + output.writeUInt64(1, height_); + } + if (!hash_.isEmpty()) { + output.writeBytes(2, hash_); + } + } + + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (height_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeUInt64Size(1, height_); + } + if (!hash_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, hash_); + } + memoizedSerializedSize = size; + return size; + } + + public static rpc.Service.BlockID parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data); + } + public static rpc.Service.BlockID parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data, extensionRegistry); + } + public static rpc.Service.BlockID parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data); + } + public static rpc.Service.BlockID parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data, extensionRegistry); + } + public static rpc.Service.BlockID parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input); + } + public static rpc.Service.BlockID parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input, extensionRegistry); + } + public static rpc.Service.BlockID parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return parseDelimitedFrom(DEFAULT_INSTANCE, input); + } + public static rpc.Service.BlockID parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return parseDelimitedFrom(DEFAULT_INSTANCE, input, extensionRegistry); + } + public static rpc.Service.BlockID parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input); + } + public static rpc.Service.BlockID parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input, extensionRegistry); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(rpc.Service.BlockID prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + /** + *
+     * A BlockID message contains identifiers to select a block: a height or a
+     * hash. If the hash is present it takes precedence.
+     * 
+ * + * Protobuf type {@code rpc.BlockID} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageLite.Builder< + rpc.Service.BlockID, Builder> implements + // @@protoc_insertion_point(builder_implements:rpc.BlockID) + rpc.Service.BlockIDOrBuilder { + // Construct using rpc.Service.BlockID.newBuilder() + private Builder() { + super(DEFAULT_INSTANCE); + } + + + /** + * optional uint64 height = 1; + */ + public long getHeight() { + return instance.getHeight(); + } + /** + * optional uint64 height = 1; + */ + public Builder setHeight(long value) { + copyOnWrite(); + instance.setHeight(value); + return this; + } + /** + * optional uint64 height = 1; + */ + public Builder clearHeight() { + copyOnWrite(); + instance.clearHeight(); + return this; + } + + /** + * optional bytes hash = 2; + */ + public com.google.protobuf.ByteString getHash() { + return instance.getHash(); + } + /** + * optional bytes hash = 2; + */ + public Builder setHash(com.google.protobuf.ByteString value) { + copyOnWrite(); + instance.setHash(value); + return this; + } + /** + * optional bytes hash = 2; + */ + public Builder clearHash() { + copyOnWrite(); + instance.clearHash(); + return this; + } + + // @@protoc_insertion_point(builder_scope:rpc.BlockID) + } + protected final Object dynamicMethod( + com.google.protobuf.GeneratedMessageLite.MethodToInvoke method, + Object arg0, Object arg1) { + switch (method) { + case NEW_MUTABLE_INSTANCE: { + return new rpc.Service.BlockID(); + } + case IS_INITIALIZED: { + return DEFAULT_INSTANCE; + } + case MAKE_IMMUTABLE: { + return null; + } + case NEW_BUILDER: { + return new Builder(); + } + case VISIT: { + Visitor visitor = (Visitor) arg0; + rpc.Service.BlockID other = (rpc.Service.BlockID) arg1; + height_ = visitor.visitLong(height_ != 0L, height_, + other.height_ != 0L, other.height_); + hash_ = visitor.visitByteString(hash_ != com.google.protobuf.ByteString.EMPTY, hash_, + other.hash_ != com.google.protobuf.ByteString.EMPTY, other.hash_); + if (visitor == com.google.protobuf.GeneratedMessageLite.MergeFromVisitor + .INSTANCE) { + } + return this; + } + case MERGE_FROM_STREAM: { + com.google.protobuf.CodedInputStream input = + (com.google.protobuf.CodedInputStream) arg0; + com.google.protobuf.ExtensionRegistryLite extensionRegistry = + (com.google.protobuf.ExtensionRegistryLite) arg1; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 8: { + + height_ = input.readUInt64(); + break; + } + case 18: { + + hash_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + } + } + case GET_DEFAULT_INSTANCE: { + return DEFAULT_INSTANCE; + } + case GET_PARSER: { + if (PARSER == null) { synchronized (rpc.Service.BlockID.class) { + if (PARSER == null) { + PARSER = new DefaultInstanceBasedParser(DEFAULT_INSTANCE); + } + } + } + return PARSER; + } + } + throw new UnsupportedOperationException(); + } + + + // @@protoc_insertion_point(class_scope:rpc.BlockID) + private static final rpc.Service.BlockID DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new BlockID(); + DEFAULT_INSTANCE.makeImmutable(); + } + + public static rpc.Service.BlockID getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static volatile com.google.protobuf.Parser PARSER; + + public static com.google.protobuf.Parser parser() { + return DEFAULT_INSTANCE.getParserForType(); + } + } + + public interface BlockRangeOrBuilder extends + // @@protoc_insertion_point(interface_extends:rpc.BlockRange) + com.google.protobuf.MessageLiteOrBuilder { + + /** + * optional .rpc.BlockID start = 1; + */ + boolean hasStart(); + /** + * optional .rpc.BlockID start = 1; + */ + rpc.Service.BlockID getStart(); + + /** + * optional .rpc.BlockID end = 2; + */ + boolean hasEnd(); + /** + * optional .rpc.BlockID end = 2; + */ + rpc.Service.BlockID getEnd(); + } + /** + *
+   * BlockRange technically allows ranging from hash to hash etc but this is not
+   * currently intended for support, though there is no reason you couldn't do
+   * it. Further permutations are left as an exercise.
+   * 
+ * + * Protobuf type {@code rpc.BlockRange} + */ + public static final class BlockRange extends + com.google.protobuf.GeneratedMessageLite< + BlockRange, BlockRange.Builder> implements + // @@protoc_insertion_point(message_implements:rpc.BlockRange) + BlockRangeOrBuilder { + private BlockRange() { + } + public static final int START_FIELD_NUMBER = 1; + private rpc.Service.BlockID start_; + /** + * optional .rpc.BlockID start = 1; + */ + public boolean hasStart() { + return start_ != null; + } + /** + * optional .rpc.BlockID start = 1; + */ + public rpc.Service.BlockID getStart() { + return start_ == null ? rpc.Service.BlockID.getDefaultInstance() : start_; + } + /** + * optional .rpc.BlockID start = 1; + */ + private void setStart(rpc.Service.BlockID value) { + if (value == null) { + throw new NullPointerException(); + } + start_ = value; + + } + /** + * optional .rpc.BlockID start = 1; + */ + private void setStart( + rpc.Service.BlockID.Builder builderForValue) { + start_ = builderForValue.build(); + + } + /** + * optional .rpc.BlockID start = 1; + */ + private void mergeStart(rpc.Service.BlockID value) { + if (start_ != null && + start_ != rpc.Service.BlockID.getDefaultInstance()) { + start_ = + rpc.Service.BlockID.newBuilder(start_).mergeFrom(value).buildPartial(); + } else { + start_ = value; + } + + } + /** + * optional .rpc.BlockID start = 1; + */ + private void clearStart() { start_ = null; + + } + + public static final int END_FIELD_NUMBER = 2; + private rpc.Service.BlockID end_; + /** + * optional .rpc.BlockID end = 2; + */ + public boolean hasEnd() { + return end_ != null; + } + /** + * optional .rpc.BlockID end = 2; + */ + public rpc.Service.BlockID getEnd() { + return end_ == null ? rpc.Service.BlockID.getDefaultInstance() : end_; + } + /** + * optional .rpc.BlockID end = 2; + */ + private void setEnd(rpc.Service.BlockID value) { + if (value == null) { + throw new NullPointerException(); + } + end_ = value; + + } + /** + * optional .rpc.BlockID end = 2; + */ + private void setEnd( + rpc.Service.BlockID.Builder builderForValue) { + end_ = builderForValue.build(); + + } + /** + * optional .rpc.BlockID end = 2; + */ + private void mergeEnd(rpc.Service.BlockID value) { + if (end_ != null && + end_ != rpc.Service.BlockID.getDefaultInstance()) { + end_ = + rpc.Service.BlockID.newBuilder(end_).mergeFrom(value).buildPartial(); + } else { + end_ = value; + } + + } + /** + * optional .rpc.BlockID end = 2; + */ + private void clearEnd() { end_ = null; + + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (start_ != null) { + output.writeMessage(1, getStart()); + } + if (end_ != null) { + output.writeMessage(2, getEnd()); + } + } + + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (start_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getStart()); + } + if (end_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getEnd()); + } + memoizedSerializedSize = size; + return size; + } + + public static rpc.Service.BlockRange parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data); + } + public static rpc.Service.BlockRange parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data, extensionRegistry); + } + public static rpc.Service.BlockRange parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data); + } + public static rpc.Service.BlockRange parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data, extensionRegistry); + } + public static rpc.Service.BlockRange parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input); + } + public static rpc.Service.BlockRange parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input, extensionRegistry); + } + public static rpc.Service.BlockRange parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return parseDelimitedFrom(DEFAULT_INSTANCE, input); + } + public static rpc.Service.BlockRange parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return parseDelimitedFrom(DEFAULT_INSTANCE, input, extensionRegistry); + } + public static rpc.Service.BlockRange parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input); + } + public static rpc.Service.BlockRange parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input, extensionRegistry); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(rpc.Service.BlockRange prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + /** + *
+     * BlockRange technically allows ranging from hash to hash etc but this is not
+     * currently intended for support, though there is no reason you couldn't do
+     * it. Further permutations are left as an exercise.
+     * 
+ * + * Protobuf type {@code rpc.BlockRange} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageLite.Builder< + rpc.Service.BlockRange, Builder> implements + // @@protoc_insertion_point(builder_implements:rpc.BlockRange) + rpc.Service.BlockRangeOrBuilder { + // Construct using rpc.Service.BlockRange.newBuilder() + private Builder() { + super(DEFAULT_INSTANCE); + } + + + /** + * optional .rpc.BlockID start = 1; + */ + public boolean hasStart() { + return instance.hasStart(); + } + /** + * optional .rpc.BlockID start = 1; + */ + public rpc.Service.BlockID getStart() { + return instance.getStart(); + } + /** + * optional .rpc.BlockID start = 1; + */ + public Builder setStart(rpc.Service.BlockID value) { + copyOnWrite(); + instance.setStart(value); + return this; + } + /** + * optional .rpc.BlockID start = 1; + */ + public Builder setStart( + rpc.Service.BlockID.Builder builderForValue) { + copyOnWrite(); + instance.setStart(builderForValue); + return this; + } + /** + * optional .rpc.BlockID start = 1; + */ + public Builder mergeStart(rpc.Service.BlockID value) { + copyOnWrite(); + instance.mergeStart(value); + return this; + } + /** + * optional .rpc.BlockID start = 1; + */ + public Builder clearStart() { copyOnWrite(); + instance.clearStart(); + return this; + } + + /** + * optional .rpc.BlockID end = 2; + */ + public boolean hasEnd() { + return instance.hasEnd(); + } + /** + * optional .rpc.BlockID end = 2; + */ + public rpc.Service.BlockID getEnd() { + return instance.getEnd(); + } + /** + * optional .rpc.BlockID end = 2; + */ + public Builder setEnd(rpc.Service.BlockID value) { + copyOnWrite(); + instance.setEnd(value); + return this; + } + /** + * optional .rpc.BlockID end = 2; + */ + public Builder setEnd( + rpc.Service.BlockID.Builder builderForValue) { + copyOnWrite(); + instance.setEnd(builderForValue); + return this; + } + /** + * optional .rpc.BlockID end = 2; + */ + public Builder mergeEnd(rpc.Service.BlockID value) { + copyOnWrite(); + instance.mergeEnd(value); + return this; + } + /** + * optional .rpc.BlockID end = 2; + */ + public Builder clearEnd() { copyOnWrite(); + instance.clearEnd(); + return this; + } + + // @@protoc_insertion_point(builder_scope:rpc.BlockRange) + } + protected final Object dynamicMethod( + com.google.protobuf.GeneratedMessageLite.MethodToInvoke method, + Object arg0, Object arg1) { + switch (method) { + case NEW_MUTABLE_INSTANCE: { + return new rpc.Service.BlockRange(); + } + case IS_INITIALIZED: { + return DEFAULT_INSTANCE; + } + case MAKE_IMMUTABLE: { + return null; + } + case NEW_BUILDER: { + return new Builder(); + } + case VISIT: { + Visitor visitor = (Visitor) arg0; + rpc.Service.BlockRange other = (rpc.Service.BlockRange) arg1; + start_ = visitor.visitMessage(start_, other.start_); + end_ = visitor.visitMessage(end_, other.end_); + if (visitor == com.google.protobuf.GeneratedMessageLite.MergeFromVisitor + .INSTANCE) { + } + return this; + } + case MERGE_FROM_STREAM: { + com.google.protobuf.CodedInputStream input = + (com.google.protobuf.CodedInputStream) arg0; + com.google.protobuf.ExtensionRegistryLite extensionRegistry = + (com.google.protobuf.ExtensionRegistryLite) arg1; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + rpc.Service.BlockID.Builder subBuilder = null; + if (start_ != null) { + subBuilder = start_.toBuilder(); + } + start_ = input.readMessage(rpc.Service.BlockID.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(start_); + start_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + rpc.Service.BlockID.Builder subBuilder = null; + if (end_ != null) { + subBuilder = end_.toBuilder(); + } + end_ = input.readMessage(rpc.Service.BlockID.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(end_); + end_ = subBuilder.buildPartial(); + } + + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + } + } + case GET_DEFAULT_INSTANCE: { + return DEFAULT_INSTANCE; + } + case GET_PARSER: { + if (PARSER == null) { synchronized (rpc.Service.BlockRange.class) { + if (PARSER == null) { + PARSER = new DefaultInstanceBasedParser(DEFAULT_INSTANCE); + } + } + } + return PARSER; + } + } + throw new UnsupportedOperationException(); + } + + + // @@protoc_insertion_point(class_scope:rpc.BlockRange) + private static final rpc.Service.BlockRange DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new BlockRange(); + DEFAULT_INSTANCE.makeImmutable(); + } + + public static rpc.Service.BlockRange getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static volatile com.google.protobuf.Parser PARSER; + + public static com.google.protobuf.Parser parser() { + return DEFAULT_INSTANCE.getParserForType(); + } + } + + public interface TxFilterOrBuilder extends + // @@protoc_insertion_point(interface_extends:rpc.TxFilter) + com.google.protobuf.MessageLiteOrBuilder { + + /** + * optional .rpc.BlockID block = 1; + */ + boolean hasBlock(); + /** + * optional .rpc.BlockID block = 1; + */ + rpc.Service.BlockID getBlock(); + + /** + * optional uint64 index = 2; + */ + long getIndex(); + + /** + * optional bytes hash = 3; + */ + com.google.protobuf.ByteString getHash(); + } + /** + *
+   * A TxFilter contains the information needed to identify a particular
+   * transaction: either a block and an index, or a direct transaction hash.
+   * 
+ * + * Protobuf type {@code rpc.TxFilter} + */ + public static final class TxFilter extends + com.google.protobuf.GeneratedMessageLite< + TxFilter, TxFilter.Builder> implements + // @@protoc_insertion_point(message_implements:rpc.TxFilter) + TxFilterOrBuilder { + private TxFilter() { + hash_ = com.google.protobuf.ByteString.EMPTY; + } + public static final int BLOCK_FIELD_NUMBER = 1; + private rpc.Service.BlockID block_; + /** + * optional .rpc.BlockID block = 1; + */ + public boolean hasBlock() { + return block_ != null; + } + /** + * optional .rpc.BlockID block = 1; + */ + public rpc.Service.BlockID getBlock() { + return block_ == null ? rpc.Service.BlockID.getDefaultInstance() : block_; + } + /** + * optional .rpc.BlockID block = 1; + */ + private void setBlock(rpc.Service.BlockID value) { + if (value == null) { + throw new NullPointerException(); + } + block_ = value; + + } + /** + * optional .rpc.BlockID block = 1; + */ + private void setBlock( + rpc.Service.BlockID.Builder builderForValue) { + block_ = builderForValue.build(); + + } + /** + * optional .rpc.BlockID block = 1; + */ + private void mergeBlock(rpc.Service.BlockID value) { + if (block_ != null && + block_ != rpc.Service.BlockID.getDefaultInstance()) { + block_ = + rpc.Service.BlockID.newBuilder(block_).mergeFrom(value).buildPartial(); + } else { + block_ = value; + } + + } + /** + * optional .rpc.BlockID block = 1; + */ + private void clearBlock() { block_ = null; + + } + + public static final int INDEX_FIELD_NUMBER = 2; + private long index_; + /** + * optional uint64 index = 2; + */ + public long getIndex() { + return index_; + } + /** + * optional uint64 index = 2; + */ + private void setIndex(long value) { + + index_ = value; + } + /** + * optional uint64 index = 2; + */ + private void clearIndex() { + + index_ = 0L; + } + + public static final int HASH_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString hash_; + /** + * optional bytes hash = 3; + */ + public com.google.protobuf.ByteString getHash() { + return hash_; + } + /** + * optional bytes hash = 3; + */ + private void setHash(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + hash_ = value; + } + /** + * optional bytes hash = 3; + */ + private void clearHash() { + + hash_ = getDefaultInstance().getHash(); + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (block_ != null) { + output.writeMessage(1, getBlock()); + } + if (index_ != 0L) { + output.writeUInt64(2, index_); + } + if (!hash_.isEmpty()) { + output.writeBytes(3, hash_); + } + } + + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (block_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getBlock()); + } + if (index_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeUInt64Size(2, index_); + } + if (!hash_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, hash_); + } + memoizedSerializedSize = size; + return size; + } + + public static rpc.Service.TxFilter parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data); + } + public static rpc.Service.TxFilter parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data, extensionRegistry); + } + public static rpc.Service.TxFilter parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data); + } + public static rpc.Service.TxFilter parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data, extensionRegistry); + } + public static rpc.Service.TxFilter parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input); + } + public static rpc.Service.TxFilter parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input, extensionRegistry); + } + public static rpc.Service.TxFilter parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return parseDelimitedFrom(DEFAULT_INSTANCE, input); + } + public static rpc.Service.TxFilter parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return parseDelimitedFrom(DEFAULT_INSTANCE, input, extensionRegistry); + } + public static rpc.Service.TxFilter parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input); + } + public static rpc.Service.TxFilter parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input, extensionRegistry); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(rpc.Service.TxFilter prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + /** + *
+     * A TxFilter contains the information needed to identify a particular
+     * transaction: either a block and an index, or a direct transaction hash.
+     * 
+ * + * Protobuf type {@code rpc.TxFilter} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageLite.Builder< + rpc.Service.TxFilter, Builder> implements + // @@protoc_insertion_point(builder_implements:rpc.TxFilter) + rpc.Service.TxFilterOrBuilder { + // Construct using rpc.Service.TxFilter.newBuilder() + private Builder() { + super(DEFAULT_INSTANCE); + } + + + /** + * optional .rpc.BlockID block = 1; + */ + public boolean hasBlock() { + return instance.hasBlock(); + } + /** + * optional .rpc.BlockID block = 1; + */ + public rpc.Service.BlockID getBlock() { + return instance.getBlock(); + } + /** + * optional .rpc.BlockID block = 1; + */ + public Builder setBlock(rpc.Service.BlockID value) { + copyOnWrite(); + instance.setBlock(value); + return this; + } + /** + * optional .rpc.BlockID block = 1; + */ + public Builder setBlock( + rpc.Service.BlockID.Builder builderForValue) { + copyOnWrite(); + instance.setBlock(builderForValue); + return this; + } + /** + * optional .rpc.BlockID block = 1; + */ + public Builder mergeBlock(rpc.Service.BlockID value) { + copyOnWrite(); + instance.mergeBlock(value); + return this; + } + /** + * optional .rpc.BlockID block = 1; + */ + public Builder clearBlock() { copyOnWrite(); + instance.clearBlock(); + return this; + } + + /** + * optional uint64 index = 2; + */ + public long getIndex() { + return instance.getIndex(); + } + /** + * optional uint64 index = 2; + */ + public Builder setIndex(long value) { + copyOnWrite(); + instance.setIndex(value); + return this; + } + /** + * optional uint64 index = 2; + */ + public Builder clearIndex() { + copyOnWrite(); + instance.clearIndex(); + return this; + } + + /** + * optional bytes hash = 3; + */ + public com.google.protobuf.ByteString getHash() { + return instance.getHash(); + } + /** + * optional bytes hash = 3; + */ + public Builder setHash(com.google.protobuf.ByteString value) { + copyOnWrite(); + instance.setHash(value); + return this; + } + /** + * optional bytes hash = 3; + */ + public Builder clearHash() { + copyOnWrite(); + instance.clearHash(); + return this; + } + + // @@protoc_insertion_point(builder_scope:rpc.TxFilter) + } + protected final Object dynamicMethod( + com.google.protobuf.GeneratedMessageLite.MethodToInvoke method, + Object arg0, Object arg1) { + switch (method) { + case NEW_MUTABLE_INSTANCE: { + return new rpc.Service.TxFilter(); + } + case IS_INITIALIZED: { + return DEFAULT_INSTANCE; + } + case MAKE_IMMUTABLE: { + return null; + } + case NEW_BUILDER: { + return new Builder(); + } + case VISIT: { + Visitor visitor = (Visitor) arg0; + rpc.Service.TxFilter other = (rpc.Service.TxFilter) arg1; + block_ = visitor.visitMessage(block_, other.block_); + index_ = visitor.visitLong(index_ != 0L, index_, + other.index_ != 0L, other.index_); + hash_ = visitor.visitByteString(hash_ != com.google.protobuf.ByteString.EMPTY, hash_, + other.hash_ != com.google.protobuf.ByteString.EMPTY, other.hash_); + if (visitor == com.google.protobuf.GeneratedMessageLite.MergeFromVisitor + .INSTANCE) { + } + return this; + } + case MERGE_FROM_STREAM: { + com.google.protobuf.CodedInputStream input = + (com.google.protobuf.CodedInputStream) arg0; + com.google.protobuf.ExtensionRegistryLite extensionRegistry = + (com.google.protobuf.ExtensionRegistryLite) arg1; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + rpc.Service.BlockID.Builder subBuilder = null; + if (block_ != null) { + subBuilder = block_.toBuilder(); + } + block_ = input.readMessage(rpc.Service.BlockID.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(block_); + block_ = subBuilder.buildPartial(); + } + + break; + } + case 16: { + + index_ = input.readUInt64(); + break; + } + case 26: { + + hash_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + } + } + case GET_DEFAULT_INSTANCE: { + return DEFAULT_INSTANCE; + } + case GET_PARSER: { + if (PARSER == null) { synchronized (rpc.Service.TxFilter.class) { + if (PARSER == null) { + PARSER = new DefaultInstanceBasedParser(DEFAULT_INSTANCE); + } + } + } + return PARSER; + } + } + throw new UnsupportedOperationException(); + } + + + // @@protoc_insertion_point(class_scope:rpc.TxFilter) + private static final rpc.Service.TxFilter DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new TxFilter(); + DEFAULT_INSTANCE.makeImmutable(); + } + + public static rpc.Service.TxFilter getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static volatile com.google.protobuf.Parser PARSER; + + public static com.google.protobuf.Parser parser() { + return DEFAULT_INSTANCE.getParserForType(); + } + } + + public interface RawTransactionOrBuilder extends + // @@protoc_insertion_point(interface_extends:rpc.RawTransaction) + com.google.protobuf.MessageLiteOrBuilder { + + /** + * optional bytes data = 1; + */ + com.google.protobuf.ByteString getData(); + } + /** + *
+   * RawTransaction contains the complete transaction data.
+   * 
+ * + * Protobuf type {@code rpc.RawTransaction} + */ + public static final class RawTransaction extends + com.google.protobuf.GeneratedMessageLite< + RawTransaction, RawTransaction.Builder> implements + // @@protoc_insertion_point(message_implements:rpc.RawTransaction) + RawTransactionOrBuilder { + private RawTransaction() { + data_ = com.google.protobuf.ByteString.EMPTY; + } + public static final int DATA_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString data_; + /** + * optional bytes data = 1; + */ + public com.google.protobuf.ByteString getData() { + return data_; + } + /** + * optional bytes data = 1; + */ + private void setData(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + data_ = value; + } + /** + * optional bytes data = 1; + */ + private void clearData() { + + data_ = getDefaultInstance().getData(); + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!data_.isEmpty()) { + output.writeBytes(1, data_); + } + } + + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (!data_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, data_); + } + memoizedSerializedSize = size; + return size; + } + + public static rpc.Service.RawTransaction parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data); + } + public static rpc.Service.RawTransaction parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data, extensionRegistry); + } + public static rpc.Service.RawTransaction parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data); + } + public static rpc.Service.RawTransaction parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data, extensionRegistry); + } + public static rpc.Service.RawTransaction parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input); + } + public static rpc.Service.RawTransaction parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input, extensionRegistry); + } + public static rpc.Service.RawTransaction parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return parseDelimitedFrom(DEFAULT_INSTANCE, input); + } + public static rpc.Service.RawTransaction parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return parseDelimitedFrom(DEFAULT_INSTANCE, input, extensionRegistry); + } + public static rpc.Service.RawTransaction parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input); + } + public static rpc.Service.RawTransaction parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input, extensionRegistry); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(rpc.Service.RawTransaction prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + /** + *
+     * RawTransaction contains the complete transaction data.
+     * 
+ * + * Protobuf type {@code rpc.RawTransaction} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageLite.Builder< + rpc.Service.RawTransaction, Builder> implements + // @@protoc_insertion_point(builder_implements:rpc.RawTransaction) + rpc.Service.RawTransactionOrBuilder { + // Construct using rpc.Service.RawTransaction.newBuilder() + private Builder() { + super(DEFAULT_INSTANCE); + } + + + /** + * optional bytes data = 1; + */ + public com.google.protobuf.ByteString getData() { + return instance.getData(); + } + /** + * optional bytes data = 1; + */ + public Builder setData(com.google.protobuf.ByteString value) { + copyOnWrite(); + instance.setData(value); + return this; + } + /** + * optional bytes data = 1; + */ + public Builder clearData() { + copyOnWrite(); + instance.clearData(); + return this; + } + + // @@protoc_insertion_point(builder_scope:rpc.RawTransaction) + } + protected final Object dynamicMethod( + com.google.protobuf.GeneratedMessageLite.MethodToInvoke method, + Object arg0, Object arg1) { + switch (method) { + case NEW_MUTABLE_INSTANCE: { + return new rpc.Service.RawTransaction(); + } + case IS_INITIALIZED: { + return DEFAULT_INSTANCE; + } + case MAKE_IMMUTABLE: { + return null; + } + case NEW_BUILDER: { + return new Builder(); + } + case VISIT: { + Visitor visitor = (Visitor) arg0; + rpc.Service.RawTransaction other = (rpc.Service.RawTransaction) arg1; + data_ = visitor.visitByteString(data_ != com.google.protobuf.ByteString.EMPTY, data_, + other.data_ != com.google.protobuf.ByteString.EMPTY, other.data_); + if (visitor == com.google.protobuf.GeneratedMessageLite.MergeFromVisitor + .INSTANCE) { + } + return this; + } + case MERGE_FROM_STREAM: { + com.google.protobuf.CodedInputStream input = + (com.google.protobuf.CodedInputStream) arg0; + com.google.protobuf.ExtensionRegistryLite extensionRegistry = + (com.google.protobuf.ExtensionRegistryLite) arg1; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + + data_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + } + } + case GET_DEFAULT_INSTANCE: { + return DEFAULT_INSTANCE; + } + case GET_PARSER: { + if (PARSER == null) { synchronized (rpc.Service.RawTransaction.class) { + if (PARSER == null) { + PARSER = new DefaultInstanceBasedParser(DEFAULT_INSTANCE); + } + } + } + return PARSER; + } + } + throw new UnsupportedOperationException(); + } + + + // @@protoc_insertion_point(class_scope:rpc.RawTransaction) + private static final rpc.Service.RawTransaction DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new RawTransaction(); + DEFAULT_INSTANCE.makeImmutable(); + } + + public static rpc.Service.RawTransaction getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static volatile com.google.protobuf.Parser PARSER; + + public static com.google.protobuf.Parser parser() { + return DEFAULT_INSTANCE.getParserForType(); + } + } + + public interface SendResponseOrBuilder extends + // @@protoc_insertion_point(interface_extends:rpc.SendResponse) + com.google.protobuf.MessageLiteOrBuilder { + + /** + * optional int32 errorCode = 1; + */ + int getErrorCode(); + + /** + * optional string errorMessage = 2; + */ + java.lang.String getErrorMessage(); + /** + * optional string errorMessage = 2; + */ + com.google.protobuf.ByteString + getErrorMessageBytes(); + } + /** + * Protobuf type {@code rpc.SendResponse} + */ + public static final class SendResponse extends + com.google.protobuf.GeneratedMessageLite< + SendResponse, SendResponse.Builder> implements + // @@protoc_insertion_point(message_implements:rpc.SendResponse) + SendResponseOrBuilder { + private SendResponse() { + errorMessage_ = ""; + } + public static final int ERRORCODE_FIELD_NUMBER = 1; + private int errorCode_; + /** + * optional int32 errorCode = 1; + */ + public int getErrorCode() { + return errorCode_; + } + /** + * optional int32 errorCode = 1; + */ + private void setErrorCode(int value) { + + errorCode_ = value; + } + /** + * optional int32 errorCode = 1; + */ + private void clearErrorCode() { + + errorCode_ = 0; + } + + public static final int ERRORMESSAGE_FIELD_NUMBER = 2; + private java.lang.String errorMessage_; + /** + * optional string errorMessage = 2; + */ + public java.lang.String getErrorMessage() { + return errorMessage_; + } + /** + * optional string errorMessage = 2; + */ + public com.google.protobuf.ByteString + getErrorMessageBytes() { + return com.google.protobuf.ByteString.copyFromUtf8(errorMessage_); + } + /** + * optional string errorMessage = 2; + */ + private void setErrorMessage( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + errorMessage_ = value; + } + /** + * optional string errorMessage = 2; + */ + private void clearErrorMessage() { + + errorMessage_ = getDefaultInstance().getErrorMessage(); + } + /** + * optional string errorMessage = 2; + */ + private void setErrorMessageBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + errorMessage_ = value.toStringUtf8(); + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (errorCode_ != 0) { + output.writeInt32(1, errorCode_); + } + if (!errorMessage_.isEmpty()) { + output.writeString(2, getErrorMessage()); + } + } + + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (errorCode_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, errorCode_); + } + if (!errorMessage_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeStringSize(2, getErrorMessage()); + } + memoizedSerializedSize = size; + return size; + } + + public static rpc.Service.SendResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data); + } + public static rpc.Service.SendResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data, extensionRegistry); + } + public static rpc.Service.SendResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data); + } + public static rpc.Service.SendResponse parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data, extensionRegistry); + } + public static rpc.Service.SendResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input); + } + public static rpc.Service.SendResponse parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input, extensionRegistry); + } + public static rpc.Service.SendResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return parseDelimitedFrom(DEFAULT_INSTANCE, input); + } + public static rpc.Service.SendResponse parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return parseDelimitedFrom(DEFAULT_INSTANCE, input, extensionRegistry); + } + public static rpc.Service.SendResponse parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input); + } + public static rpc.Service.SendResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input, extensionRegistry); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(rpc.Service.SendResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + /** + * Protobuf type {@code rpc.SendResponse} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageLite.Builder< + rpc.Service.SendResponse, Builder> implements + // @@protoc_insertion_point(builder_implements:rpc.SendResponse) + rpc.Service.SendResponseOrBuilder { + // Construct using rpc.Service.SendResponse.newBuilder() + private Builder() { + super(DEFAULT_INSTANCE); + } + + + /** + * optional int32 errorCode = 1; + */ + public int getErrorCode() { + return instance.getErrorCode(); + } + /** + * optional int32 errorCode = 1; + */ + public Builder setErrorCode(int value) { + copyOnWrite(); + instance.setErrorCode(value); + return this; + } + /** + * optional int32 errorCode = 1; + */ + public Builder clearErrorCode() { + copyOnWrite(); + instance.clearErrorCode(); + return this; + } + + /** + * optional string errorMessage = 2; + */ + public java.lang.String getErrorMessage() { + return instance.getErrorMessage(); + } + /** + * optional string errorMessage = 2; + */ + public com.google.protobuf.ByteString + getErrorMessageBytes() { + return instance.getErrorMessageBytes(); + } + /** + * optional string errorMessage = 2; + */ + public Builder setErrorMessage( + java.lang.String value) { + copyOnWrite(); + instance.setErrorMessage(value); + return this; + } + /** + * optional string errorMessage = 2; + */ + public Builder clearErrorMessage() { + copyOnWrite(); + instance.clearErrorMessage(); + return this; + } + /** + * optional string errorMessage = 2; + */ + public Builder setErrorMessageBytes( + com.google.protobuf.ByteString value) { + copyOnWrite(); + instance.setErrorMessageBytes(value); + return this; + } + + // @@protoc_insertion_point(builder_scope:rpc.SendResponse) + } + protected final Object dynamicMethod( + com.google.protobuf.GeneratedMessageLite.MethodToInvoke method, + Object arg0, Object arg1) { + switch (method) { + case NEW_MUTABLE_INSTANCE: { + return new rpc.Service.SendResponse(); + } + case IS_INITIALIZED: { + return DEFAULT_INSTANCE; + } + case MAKE_IMMUTABLE: { + return null; + } + case NEW_BUILDER: { + return new Builder(); + } + case VISIT: { + Visitor visitor = (Visitor) arg0; + rpc.Service.SendResponse other = (rpc.Service.SendResponse) arg1; + errorCode_ = visitor.visitInt(errorCode_ != 0, errorCode_, + other.errorCode_ != 0, other.errorCode_); + errorMessage_ = visitor.visitString(!errorMessage_.isEmpty(), errorMessage_, + !other.errorMessage_.isEmpty(), other.errorMessage_); + if (visitor == com.google.protobuf.GeneratedMessageLite.MergeFromVisitor + .INSTANCE) { + } + return this; + } + case MERGE_FROM_STREAM: { + com.google.protobuf.CodedInputStream input = + (com.google.protobuf.CodedInputStream) arg0; + com.google.protobuf.ExtensionRegistryLite extensionRegistry = + (com.google.protobuf.ExtensionRegistryLite) arg1; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 8: { + + errorCode_ = input.readInt32(); + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + errorMessage_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + } + } + case GET_DEFAULT_INSTANCE: { + return DEFAULT_INSTANCE; + } + case GET_PARSER: { + if (PARSER == null) { synchronized (rpc.Service.SendResponse.class) { + if (PARSER == null) { + PARSER = new DefaultInstanceBasedParser(DEFAULT_INSTANCE); + } + } + } + return PARSER; + } + } + throw new UnsupportedOperationException(); + } + + + // @@protoc_insertion_point(class_scope:rpc.SendResponse) + private static final rpc.Service.SendResponse DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new SendResponse(); + DEFAULT_INSTANCE.makeImmutable(); + } + + public static rpc.Service.SendResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static volatile com.google.protobuf.Parser PARSER; + + public static com.google.protobuf.Parser parser() { + return DEFAULT_INSTANCE.getParserForType(); + } + } + + public interface ChainSpecOrBuilder extends + // @@protoc_insertion_point(interface_extends:rpc.ChainSpec) + com.google.protobuf.MessageLiteOrBuilder { + } + /** + *
+   * Empty placeholder. Someday we may want to specify e.g. a particular chain fork.
+   * 
+ * + * Protobuf type {@code rpc.ChainSpec} + */ + public static final class ChainSpec extends + com.google.protobuf.GeneratedMessageLite< + ChainSpec, ChainSpec.Builder> implements + // @@protoc_insertion_point(message_implements:rpc.ChainSpec) + ChainSpecOrBuilder { + private ChainSpec() { + } + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + } + + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + memoizedSerializedSize = size; + return size; + } + + public static rpc.Service.ChainSpec parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data); + } + public static rpc.Service.ChainSpec parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data, extensionRegistry); + } + public static rpc.Service.ChainSpec parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data); + } + public static rpc.Service.ChainSpec parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data, extensionRegistry); + } + public static rpc.Service.ChainSpec parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input); + } + public static rpc.Service.ChainSpec parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input, extensionRegistry); + } + public static rpc.Service.ChainSpec parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return parseDelimitedFrom(DEFAULT_INSTANCE, input); + } + public static rpc.Service.ChainSpec parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return parseDelimitedFrom(DEFAULT_INSTANCE, input, extensionRegistry); + } + public static rpc.Service.ChainSpec parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input); + } + public static rpc.Service.ChainSpec parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input, extensionRegistry); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(rpc.Service.ChainSpec prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + /** + *
+     * Empty placeholder. Someday we may want to specify e.g. a particular chain fork.
+     * 
+ * + * Protobuf type {@code rpc.ChainSpec} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageLite.Builder< + rpc.Service.ChainSpec, Builder> implements + // @@protoc_insertion_point(builder_implements:rpc.ChainSpec) + rpc.Service.ChainSpecOrBuilder { + // Construct using rpc.Service.ChainSpec.newBuilder() + private Builder() { + super(DEFAULT_INSTANCE); + } + + + // @@protoc_insertion_point(builder_scope:rpc.ChainSpec) + } + protected final Object dynamicMethod( + com.google.protobuf.GeneratedMessageLite.MethodToInvoke method, + Object arg0, Object arg1) { + switch (method) { + case NEW_MUTABLE_INSTANCE: { + return new rpc.Service.ChainSpec(); + } + case IS_INITIALIZED: { + return DEFAULT_INSTANCE; + } + case MAKE_IMMUTABLE: { + return null; + } + case NEW_BUILDER: { + return new Builder(); + } + case VISIT: { + Visitor visitor = (Visitor) arg0; + rpc.Service.ChainSpec other = (rpc.Service.ChainSpec) arg1; + if (visitor == com.google.protobuf.GeneratedMessageLite.MergeFromVisitor + .INSTANCE) { + } + return this; + } + case MERGE_FROM_STREAM: { + com.google.protobuf.CodedInputStream input = + (com.google.protobuf.CodedInputStream) arg0; + com.google.protobuf.ExtensionRegistryLite extensionRegistry = + (com.google.protobuf.ExtensionRegistryLite) arg1; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + } + } + case GET_DEFAULT_INSTANCE: { + return DEFAULT_INSTANCE; + } + case GET_PARSER: { + if (PARSER == null) { synchronized (rpc.Service.ChainSpec.class) { + if (PARSER == null) { + PARSER = new DefaultInstanceBasedParser(DEFAULT_INSTANCE); + } + } + } + return PARSER; + } + } + throw new UnsupportedOperationException(); + } + + + // @@protoc_insertion_point(class_scope:rpc.ChainSpec) + private static final rpc.Service.ChainSpec DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new ChainSpec(); + DEFAULT_INSTANCE.makeImmutable(); + } + + public static rpc.Service.ChainSpec getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static volatile com.google.protobuf.Parser PARSER; + + public static com.google.protobuf.Parser parser() { + return DEFAULT_INSTANCE.getParserForType(); + } + } + + + static { + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/src/generated/source/grpc/debug/javalite/rpc/WalletDataOuterClass.java b/src/generated/source/grpc/debug/javalite/rpc/WalletDataOuterClass.java new file mode 100644 index 00000000..5b05d441 --- /dev/null +++ b/src/generated/source/grpc/debug/javalite/rpc/WalletDataOuterClass.java @@ -0,0 +1,505 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: WalletData.proto + +package rpc; + +public final class WalletDataOuterClass { + private WalletDataOuterClass() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + public interface WalletDataOrBuilder extends + // @@protoc_insertion_point(interface_extends:rpc.WalletData) + com.google.protobuf.MessageLiteOrBuilder { + + /** + * optional string name = 1; + */ + java.lang.String getName(); + /** + * optional string name = 1; + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + * optional int32 id = 2; + */ + int getId(); + + /** + * optional string emails = 3; + */ + java.lang.String getEmails(); + /** + * optional string emails = 3; + */ + com.google.protobuf.ByteString + getEmailsBytes(); + } + /** + * Protobuf type {@code rpc.WalletData} + */ + public static final class WalletData extends + com.google.protobuf.GeneratedMessageLite< + WalletData, WalletData.Builder> implements + // @@protoc_insertion_point(message_implements:rpc.WalletData) + WalletDataOrBuilder { + private WalletData() { + name_ = ""; + emails_ = ""; + } + public static final int NAME_FIELD_NUMBER = 1; + private java.lang.String name_; + /** + * optional string name = 1; + */ + public java.lang.String getName() { + return name_; + } + /** + * optional string name = 1; + */ + public com.google.protobuf.ByteString + getNameBytes() { + return com.google.protobuf.ByteString.copyFromUtf8(name_); + } + /** + * optional string name = 1; + */ + private void setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + } + /** + * optional string name = 1; + */ + private void clearName() { + + name_ = getDefaultInstance().getName(); + } + /** + * optional string name = 1; + */ + private void setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value.toStringUtf8(); + } + + public static final int ID_FIELD_NUMBER = 2; + private int id_; + /** + * optional int32 id = 2; + */ + public int getId() { + return id_; + } + /** + * optional int32 id = 2; + */ + private void setId(int value) { + + id_ = value; + } + /** + * optional int32 id = 2; + */ + private void clearId() { + + id_ = 0; + } + + public static final int EMAILS_FIELD_NUMBER = 3; + private java.lang.String emails_; + /** + * optional string emails = 3; + */ + public java.lang.String getEmails() { + return emails_; + } + /** + * optional string emails = 3; + */ + public com.google.protobuf.ByteString + getEmailsBytes() { + return com.google.protobuf.ByteString.copyFromUtf8(emails_); + } + /** + * optional string emails = 3; + */ + private void setEmails( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + emails_ = value; + } + /** + * optional string emails = 3; + */ + private void clearEmails() { + + emails_ = getDefaultInstance().getEmails(); + } + /** + * optional string emails = 3; + */ + private void setEmailsBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + emails_ = value.toStringUtf8(); + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!name_.isEmpty()) { + output.writeString(1, getName()); + } + if (id_ != 0) { + output.writeInt32(2, id_); + } + if (!emails_.isEmpty()) { + output.writeString(3, getEmails()); + } + } + + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (!name_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeStringSize(1, getName()); + } + if (id_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, id_); + } + if (!emails_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeStringSize(3, getEmails()); + } + memoizedSerializedSize = size; + return size; + } + + public static rpc.WalletDataOuterClass.WalletData parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data); + } + public static rpc.WalletDataOuterClass.WalletData parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data, extensionRegistry); + } + public static rpc.WalletDataOuterClass.WalletData parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data); + } + public static rpc.WalletDataOuterClass.WalletData parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, data, extensionRegistry); + } + public static rpc.WalletDataOuterClass.WalletData parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input); + } + public static rpc.WalletDataOuterClass.WalletData parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input, extensionRegistry); + } + public static rpc.WalletDataOuterClass.WalletData parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return parseDelimitedFrom(DEFAULT_INSTANCE, input); + } + public static rpc.WalletDataOuterClass.WalletData parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return parseDelimitedFrom(DEFAULT_INSTANCE, input, extensionRegistry); + } + public static rpc.WalletDataOuterClass.WalletData parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input); + } + public static rpc.WalletDataOuterClass.WalletData parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageLite.parseFrom( + DEFAULT_INSTANCE, input, extensionRegistry); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(rpc.WalletDataOuterClass.WalletData prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + /** + * Protobuf type {@code rpc.WalletData} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageLite.Builder< + rpc.WalletDataOuterClass.WalletData, Builder> implements + // @@protoc_insertion_point(builder_implements:rpc.WalletData) + rpc.WalletDataOuterClass.WalletDataOrBuilder { + // Construct using rpc.WalletDataOuterClass.WalletData.newBuilder() + private Builder() { + super(DEFAULT_INSTANCE); + } + + + /** + * optional string name = 1; + */ + public java.lang.String getName() { + return instance.getName(); + } + /** + * optional string name = 1; + */ + public com.google.protobuf.ByteString + getNameBytes() { + return instance.getNameBytes(); + } + /** + * optional string name = 1; + */ + public Builder setName( + java.lang.String value) { + copyOnWrite(); + instance.setName(value); + return this; + } + /** + * optional string name = 1; + */ + public Builder clearName() { + copyOnWrite(); + instance.clearName(); + return this; + } + /** + * optional string name = 1; + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + copyOnWrite(); + instance.setNameBytes(value); + return this; + } + + /** + * optional int32 id = 2; + */ + public int getId() { + return instance.getId(); + } + /** + * optional int32 id = 2; + */ + public Builder setId(int value) { + copyOnWrite(); + instance.setId(value); + return this; + } + /** + * optional int32 id = 2; + */ + public Builder clearId() { + copyOnWrite(); + instance.clearId(); + return this; + } + + /** + * optional string emails = 3; + */ + public java.lang.String getEmails() { + return instance.getEmails(); + } + /** + * optional string emails = 3; + */ + public com.google.protobuf.ByteString + getEmailsBytes() { + return instance.getEmailsBytes(); + } + /** + * optional string emails = 3; + */ + public Builder setEmails( + java.lang.String value) { + copyOnWrite(); + instance.setEmails(value); + return this; + } + /** + * optional string emails = 3; + */ + public Builder clearEmails() { + copyOnWrite(); + instance.clearEmails(); + return this; + } + /** + * optional string emails = 3; + */ + public Builder setEmailsBytes( + com.google.protobuf.ByteString value) { + copyOnWrite(); + instance.setEmailsBytes(value); + return this; + } + + // @@protoc_insertion_point(builder_scope:rpc.WalletData) + } + protected final Object dynamicMethod( + com.google.protobuf.GeneratedMessageLite.MethodToInvoke method, + Object arg0, Object arg1) { + switch (method) { + case NEW_MUTABLE_INSTANCE: { + return new rpc.WalletDataOuterClass.WalletData(); + } + case IS_INITIALIZED: { + return DEFAULT_INSTANCE; + } + case MAKE_IMMUTABLE: { + return null; + } + case NEW_BUILDER: { + return new Builder(); + } + case VISIT: { + Visitor visitor = (Visitor) arg0; + rpc.WalletDataOuterClass.WalletData other = (rpc.WalletDataOuterClass.WalletData) arg1; + name_ = visitor.visitString(!name_.isEmpty(), name_, + !other.name_.isEmpty(), other.name_); + id_ = visitor.visitInt(id_ != 0, id_, + other.id_ != 0, other.id_); + emails_ = visitor.visitString(!emails_.isEmpty(), emails_, + !other.emails_.isEmpty(), other.emails_); + if (visitor == com.google.protobuf.GeneratedMessageLite.MergeFromVisitor + .INSTANCE) { + } + return this; + } + case MERGE_FROM_STREAM: { + com.google.protobuf.CodedInputStream input = + (com.google.protobuf.CodedInputStream) arg0; + com.google.protobuf.ExtensionRegistryLite extensionRegistry = + (com.google.protobuf.ExtensionRegistryLite) arg1; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 16: { + + id_ = input.readInt32(); + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + emails_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + } + } + case GET_DEFAULT_INSTANCE: { + return DEFAULT_INSTANCE; + } + case GET_PARSER: { + if (PARSER == null) { synchronized (rpc.WalletDataOuterClass.WalletData.class) { + if (PARSER == null) { + PARSER = new DefaultInstanceBasedParser(DEFAULT_INSTANCE); + } + } + } + return PARSER; + } + } + throw new UnsupportedOperationException(); + } + + + // @@protoc_insertion_point(class_scope:rpc.WalletData) + private static final rpc.WalletDataOuterClass.WalletData DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new WalletData(); + DEFAULT_INSTANCE.makeImmutable(); + } + + public static rpc.WalletDataOuterClass.WalletData getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static volatile com.google.protobuf.Parser PARSER; + + public static com.google.protobuf.Parser parser() { + return DEFAULT_INSTANCE.getParserForType(); + } + } + + + static { + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index fdcda290..bd61c458 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -1,2 +1,6 @@ + package="cash.z.wallet.sdk"> + + + + diff --git a/src/main/java/cash/z/wallet/sdk/dao/CompactBlockDao.kt b/src/main/java/cash/z/wallet/sdk/dao/CompactBlockDao.kt index 663e5a5c..ff52151f 100644 --- a/src/main/java/cash/z/wallet/sdk/dao/CompactBlockDao.kt +++ b/src/main/java/cash/z/wallet/sdk/dao/CompactBlockDao.kt @@ -5,7 +5,7 @@ import cash.z.wallet.sdk.vo.CompactBlock @Dao interface CompactBlockDao { - @Insert(onConflict = OnConflictStrategy.REPLACE) + @Insert(onConflict = OnConflictStrategy.IGNORE) fun insert(block: CompactBlock) @Query("SELECT * FROM compactblocks WHERE height = :height") diff --git a/src/main/java/cash/z/wallet/sdk/data/CompactBlockDownloader.kt b/src/main/java/cash/z/wallet/sdk/data/CompactBlockDownloader.kt new file mode 100644 index 00000000..deb4ca81 --- /dev/null +++ b/src/main/java/cash/z/wallet/sdk/data/CompactBlockDownloader.kt @@ -0,0 +1,129 @@ +package cash.z.wallet.sdk.data + +import cash.z.wallet.sdk.ext.debug +import cash.z.wallet.sdk.ext.toBlockHeight +import io.grpc.ManagedChannelBuilder +import kotlinx.coroutines.* +import kotlinx.coroutines.channels.BroadcastChannel +import kotlinx.coroutines.channels.ReceiveChannel +import rpc.CompactFormats.CompactBlock +import rpc.CompactTxStreamerGrpc +import rpc.Service +import java.io.Closeable + +/** + * Downloads compact blocks to the database + */ +class CompactBlockDownloader(val scope: CoroutineScope) : CompactBlockSource { + + private var connection: Connection? = null + + override fun blocks(): ReceiveChannel> = connection!!.subscribe() + + fun start() { + connection = Connection() + scope.launch { + connection!!.loadBlockRange(373070L..373085L).join() + connection = Connection().open() + } + } + + fun stop() { + connection?.close() + connection = null + } + + inner class Connection: Closeable { + private var job: Job? = null + private var syncJob: Job? = null + private val compactBlockChannel = BroadcastChannel>(100) + private val errorHandler: CoroutineExceptionHandler + + val channel = ManagedChannelBuilder.forAddress("10.0.2.2", 9067).usePlaintext().build() + val blockingStub = CompactTxStreamerGrpc.newBlockingStub(channel) + + init { + errorHandler = CoroutineExceptionHandler { _, error -> + debug("handling error: $error") + try { + debug("totally about to launch something sweet") + GlobalScope.launch { + debug("sending error") + compactBlockChannel.send(Result.failure(error)) + debug("error sent") + } + + }catch (t:Throwable) { + debug("failed to send error because of $t") + } + } + } + + fun subscribe() = compactBlockChannel.openSubscription() + + fun loadBlockRange(range: LongRange) : Job { + syncJob = scope.launch { + if (isActive) { + debug("requesting a block range: ...") + channel. + val result = blockingStub.getBlockRange( + Service.BlockRange.newBuilder() + .setStart(range.first.toBlockHeight()) + .setEnd(range.last.toBlockHeight()) + .build() + ) + while (result.hasNext()) { + try { + val nextBlock = result.next() + debug("received new block in range: ${nextBlock.height}") + + async { debug("sending block from range: ${nextBlock.height}"); compactBlockChannel.send(Result.success(nextBlock)); debug("done sending block from range: ${nextBlock.height}") } + } catch (t: Throwable) { + async { debug("sending failure"); compactBlockChannel.send(Result.failure(t)); debug("done sending failure"); } + } + } + } + } + return syncJob!! + } + + fun open(): Connection { + // TODO: use CoroutineScope.open to avoid the need to pass scope around + job = scope.launch { + var lastHeight = 0L + while (isActive) { +debug("requesting a block...") + val result = blockingStub.getLatestBlock(Service.ChainSpec.newBuilder().build()) + if (result.height > lastHeight) { +debug("received new block: ${result.height}") + // if we have new data, send it and then wait a while + try { + + async { debug("sending block: ${result.height}"); compactBlockChannel.send(Result.success(blockingStub.getBlock(result))); debug("done sending block: ${result.height}"); } + } catch (t: Throwable) { + async { debug("sending failure"); compactBlockChannel.send(Result.failure(t)); debug("done sending failure"); } + } + + lastHeight = result.height + delay(25 * 1000) + + } else { +debug("received same old block: ${result.height}") + // otherwise keep checking fairly often until we have new data + delay(3000) + } + } + } + return this + } + + override fun close() { + compactBlockChannel.cancel() + syncJob?.cancel() + syncJob = null + job?.cancel() + job = null + } + + } +} \ No newline at end of file diff --git a/src/main/java/cash/z/wallet/sdk/data/CompactBlockSource.kt b/src/main/java/cash/z/wallet/sdk/data/CompactBlockSource.kt new file mode 100644 index 00000000..0601917c --- /dev/null +++ b/src/main/java/cash/z/wallet/sdk/data/CompactBlockSource.kt @@ -0,0 +1,8 @@ +package cash.z.wallet.sdk.data + +import kotlinx.coroutines.channels.ReceiveChannel +import rpc.CompactFormats.CompactBlock + +interface CompactBlockSource { + fun blocks(): ReceiveChannel> +} \ No newline at end of file diff --git a/src/main/java/cash/z/wallet/sdk/data/ScanResultDbCreator.kt b/src/main/java/cash/z/wallet/sdk/data/ScanResultDbCreator.kt new file mode 100644 index 00000000..3a0fdf5b --- /dev/null +++ b/src/main/java/cash/z/wallet/sdk/data/ScanResultDbCreator.kt @@ -0,0 +1,68 @@ +package cash.z.wallet.sdk.data + +import android.content.Context +import android.database.sqlite.SQLiteDatabase +import android.database.sqlite.SQLiteOpenHelper + +class ScanResultDbCreator(context: Context) : SQLiteOpenHelper(context, DB_NAME, null, DB_VERSION) { + override fun onCreate(db: SQLiteDatabase) { + SQL_CREATE_DB.split(";").forEach { db.execSQL(it.trim()) } + + } + + override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) { + onCreate(db) + } + + override fun onDowngrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) { + onUpgrade(db, oldVersion, newVersion) + } + + companion object { + const val DB_NAME = "ScannedBlockResults.db" + const val DB_VERSION = 1 + val SQL_CREATE_DB: String = """ + CREATE TABLE IF NOT EXISTS blocks ( + height INTEGER PRIMARY KEY, + time INTEGER, + sapling_tree BLOB + ); + CREATE TABLE IF NOT EXISTS transactions ( + id_tx INTEGER PRIMARY KEY, + txid BLOB NOT NULL UNIQUE, + block INTEGER, + raw BLOB, + FOREIGN KEY (block) REFERENCES blocks(height) + ); + CREATE TABLE IF NOT EXISTS received_notes ( + id_note INTEGER PRIMARY KEY, + tx INTEGER NOT NULL, + output_index INTEGER NOT NULL, + account INTEGER NOT NULL, + diversifier BLOB NOT NULL, + value INTEGER NOT NULL, + rcm BLOB NOT NULL, + nf BLOB NOT NULL UNIQUE, + memo BLOB, + spent INTEGER, + FOREIGN KEY (tx) REFERENCES transactions(id_tx), + FOREIGN KEY (spent) REFERENCES transactions(id_tx), + CONSTRAINT tx_output UNIQUE (tx, output_index) + ); + CREATE TABLE IF NOT EXISTS sapling_witnesses ( + id_witness INTEGER PRIMARY KEY, + note INTEGER NOT NULL, + block INTEGER NOT NULL, + witness BLOB NOT NULL, + FOREIGN KEY (note) REFERENCES received_notes(id_note), + FOREIGN KEY (block) REFERENCES blocks(height), + CONSTRAINT witness_height UNIQUE (note, block) + ) + """.trimIndent() + + fun create(context: Context) { + val db = ScanResultDbCreator(context).writableDatabase + db.close() + } + } +} \ No newline at end of file diff --git a/src/main/java/cash/z/wallet/sdk/data/Synchronizer.kt b/src/main/java/cash/z/wallet/sdk/data/Synchronizer.kt new file mode 100644 index 00000000..5f8e3822 --- /dev/null +++ b/src/main/java/cash/z/wallet/sdk/data/Synchronizer.kt @@ -0,0 +1,104 @@ +package cash.z.wallet.sdk.data + +import android.content.Context +import androidx.room.Room +import androidx.room.RoomDatabase +import cash.z.wallet.sdk.dao.CompactBlockDao +import cash.z.wallet.sdk.db.CompactBlockDb +import cash.z.wallet.sdk.ext.debug +import cash.z.wallet.sdk.jni.JniConverter +import kotlinx.coroutines.* +import kotlinx.coroutines.channels.ConflatedBroadcastChannel +import kotlinx.coroutines.channels.ReceiveChannel +import rpc.CompactFormats + +/** + * Downloads compact blocks to the database and then scans them for transactions + */ +class Synchronizer(val applicationContext: Context, val scope: CoroutineScope, val birthday: Long = 373070L) : CompactBlockSource { + + // TODO: convert to CompactBlockSource that just has a stream and then have the downloader operate on the stream + private val downloader = CompactBlockDownloader(scope) + private val savedBlockChannel = ConflatedBroadcastChannel>() + private lateinit var cacheDao: CompactBlockDao + private lateinit var cacheDb: CompactBlockDb + private lateinit var saveJob: Job + private lateinit var scanJob: Job + override fun blocks(): ReceiveChannel> = savedBlockChannel.openSubscription() + + fun start() { + createDb() + downloader.start() + saveJob = saveBlocks() + scanJob = scanBlocks() + } + + fun stop() { + scanJob.cancel() + saveJob.cancel() + downloader.stop() + cacheDb.close() + } + + private fun createDb() { + // TODO: inject the db and dao + cacheDb = Room.databaseBuilder( + applicationContext, + CompactBlockDb::class.java, + CACHEDB_NAME + ) + .setJournalMode(RoomDatabase.JournalMode.TRUNCATE) + .fallbackToDestructiveMigration() + .build() + .apply { cacheDao = complactBlockDao() } + } + + private fun saveBlocks(): Job = scope.launch { + val downloadedBlockChannel = downloader.blocks() + while (isActive) { + try { + val nextBlock = downloadedBlockChannel.receive().getOrThrow() + cacheDao.insert(cash.z.wallet.sdk.vo.CompactBlock(nextBlock.height.toInt(), nextBlock.toByteArray())) + async { + savedBlockChannel.send(Result.success(nextBlock)) + debug("stored block at height: ${nextBlock.height}") + } + } catch (t: Throwable) { + debug("failed to store block due to $t") + async { + savedBlockChannel.send(Result.failure(t)) + } + } + + } + } + + private fun scanBlocks(): Job = scope.launch { + val savedBlocks = blocks() + val converter = JniConverter() + converter.initLogs() + ScanResultDbCreator.create(applicationContext) + while (isActive) { + try { + debug("scanning blocks from $birthday onward...") + val nextBlock = savedBlocks.receive().getOrThrow() // wait until a block was saved + debug("...scanner observed a block (${nextBlock.height}) without crashing!") + delay(5000L) + val result = converter.scanBlocks( + applicationContext.getDatabasePath(CACHEDB_NAME).absolutePath, + applicationContext.getDatabasePath(ScanResultDbCreator.DB_NAME).absolutePath, + "dummyseed".toByteArray(), + birthday.toInt() + ) + debug("scan complete") + } catch (t: Throwable) { + debug("error while scanning blocks: $t") + } + + } + } + + companion object { + const val CACHEDB_NAME = "DownloadedCompactBlocks.db" + } +} \ No newline at end of file diff --git a/src/main/java/cash/z/wallet/sdk/db/DerivedDataDb.kt b/src/main/java/cash/z/wallet/sdk/db/DerivedDataDb.kt index e88b67a5..67544991 100644 --- a/src/main/java/cash/z/wallet/sdk/db/DerivedDataDb.kt +++ b/src/main/java/cash/z/wallet/sdk/db/DerivedDataDb.kt @@ -15,7 +15,7 @@ import cash.z.wallet.sdk.vo.Transaction Block::class, Note::class ], - version = 1, + version = 2, exportSchema = false ) abstract class DerivedDataDb : RoomDatabase() { diff --git a/src/main/java/cash/z/wallet/sdk/ext/Debug.kt b/src/main/java/cash/z/wallet/sdk/ext/Debug.kt new file mode 100644 index 00000000..85ed9644 --- /dev/null +++ b/src/main/java/cash/z/wallet/sdk/ext/Debug.kt @@ -0,0 +1,7 @@ +package cash.z.wallet.sdk.ext + +import android.util.Log + +internal fun debug(message: String) { + Log.e("DBUG", message) +} \ No newline at end of file diff --git a/src/main/java/cash/z/wallet/sdk/ext/WalletService.kt b/src/main/java/cash/z/wallet/sdk/ext/WalletService.kt new file mode 100644 index 00000000..f27269da --- /dev/null +++ b/src/main/java/cash/z/wallet/sdk/ext/WalletService.kt @@ -0,0 +1,5 @@ +package cash.z.wallet.sdk.ext + +import rpc.Service + +fun Long.toBlockHeight(): Service.BlockID = Service.BlockID.newBuilder().setHeight(this).build() \ No newline at end of file diff --git a/src/main/java/cash/z/wallet/sdk/vo/Block.kt b/src/main/java/cash/z/wallet/sdk/vo/Block.kt index ac8acbca..309d4892 100644 --- a/src/main/java/cash/z/wallet/sdk/vo/Block.kt +++ b/src/main/java/cash/z/wallet/sdk/vo/Block.kt @@ -6,7 +6,7 @@ import androidx.room.Entity @Entity(primaryKeys = ["height"], tableName = "blocks") data class Block( val height: Int, - val time: Int, + val time: Int?, @ColumnInfo(typeAffinity = ColumnInfo.BLOB, name = "sapling_tree") val saplingTree: ByteArray ) { @@ -20,7 +20,7 @@ data class Block( override fun hashCode(): Int { var result = height - result = 31 * result + time + result = 31 * result + (time ?: 0) result = 31 * result + saplingTree.contentHashCode() return result } diff --git a/src/main/java/cash/z/wallet/sdk/vo/Note.kt b/src/main/java/cash/z/wallet/sdk/vo/Note.kt index abd3e9d0..19c8b386 100644 --- a/src/main/java/cash/z/wallet/sdk/vo/Note.kt +++ b/src/main/java/cash/z/wallet/sdk/vo/Note.kt @@ -33,7 +33,7 @@ data class Note( val account: Int, val value: Int, - val spent: Int, + val spent: Int?, @ColumnInfo(typeAffinity = ColumnInfo.BLOB) val diversifier: ByteArray, @@ -69,7 +69,7 @@ data class Note( result = 31 * result + outputIndex result = 31 * result + account result = 31 * result + value - result = 31 * result + spent + result = 31 * result + (spent ?: 0) result = 31 * result + diversifier.contentHashCode() result = 31 * result + rcm.contentHashCode() result = 31 * result + nf.contentHashCode() diff --git a/src/main/proto/WalletData.proto b/src/main/proto/WalletData.proto index e69384c5..9731b26b 100644 --- a/src/main/proto/WalletData.proto +++ b/src/main/proto/WalletData.proto @@ -1,6 +1,7 @@ -package cash.z.wallet.sdk.proto; +syntax = "proto3"; +package rpc; message WalletData { - required string name = 1; - required int32 id = 2; - optional string emails = 3; + string name = 1; + int32 id = 2; + string emails = 3; } \ No newline at end of file diff --git a/src/main/proto/compact_formats.proto b/src/main/proto/compact_formats.proto index d65b658a..07bd3450 100644 --- a/src/main/proto/compact_formats.proto +++ b/src/main/proto/compact_formats.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package cash.z.wallet.sdk.rpc; 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. // bytes fields of hashes are in canonical little-endian format. diff --git a/src/main/proto/service.proto b/src/main/proto/service.proto index 2ae46d2c..d1948467 100644 --- a/src/main/proto/service.proto +++ b/src/main/proto/service.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package cash.z.wallet.sdk.rpc; option go_package = "walletrpc"; +package rpc; import "compact_formats.proto"; diff --git a/src/test/java/cash/z/wallet/sdk/GlueTest.kt b/src/test/java/cash/z/wallet/sdk/GlueTest.kt new file mode 100644 index 00000000..84422708 --- /dev/null +++ b/src/test/java/cash/z/wallet/sdk/GlueTest.kt @@ -0,0 +1,53 @@ +package cash.z.wallet.sdk + + +import android.util.Log +import io.grpc.ManagedChannel +import io.grpc.ManagedChannelBuilder +import org.junit.AfterClass +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNotNull +import org.junit.BeforeClass +import org.junit.Test +import rpc.CompactTxStreamerGrpc +import rpc.Service +import rpc.Service.* +import rpc.WalletDataOuterClass +import java.util.concurrent.TimeUnit + +class GlueTest { + + @Test + fun testSanity_transactionParsing() { + val result = + blockingStub.getBlockRange( + BlockRange.newBuilder() + .setStart(heightOf(373070)) + .setEnd(heightOf(373085)) + .build() + ) + assertNotNull(result) + assertEquals(372950, result.next().height) + } + + fun heightOf(height: Long): Service.BlockID { + return BlockID.newBuilder().setHeight(height).build() + } + + companion object { + lateinit var blockingStub: CompactTxStreamerGrpc.CompactTxStreamerBlockingStub + + @BeforeClass + @JvmStatic + fun setup() { + val channel = ManagedChannelBuilder.forAddress("localhost", 9067).usePlaintext().build() + blockingStub = CompactTxStreamerGrpc.newBlockingStub(channel) + } + + @AfterClass + @JvmStatic + fun tearDown() { + (blockingStub.channel as ManagedChannel).shutdown().awaitTermination(2000L, TimeUnit.MILLISECONDS) + } + } +} \ No newline at end of file diff --git a/src/test/java/cash/z/wallet/sdk/GrpcTest.kt b/src/test/java/cash/z/wallet/sdk/GrpcTest.kt new file mode 100644 index 00000000..2c20a19c --- /dev/null +++ b/src/test/java/cash/z/wallet/sdk/GrpcTest.kt @@ -0,0 +1,68 @@ +package cash.z.wallet.sdk + + +import android.util.Log +import io.grpc.ManagedChannel +import io.grpc.ManagedChannelBuilder +import org.junit.AfterClass +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNotNull +import org.junit.BeforeClass +import org.junit.Test +import rpc.CompactTxStreamerGrpc +import rpc.Service +import rpc.Service.* +import rpc.WalletDataOuterClass +import java.util.concurrent.TimeUnit + +class GrpcTest { + @Test + fun testSanity_protoFilesCreated() { + val name = "Zooko" + val data = WalletDataOuterClass.WalletData.newBuilder() + .setName(name) + .setId(1) + .build() + assertEquals(name, data.name) + } + + @Test + fun testSanity_serviceCreated() { + val result = blockingStub.getLatestBlock(ChainSpec.newBuilder().build()) + assertNotNull(result) + } + + @Test + fun testSanity_transactionParsing() { + val result = + blockingStub.getBlockRange( + BlockRange.newBuilder() + .setStart(heightOf(372950)) + .setEnd(heightOf(372954)) + .build() + ) + assertNotNull(result) + assertEquals(372950, result.next().height) + } + + fun heightOf(height: Long): Service.BlockID { + return BlockID.newBuilder().setHeight(height).build() + } + + companion object { + lateinit var blockingStub: CompactTxStreamerGrpc.CompactTxStreamerBlockingStub + + @BeforeClass + @JvmStatic + fun setup() { + val channel = ManagedChannelBuilder.forAddress("localhost", 9067).usePlaintext().build() + blockingStub = CompactTxStreamerGrpc.newBlockingStub(channel) + } + + @AfterClass + @JvmStatic + fun tearDown() { + (blockingStub.channel as ManagedChannel).shutdown().awaitTermination(2000L, TimeUnit.MILLISECONDS) + } + } +} \ No newline at end of file diff --git a/testing.gradle b/testing.gradle new file mode 100755 index 00000000..462437d8 --- /dev/null +++ b/testing.gradle @@ -0,0 +1,46 @@ +task unregistered { + println "configuring unregistered" + doLast { + println 'unregistered' + } +} + +tasks.register("pb") { + println "configuring pb" + doLast { + println 'preBuild' + } +} +tasks.register("generateJni") { + println "configuring generateJni" + doLast { + println 'jni' + } +} +tasks.register("copyA") { + dependsOn generateJni + println "configuring copyA" + doLast { + println 'copyA' + } +} +tasks.register("copyB") { + dependsOn generateJni + println "configuring copyB" + doLast { + println 'copyB' + } +} +tasks.register("copyC") { + dependsOn generateJni + println "configuring copyC" + doLast { + println 'copyC' + } +} + +task copyAll { + dependsOn copyA, copyB, copyC +} + +pb.dependsOn copyAll \ No newline at end of file