Skip to content

Commit

Permalink
arktika checking field number for rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
fireduck64 committed Jul 19, 2018
1 parent bc65a13 commit 2514ba9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion client/src/SnowBlossomClient.java
Expand Up @@ -193,7 +193,7 @@ else if (command.equals("loadtest"))
System.out.println(" if generate_now is true, generate a new address rather than using the key pool");
System.out.println(" send <amount> <destination> - send snow to address");
System.out.println(" export <file> - export wallet to json file");
System.out.println(" import <file> - import wallet from json file");
System.out.println(" import <file> - import wallet from json file, merges with existing");


System.exit(-1);
Expand Down
4 changes: 2 additions & 2 deletions miner/src/Arktika.java
Expand Up @@ -142,7 +142,7 @@ public Arktika(Config config) throws Exception

Server s = ServerBuilder
.forPort(2311)
.addService(new Stubo(composit_source))
.addService(new Stubo(composit_source, selected_field))
.build();
s.start();

Expand Down Expand Up @@ -417,7 +417,7 @@ else if (type.equals("fake"))
}
else if (type.equals("remote"))
{
FieldSource fs = new FieldSourceRemote(config, i);
FieldSource fs = new FieldSourceRemote(config, i, selected_field);
all_sources[i] = fs;
//Not adding to composit because
// 1) to slow for current merkle implementation
Expand Down
9 changes: 7 additions & 2 deletions miner/src/FieldSourceRemote.java
Expand Up @@ -30,9 +30,11 @@ public class FieldSourceRemote extends FieldSource implements BatchSource
{
private ThreadLocal<SharedMiningServiceBlockingStub> stub_local=new ThreadLocal<>();
SharedMiningServiceBlockingStub stub_one;
private int field_number;

public FieldSourceRemote(Config config, int layer)
public FieldSourceRemote(Config config, int layer, int field_number)
{
this.field_number = field_number;
config.require("layer_" + layer + "_host");
config.require("layer_" + layer + "_range");

Expand Down Expand Up @@ -95,7 +97,10 @@ public void bulkRead(long word_index, ByteBuffer bb) throws java.io.IOException
@Override
public List<ByteString> readWordsBulk(List<Long> indexes)
{
return getStub().getWords(GetWordsRequest.newBuilder().addAllWordIndexes(indexes).build()).getWordsList();
return getStub().getWords(GetWordsRequest.newBuilder()
.addAllWordIndexes(indexes)
.setField(field_number)
.build()).getWordsList();
}


Expand Down
12 changes: 11 additions & 1 deletion miner/src/Stubo.java
Expand Up @@ -11,16 +11,26 @@
public class Stubo extends SharedMiningServiceGrpc.SharedMiningServiceImplBase
{
FieldSource src;
public Stubo(FieldSource src)
int field_number;
public Stubo(FieldSource src, int field_number)
{
this.src = src;
this.field_number = field_number;
}

@Override
public void getWords(GetWordsRequest req, StreamObserver<GetWordsResponce> observer)
{
try
{
if (req.getField() > 0)
{
if (req.getField() != field_number)
{
throw new java.io.IOException(
String.format("Wrong field requested %d. I have %d", req.getField(), field_number));
}
}
GetWordsResponce.Builder builder = GetWordsResponce.newBuilder();

for(long x : req.getWordIndexesList())
Expand Down
1 change: 1 addition & 0 deletions protolib/mining_pool.proto
Expand Up @@ -44,6 +44,7 @@ service SharedMiningService {

message GetWordsRequest {
repeated int64 word_indexes = 1;
int32 field = 2;
}

message GetWordsResponce {
Expand Down

0 comments on commit 2514ba9

Please sign in to comment.