Skip to content

Commit

Permalink
Moved minerStart() and minerStop() methods to the JsonRpc2_0Geth class
Browse files Browse the repository at this point in the history
  • Loading branch information
mushketyk committed Apr 3, 2018
1 parent 6b297f8 commit e4957ec
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 52 deletions.
6 changes: 0 additions & 6 deletions core/src/main/java/org/web3j/protocol/core/Ethereum.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.math.BigInteger;

import org.web3j.protocol.admin.methods.response.BooleanResponse;
import org.web3j.protocol.core.methods.request.ShhFilter;
import org.web3j.protocol.core.methods.response.DbGetHex;
import org.web3j.protocol.core.methods.response.DbGetString;
Expand Down Expand Up @@ -39,7 +38,6 @@
import org.web3j.protocol.core.methods.response.EthSyncing;
import org.web3j.protocol.core.methods.response.EthTransaction;
import org.web3j.protocol.core.methods.response.EthUninstallFilter;
import org.web3j.protocol.core.methods.response.MinerStartResponse;
import org.web3j.protocol.core.methods.response.NetListening;
import org.web3j.protocol.core.methods.response.NetPeerCount;
import org.web3j.protocol.core.methods.response.NetVersion;
Expand Down Expand Up @@ -200,8 +198,4 @@ Request<?, org.web3j.protocol.core.methods.response.ShhPost> shhPost(
Request<?, ShhMessages> shhGetFilterChanges(BigInteger filterId);

Request<?, ShhMessages> shhGetMessages(BigInteger filterId);

Request<?, MinerStartResponse> minerStart(int threadCount);

Request<?, BooleanResponse> minerStop();
}
20 changes: 0 additions & 20 deletions core/src/main/java/org/web3j/protocol/core/JsonRpc2_0Web3j.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import org.web3j.protocol.Web3j;
import org.web3j.protocol.Web3jService;
import org.web3j.protocol.admin.methods.response.BooleanResponse;
import org.web3j.protocol.core.methods.request.ShhFilter;
import org.web3j.protocol.core.methods.request.ShhPost;
import org.web3j.protocol.core.methods.request.Transaction;
Expand Down Expand Up @@ -49,7 +48,6 @@
import org.web3j.protocol.core.methods.response.EthTransaction;
import org.web3j.protocol.core.methods.response.EthUninstallFilter;
import org.web3j.protocol.core.methods.response.Log;
import org.web3j.protocol.core.methods.response.MinerStartResponse;
import org.web3j.protocol.core.methods.response.NetListening;
import org.web3j.protocol.core.methods.response.NetPeerCount;
import org.web3j.protocol.core.methods.response.NetVersion;
Expand Down Expand Up @@ -688,24 +686,6 @@ public Request<?, ShhMessages> shhGetMessages(BigInteger filterId) {
ShhMessages.class);
}

@Override
public Request<?, MinerStartResponse> minerStart(int threadCount) {
return new Request<>(
"miner_start",
Arrays.asList(threadCount),
web3jService,
MinerStartResponse.class);
}

@Override
public Request<?, BooleanResponse> minerStop() {
return new Request<>(
"miner_stop",
Collections.<String>emptyList(),
web3jService,
BooleanResponse.class);
}

@Override
public Observable<String> ethBlockHashObservable() {
return web3jRx.ethBlockHashObservable(blockTime);
Expand Down
19 changes: 0 additions & 19 deletions core/src/test/java/org/web3j/protocol/core/RequestTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

import org.web3j.protocol.RequestTester;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.DefaultBlockParameter;
import org.web3j.protocol.core.DefaultBlockParameterName;
import org.web3j.protocol.core.methods.request.EthFilter;
import org.web3j.protocol.core.methods.request.ShhFilter;
import org.web3j.protocol.core.methods.request.ShhPost;
Expand Down Expand Up @@ -623,21 +621,4 @@ public void testShhGetMessages() throws Exception {
verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"shh_getMessages\","
+ "\"params\":[\"0x07\"],\"id\":1}");
}

@Test
public void testMinerStart() throws Exception {
web3j.minerStart(4).send();

verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"miner_start\","
+ "\"params\":[4],\"id\":1}");
}

@Test
public void testMinerStop() throws Exception {
web3j.minerStop().send();

verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"miner_stop\","
+ "\"params\":[],\"id\":1}");
}

}
15 changes: 10 additions & 5 deletions geth/src/main/java/org/web3j/protocol/geth/Geth.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.web3j.protocol.admin.methods.response.BooleanResponse;
import org.web3j.protocol.admin.methods.response.PersonalSign;
import org.web3j.protocol.core.Request;
import org.web3j.protocol.core.methods.response.MinerStartResponse;
import org.web3j.protocol.geth.response.PersonalEcRecover;
import org.web3j.protocol.geth.response.PersonalImportRawKey;

Expand All @@ -16,12 +17,16 @@ static Geth build(Web3jService web3jService) {
return new JsonRpc2_0Geth(web3jService);
}

public Request<?, PersonalImportRawKey> personalImportRawKey(String keydata, String password);
Request<?, PersonalImportRawKey> personalImportRawKey(String keydata, String password);

public Request<?, BooleanResponse> personalLockAccount(String accountId);
Request<?, BooleanResponse> personalLockAccount(String accountId);

public Request<?, PersonalSign> personalSign(String message, String accountId, String password);

public Request<?, PersonalEcRecover> personalEcRecover(String message, String signiture);
Request<?, PersonalSign> personalSign(String message, String accountId, String password);

Request<?, PersonalEcRecover> personalEcRecover(String message, String signiture);

Request<?, MinerStartResponse> minerStart(int threadCount);

Request<?, BooleanResponse> minerStop();

}
24 changes: 22 additions & 2 deletions geth/src/main/java/org/web3j/protocol/geth/JsonRpc2_0Geth.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package org.web3j.protocol.geth;

import java.util.Arrays;
import java.util.Collections;

import org.web3j.protocol.Web3jService;
import org.web3j.protocol.admin.JsonRpc2_0Admin;
import org.web3j.protocol.admin.methods.response.BooleanResponse;
import org.web3j.protocol.admin.methods.response.PersonalSign;
import org.web3j.protocol.core.Request;
import org.web3j.protocol.core.methods.response.MinerStartResponse;
import org.web3j.protocol.geth.response.PersonalEcRecover;
import org.web3j.protocol.geth.response.PersonalImportRawKey;

Expand Down Expand Up @@ -56,6 +58,24 @@ public Request<?, PersonalEcRecover> personalEcRecover(
Arrays.asList(hexMessage,signedMessage),
web3jService,
PersonalEcRecover.class);
}

}

@Override
public Request<?, MinerStartResponse> minerStart(int threadCount) {
return new Request<>(
"miner_start",
Arrays.asList(threadCount),
web3jService,
MinerStartResponse.class);
}

@Override
public Request<?, BooleanResponse> minerStop() {
return new Request<>(
"miner_stop",
Collections.<String>emptyList(),
web3jService,
BooleanResponse.class);
}

}
16 changes: 16 additions & 0 deletions geth/src/test/java/org/web3j/protocol/geth/RequestTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,20 @@ public void testPersonalEcRecover() throws Exception {
verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"personal_ecRecover\",\"params\":[\"0xdeadbeaf\",\"0xa3f20717a250c2b0b729b7e5becbff67fdaef7e0699da4de7ca5895b02a170a12d887fd3b17bfdce3481f10bea41f45ba9f709d39ce8325427b57afcfc994cee1b\"],\"id\":1}");
//CHECKSTYLE:ON
}

@Test
public void testMinerStart() throws Exception {
web3j.minerStart(4).send();

verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"miner_start\","
+ "\"params\":[4],\"id\":1}");
}

@Test
public void testMinerStop() throws Exception {
web3j.minerStop().send();

verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"miner_stop\","
+ "\"params\":[],\"id\":1}");
}
}

0 comments on commit e4957ec

Please sign in to comment.