mirror of https://github.com/hyperledger/besu
[nc-1756] jsonrpc enabling for clique and ibft (#91)
parent
fdd08a8820
commit
0d77c515b5
@ -0,0 +1,33 @@ |
||||
/* |
||||
* Copyright 2018 ConsenSys AG. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
||||
* specific language governing permissions and limitations under the License. |
||||
*/ |
||||
package tech.pegasys.pantheon.consensus.clique.jsonrpc; |
||||
|
||||
import tech.pegasys.pantheon.ethereum.jsonrpc.RpcApi; |
||||
|
||||
import java.util.Optional; |
||||
|
||||
public class CliqueRpcApis { |
||||
public static final RpcApi CLIQUE = new RpcApi("CLIQUE"); |
||||
|
||||
public static final Optional<RpcApi> valueOf(final String name) { |
||||
if (name.equals(CLIQUE.getCliValue())) { |
||||
return Optional.of(CLIQUE); |
||||
} else { |
||||
return Optional.empty(); |
||||
} |
||||
} |
||||
|
||||
public static final String getName(final RpcApi rpcapi) { |
||||
return rpcapi.getCliValue(); |
||||
} |
||||
} |
@ -0,0 +1,33 @@ |
||||
/* |
||||
* Copyright 2018 ConsenSys AG. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
||||
* specific language governing permissions and limitations under the License. |
||||
*/ |
||||
package tech.pegasys.pantheon.consensus.ibft.jsonrpc; |
||||
|
||||
import tech.pegasys.pantheon.ethereum.jsonrpc.RpcApi; |
||||
|
||||
import java.util.Optional; |
||||
|
||||
public class IbftRpcApis { |
||||
public static final RpcApi IBFT = new RpcApi("IBFT"); |
||||
|
||||
public static final Optional<RpcApi> valueOf(final String name) { |
||||
if (name.equals(IBFT.getCliValue())) { |
||||
return Optional.of(IBFT); |
||||
} else { |
||||
return Optional.empty(); |
||||
} |
||||
} |
||||
|
||||
public static final String getName(final RpcApi rpcapi) { |
||||
return rpcapi.getCliValue(); |
||||
} |
||||
} |
@ -0,0 +1,44 @@ |
||||
/* |
||||
* Copyright 2018 ConsenSys AG. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
||||
* specific language governing permissions and limitations under the License. |
||||
*/ |
||||
package tech.pegasys.pantheon.ethereum.jsonrpc; |
||||
|
||||
import com.google.common.base.Objects; |
||||
|
||||
public class RpcApi { |
||||
private final String cliValue; |
||||
|
||||
public RpcApi(final String cliValue) { |
||||
this.cliValue = cliValue; |
||||
} |
||||
|
||||
public String getCliValue() { |
||||
return cliValue; |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(final Object o) { |
||||
if (this == o) { |
||||
return true; |
||||
} |
||||
if (o == null || getClass() != o.getClass()) { |
||||
return false; |
||||
} |
||||
final RpcApi rpcApi = (RpcApi) o; |
||||
return Objects.equal(cliValue, rpcApi.cliValue); |
||||
} |
||||
|
||||
@Override |
||||
public int hashCode() { |
||||
return Objects.hashCode(cliValue); |
||||
} |
||||
} |
@ -0,0 +1,47 @@ |
||||
/* |
||||
* Copyright 2018 ConsenSys AG. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
||||
* specific language governing permissions and limitations under the License. |
||||
*/ |
||||
package tech.pegasys.pantheon.ethereum.jsonrpc; |
||||
|
||||
import java.util.Arrays; |
||||
import java.util.Collection; |
||||
import java.util.Optional; |
||||
|
||||
public class RpcApis { |
||||
public static final RpcApi ETH = new RpcApi("ETH"); |
||||
public static final RpcApi DEBUG = new RpcApi("DEBUG"); |
||||
public static final RpcApi MINER = new RpcApi("MINER"); |
||||
public static final RpcApi NET = new RpcApi("NET"); |
||||
public static final RpcApi WEB3 = new RpcApi("WEB3"); |
||||
|
||||
public static final Collection<RpcApi> DEFAULT_JSON_RPC_APIS = Arrays.asList(ETH, NET, WEB3); |
||||
|
||||
public static final Optional<RpcApi> valueOf(final String name) { |
||||
if (name.equals(ETH.getCliValue())) { |
||||
return Optional.of(ETH); |
||||
} else if (name.equals(DEBUG.getCliValue())) { |
||||
return Optional.of(DEBUG); |
||||
} else if (name.equals(MINER.getCliValue())) { |
||||
return Optional.of(MINER); |
||||
} else if (name.equals(NET.getCliValue())) { |
||||
return Optional.of(NET); |
||||
} else if (name.equals(WEB3.getCliValue())) { |
||||
return Optional.of(WEB3); |
||||
} else { |
||||
return Optional.empty(); |
||||
} |
||||
} |
||||
|
||||
public static final String getValue(final RpcApi rpcapi) { |
||||
return rpcapi.getCliValue(); |
||||
} |
||||
} |
Loading…
Reference in new issue