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;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
@ -113,7 +113,10 @@ message RequestCheckTx{
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user