mirror of
https://github.com/fluencelabs/jabci
synced 2025-03-31 01:11:12 +00:00
protobuf update for 0.9.1
This commit is contained in:
parent
b5b2c6e3a3
commit
f81e092a0d
@ -23,7 +23,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.github.jtendermint.jabci;
|
package com.github.jtendermint.jabci;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
@ -65,7 +64,9 @@ public class JavaCounter implements IDeliverTx, ICheckTx, ICommit, IQuery {
|
|||||||
|
|
||||||
socket.registerListener(this);
|
socket.registerListener(this);
|
||||||
|
|
||||||
new Thread(socket::start).start();
|
Thread t = new Thread(socket::start);
|
||||||
|
t.setName("Java Counter Main Thread");
|
||||||
|
t.start();
|
||||||
while (true) {
|
while (true) {
|
||||||
Thread.sleep(1000L);
|
Thread.sleep(1000L);
|
||||||
}
|
}
|
||||||
@ -133,30 +134,15 @@ public class JavaCounter implements IDeliverTx, ICheckTx, ICommit, IQuery {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseQuery requestQuery(RequestQuery req) {
|
public ResponseQuery requestQuery(RequestQuery req) {
|
||||||
|
final String query = new String(req.getData().toByteArray());
|
||||||
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);
|
|
||||||
|
|
||||||
switch (query) {
|
switch (query) {
|
||||||
case "hash":
|
case "hash":
|
||||||
try {
|
return ResponseQuery.newBuilder().setCode(CodeType.OK).setValue(ByteString.copyFrom(("" + hashCount).getBytes())).build();
|
||||||
return ResponseQuery.newBuilder().setCode(CodeType.OK).setData(ByteString.copyFrom("" + hashCount, "UTF-8")).build();
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
return internalError;
|
|
||||||
}
|
|
||||||
case "tx":
|
case "tx":
|
||||||
try {
|
return ResponseQuery.newBuilder().setCode(CodeType.OK).setValue(ByteString.copyFrom(("" + txCount).getBytes())).build();
|
||||||
return ResponseQuery.newBuilder().setCode(CodeType.OK).setData(ByteString.copyFrom("" + txCount, "UTF-8")).build();
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
return internalError;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
|
return ResponseQuery.newBuilder().setCode(CodeType.BadNonce).setLog("Invalid query path. Expected hash or tx, got " + query)
|
||||||
return ResponseQuery.newBuilder().setLog("Invalid query path. Expected hash or tx, got " + query).build();
|
.build();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,6 +225,7 @@ public class TSocket extends ASocket {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
if (!isInterrupted()) {
|
if (!isInterrupted()) {
|
||||||
HANDLER_LOG.error("Error with " + this.getName(), e);
|
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());
|
HANDLER_LOG.debug("Stopping Thread " + this.getName());
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -6,67 +6,67 @@ package com.github.jtendermint.jabci.types;
|
|||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
// Message types
|
// Message types
|
||||||
|
|
||||||
// Not being used
|
// Not being used
|
||||||
// Could be added to request/response
|
// Could be added to request/response
|
||||||
// so we don't have to type switch
|
// so we don't have to type switch
|
||||||
// (would be twice as fast, but we're talking about 15ns)
|
// (would be twice as fast, but we're talking about 15ns)
|
||||||
enum MessageType {
|
enum MessageType {
|
||||||
NullMessage = 0x00;
|
NullMessage = 0x00;
|
||||||
|
|
||||||
Echo = 0x01;
|
Echo = 0x01;
|
||||||
Flush = 0x02;
|
Flush = 0x02;
|
||||||
Info = 0x03;
|
Info = 0x03;
|
||||||
SetOption = 0x04;
|
SetOption = 0x04;
|
||||||
Exception = 0x05;
|
Exception = 0x05;
|
||||||
DeliverTx = 0x11;
|
DeliverTx = 0x11;
|
||||||
CheckTx = 0x12;
|
CheckTx = 0x12;
|
||||||
Commit = 0x13;
|
Commit = 0x13;
|
||||||
Query = 0x14;
|
Query = 0x14;
|
||||||
InitChain = 0x15;
|
InitChain = 0x15;
|
||||||
BeginBlock = 0x16;
|
BeginBlock = 0x16;
|
||||||
EndBlock = 0x17;
|
EndBlock = 0x17;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
// Code types
|
// Code types
|
||||||
|
|
||||||
enum CodeType {
|
enum CodeType {
|
||||||
OK = 0;
|
OK = 0;
|
||||||
|
|
||||||
// General response codes, 0 ~ 99
|
// General response codes, 0 ~ 99
|
||||||
InternalError = 1;
|
InternalError = 1;
|
||||||
EncodingError = 2;
|
EncodingError = 2;
|
||||||
BadNonce = 3;
|
BadNonce = 3;
|
||||||
Unauthorized = 4;
|
Unauthorized = 4;
|
||||||
InsufficientFunds = 5;
|
InsufficientFunds = 5;
|
||||||
UnknownRequest = 6;
|
UnknownRequest = 6;
|
||||||
|
|
||||||
// Reserved for basecoin, 100 ~ 199
|
// Reserved for basecoin, 100 ~ 199
|
||||||
BaseDuplicateAddress = 101;
|
BaseDuplicateAddress = 101;
|
||||||
BaseEncodingError = 102;
|
BaseEncodingError = 102;
|
||||||
BaseInsufficientFees = 103;
|
BaseInsufficientFees = 103;
|
||||||
BaseInsufficientFunds = 104;
|
BaseInsufficientFunds = 104;
|
||||||
BaseInsufficientGasPrice = 105;
|
BaseInsufficientGasPrice = 105;
|
||||||
BaseInvalidInput = 106;
|
BaseInvalidInput = 106;
|
||||||
BaseInvalidOutput = 107;
|
BaseInvalidOutput = 107;
|
||||||
BaseInvalidPubKey = 108;
|
BaseInvalidPubKey = 108;
|
||||||
BaseInvalidSequence = 109;
|
BaseInvalidSequence = 109;
|
||||||
BaseInvalidSignature = 110;
|
BaseInvalidSignature = 110;
|
||||||
BaseUnknownAddress = 111;
|
BaseUnknownAddress = 111;
|
||||||
BaseUnknownPubKey = 112;
|
BaseUnknownPubKey = 112;
|
||||||
BaseUnknownPlugin = 113;
|
BaseUnknownPlugin = 113;
|
||||||
|
|
||||||
// Reserved for governance, 200 ~ 299
|
// Reserved for governance, 200 ~ 299
|
||||||
GovUnknownEntity = 201;
|
GovUnknownEntity = 201;
|
||||||
GovUnknownGroup = 202;
|
GovUnknownGroup = 202;
|
||||||
GovUnknownProposal = 203;
|
GovUnknownProposal = 203;
|
||||||
GovDuplicateGroup = 204;
|
GovDuplicateGroup = 204;
|
||||||
GovDuplicateMember = 205;
|
GovDuplicateMember = 205;
|
||||||
GovDuplicateProposal = 206;
|
GovDuplicateProposal = 206;
|
||||||
GovDuplicateVote = 207;
|
GovDuplicateVote = 207;
|
||||||
GovInvalidMember = 208;
|
GovInvalidMember = 208;
|
||||||
GovInvalidVote = 209;
|
GovInvalidVote = 209;
|
||||||
GovInvalidVotingPower = 210;
|
GovInvalidVotingPower = 210;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,15 +105,18 @@ message RequestSetOption{
|
|||||||
}
|
}
|
||||||
|
|
||||||
message RequestDeliverTx{
|
message RequestDeliverTx{
|
||||||
bytes tx = 1;
|
bytes tx = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message RequestCheckTx{
|
message RequestCheckTx{
|
||||||
bytes tx = 1;
|
bytes tx = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message RequestQuery{
|
message RequestQuery{
|
||||||
bytes query = 1;
|
bytes data = 1;
|
||||||
|
string path = 2;
|
||||||
|
uint64 height = 3;
|
||||||
|
bool prove = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message RequestCommit{
|
message RequestCommit{
|
||||||
@ -189,8 +192,12 @@ message ResponseCheckTx{
|
|||||||
|
|
||||||
message ResponseQuery{
|
message ResponseQuery{
|
||||||
CodeType code = 1;
|
CodeType code = 1;
|
||||||
bytes data = 2;
|
int64 index = 2;
|
||||||
string log = 3;
|
bytes key = 3;
|
||||||
|
bytes value = 4;
|
||||||
|
bytes proof = 5;
|
||||||
|
uint64 height = 6;
|
||||||
|
string log = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ResponseCommit{
|
message ResponseCommit{
|
||||||
@ -207,7 +214,7 @@ message ResponseBeginBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
message ResponseEndBlock{
|
message ResponseEndBlock{
|
||||||
repeated Validator diffs = 4;
|
repeated Validator diffs = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
@ -222,7 +229,7 @@ message Header {
|
|||||||
bytes last_commit_hash = 6;
|
bytes last_commit_hash = 6;
|
||||||
bytes data_hash = 7;
|
bytes data_hash = 7;
|
||||||
bytes validators_hash = 8;
|
bytes validators_hash = 8;
|
||||||
bytes app_hash = 9;
|
bytes app_hash = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
message BlockID {
|
message BlockID {
|
||||||
@ -236,8 +243,8 @@ message PartSetHeader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message Validator {
|
message Validator {
|
||||||
bytes pubKey = 1;
|
bytes pubKey = 1;
|
||||||
uint64 power = 2;
|
uint64 power = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user