Skip to content

Commit

Permalink
Added Version to the NodeController for the node version rpc call
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigo-o committed Jul 17, 2024
1 parent f0590fe commit 906a811
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/beacon_api/controllers/v1/node_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ defmodule BeaconApi.V1.NodeController do
def open_api_operation(:identity),
do: ApiSpec.spec().paths["/eth/v1/node/identity"].get

def open_api_operation(:version),
do: ApiSpec.spec().paths["/eth/v1/node/version"].get

@spec health(Plug.Conn.t(), any) :: Plug.Conn.t()
def health(conn, params) do
# TODO: respond with syncing status if we're still syncing
Expand Down Expand Up @@ -46,4 +49,17 @@ defmodule BeaconApi.V1.NodeController do
}
})
end

@spec version(Plug.Conn.t(), any) :: Plug.Conn.t()
def version(conn, _params) do
version = Application.spec(:lambda_ethereum_consensus)[:vsn]
arch = :erlang.system_info(:system_architecture)

conn
|> json(%{
"data" => %{
"version" => "Lambda/#{version}/#{arch}",
}
})
end
end
1 change: 1 addition & 0 deletions lib/beacon_api/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ defmodule BeaconApi.Router do
scope "/node" do
get("/health", NodeController, :health)
get("/identity", NodeController, :identity)
get("/version", NodeController, :version)
end
end

Expand Down

0 comments on commit 906a811

Please sign in to comment.