Skip to content

Adding a new RPC end point to access blockhashes #303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions vm/ieleApi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ let get_account_field address blocknumber field convert default =
let eth_getCode address blocknumber =
`String (get_account_field address blocknumber "code" to_string "0x")

let eth_getBlockhash offset =
let hash = IeleClientUtils.InMemoryWorldState.get_blockhash (int_of_string offset) in
`String (to_hex_unsigned hash)

let eth_getBlockByNumber blocknumber =
let block = get_block blocknumber in
`Assoc [("timestamp", `String block.timestamp)]
Expand Down
1 change: 1 addition & 0 deletions vm/ieleApi.mli
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
open Yojson.Basic

val eth_getCode : string -> string -> json
val eth_getBlockhash : string -> json
val eth_getBlockByNumber : string -> json
val eth_getTransactionReceipt : string -> json
val iele_sendTransaction : json -> json
Expand Down
1 change: 1 addition & 0 deletions vm/ieleApiClient.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ let process_requests (_in,fd) =
let params = request |> member "params" |> to_list in
let response = match _method, params with
| "eth_getCode", [`String address; `String number] -> eth_getCode address number
| "eth_getBlockhash", [`String offset] -> eth_getBlockhash offset
| "eth_getBlockByNumber", [`String number; `Bool _] -> eth_getBlockByNumber number
| "eth_getTransactionReceipt", [`String hash] -> eth_getTransactionReceipt hash
| "iele_sendTransaction", [tx] -> iele_sendTransaction tx
Expand Down