protobuf update for 0.9.1

This commit is contained in:
Ich 2017-05-03 11:29:05 +02:00
parent b5b2c6e3a3
commit f81e092a0d
4 changed files with 827 additions and 305 deletions

View File

@ -23,7 +23,6 @@
*/
package com.github.jtendermint.jabci;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.nio.ByteBuffer;
@ -65,7 +64,9 @@ public class JavaCounter implements IDeliverTx, ICheckTx, ICommit, IQuery {
socket.registerListener(this);
new Thread(socket::start).start();
Thread t = new Thread(socket::start);
t.setName("Java Counter Main Thread");
t.start();
while (true) {
Thread.sleep(1000L);
}
@ -133,30 +134,15 @@ public class JavaCounter implements IDeliverTx, ICheckTx, ICommit, IQuery {
@Override
public ResponseQuery requestQuery(RequestQuery req) {
final ResponseQuery internalError = ResponseQuery.newBuilder().setCode(CodeType.InternalError).setLog("some shit happened").build();
final String query = req.getQuery().toString();
System.out.println("Query is: " + query);
final String query = new String(req.getData().toByteArray());
switch (query) {
case "hash":
try {
return ResponseQuery.newBuilder().setCode(CodeType.OK).setData(ByteString.copyFrom("" + hashCount, "UTF-8")).build();
} catch (UnsupportedEncodingException e) {
return internalError;
}
return ResponseQuery.newBuilder().setCode(CodeType.OK).setValue(ByteString.copyFrom(("" + hashCount).getBytes())).build();
case "tx":
try {
return ResponseQuery.newBuilder().setCode(CodeType.OK).setData(ByteString.copyFrom("" + txCount, "UTF-8")).build();
} catch (UnsupportedEncodingException e) {
return internalError;
}
return ResponseQuery.newBuilder().setCode(CodeType.OK).setValue(ByteString.copyFrom(("" + txCount).getBytes())).build();
default:
return ResponseQuery.newBuilder().setLog("Invalid query path. Expected hash or tx, got " + query).build();
return ResponseQuery.newBuilder().setCode(CodeType.BadNonce).setLog("Invalid query path. Expected hash or tx, got " + query)
.build();
}
}
}

View File

@ -225,6 +225,7 @@ public class TSocket extends ASocket {
} catch (IOException e) {
if (!isInterrupted()) {
HANDLER_LOG.error("Error with " + this.getName(), e);
HANDLER_LOG.info("Note: If \"the input ended unexpectedly\" it could mean the protobuf file is not up to date.");
}
}
HANDLER_LOG.debug("Stopping Thread " + this.getName());

File diff suppressed because it is too large Load Diff

View File

@ -6,67 +6,67 @@ package com.github.jtendermint.jabci.types;
//----------------------------------------
// Message types
// Not being used
// Not being used
// Could be added to request/response
// so we don't have to type switch
// (would be twice as fast, but we're talking about 15ns)
enum MessageType {
NullMessage = 0x00;
NullMessage = 0x00;
Echo = 0x01;
Flush = 0x02;
Info = 0x03;
SetOption = 0x04;
Exception = 0x05;
DeliverTx = 0x11;
CheckTx = 0x12;
Commit = 0x13;
Query = 0x14;
InitChain = 0x15;
BeginBlock = 0x16;
EndBlock = 0x17;
Echo = 0x01;
Flush = 0x02;
Info = 0x03;
SetOption = 0x04;
Exception = 0x05;
DeliverTx = 0x11;
CheckTx = 0x12;
Commit = 0x13;
Query = 0x14;
InitChain = 0x15;
BeginBlock = 0x16;
EndBlock = 0x17;
}
//----------------------------------------
// Code types
enum CodeType {
OK = 0;
OK = 0;
// General response codes, 0 ~ 99
InternalError = 1;
EncodingError = 2;
BadNonce = 3;
Unauthorized = 4;
InsufficientFunds = 5;
UnknownRequest = 6;
// General response codes, 0 ~ 99
InternalError = 1;
EncodingError = 2;
BadNonce = 3;
Unauthorized = 4;
InsufficientFunds = 5;
UnknownRequest = 6;
// Reserved for basecoin, 100 ~ 199
BaseDuplicateAddress = 101;
BaseEncodingError = 102;
BaseInsufficientFees = 103;
BaseInsufficientFunds = 104;
BaseInsufficientGasPrice = 105;
BaseInvalidInput = 106;
BaseInvalidOutput = 107;
BaseInvalidPubKey = 108;
BaseInvalidSequence = 109;
BaseInvalidSignature = 110;
BaseUnknownAddress = 111;
BaseUnknownPubKey = 112;
BaseUnknownPlugin = 113;
// Reserved for basecoin, 100 ~ 199
BaseDuplicateAddress = 101;
BaseEncodingError = 102;
BaseInsufficientFees = 103;
BaseInsufficientFunds = 104;
BaseInsufficientGasPrice = 105;
BaseInvalidInput = 106;
BaseInvalidOutput = 107;
BaseInvalidPubKey = 108;
BaseInvalidSequence = 109;
BaseInvalidSignature = 110;
BaseUnknownAddress = 111;
BaseUnknownPubKey = 112;
BaseUnknownPlugin = 113;
// Reserved for governance, 200 ~ 299
GovUnknownEntity = 201;
GovUnknownGroup = 202;
GovUnknownProposal = 203;
GovDuplicateGroup = 204;
GovDuplicateMember = 205;
GovDuplicateProposal = 206;
GovDuplicateVote = 207;
GovInvalidMember = 208;
GovInvalidVote = 209;
GovInvalidVotingPower = 210;
// Reserved for governance, 200 ~ 299
GovUnknownEntity = 201;
GovUnknownGroup = 202;
GovUnknownProposal = 203;
GovDuplicateGroup = 204;
GovDuplicateMember = 205;
GovDuplicateProposal = 206;
GovDuplicateVote = 207;
GovInvalidMember = 208;
GovInvalidVote = 209;
GovInvalidVotingPower = 210;
}
@ -105,15 +105,18 @@ message RequestSetOption{
}
message RequestDeliverTx{
bytes tx = 1;
bytes tx = 1;
}
message RequestCheckTx{
bytes tx = 1;
bytes tx = 1;
}
message RequestQuery{
bytes query = 1;
bytes data = 1;
string path = 2;
uint64 height = 3;
bool prove = 4;
}
message RequestCommit{
@ -189,8 +192,12 @@ message ResponseCheckTx{
message ResponseQuery{
CodeType code = 1;
bytes data = 2;
string log = 3;
int64 index = 2;
bytes key = 3;
bytes value = 4;
bytes proof = 5;
uint64 height = 6;
string log = 7;
}
message ResponseCommit{
@ -207,7 +214,7 @@ message ResponseBeginBlock{
}
message ResponseEndBlock{
repeated Validator diffs = 4;
repeated Validator diffs = 1;
}
//----------------------------------------
@ -222,7 +229,7 @@ message Header {
bytes last_commit_hash = 6;
bytes data_hash = 7;
bytes validators_hash = 8;
bytes app_hash = 9;
bytes app_hash = 9;
}
message BlockID {
@ -236,8 +243,8 @@ message PartSetHeader {
}
message Validator {
bytes pubKey = 1;
uint64 power = 2;
bytes pubKey = 1;
uint64 power = 2;
}
//----------------------------------------