This is an automated email from the ASF dual-hosted git repository.
toulmean pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-tuweni.git
The following commit(s) were added to refs/heads/main by this push:
new 5bd0556 Example of eth_blockNumber method
new db50038 Merge pull request #242 from atoulme/jsonrpc_server
5bd0556 is described below
commit 5bd0556c31bd439170f9a62aab4c4b55e0202e7e
Author: Antoine Toulme <[email protected]>
AuthorDate: Sun May 23 17:01:02 2021 -0700
Example of eth_blockNumber method
---
.../apache/tuweni/eth/repository/rpc/RpcMethods.kt | 36 ++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git
a/eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/rpc/RpcMethods.kt
b/eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/rpc/RpcMethods.kt
new file mode 100644
index 0000000..508615e
--- /dev/null
+++
b/eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/rpc/RpcMethods.kt
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.tuweni.eth.repository.rpc
+
+import kotlinx.coroutines.runBlocking
+import org.apache.tuweni.eth.JSONRPCRequest
+import org.apache.tuweni.eth.JSONRPCResponse
+import org.apache.tuweni.eth.invalidParams
+import org.apache.tuweni.eth.repository.BlockchainRepository
+
+class BlockchainRepositoryRpcMethods(val repository: BlockchainRepository) {
+
+ fun getMostRecentBlockNumber(request: JSONRPCRequest): JSONRPCResponse {
+ if (request.params.isNotEmpty()) {
+ return invalidParams.copy(id = request.id)
+ }
+ return runBlocking {
+ val number = repository.retrieveChainHead().header.number
+ return@runBlocking JSONRPCResponse(id = request.id, result =
number.toHexString())
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]