From b55cc1989c52679389f408f2f9c3e83b1eb10f2f Mon Sep 17 00:00:00 2001 From: nabarun Date: Mon, 9 May 2022 13:01:34 +0530 Subject: [PATCH] Update readme to run server --- .gitignore | 1 + Makefile | 4 ++++ README.md | 24 ++++++++++++++++++++++++ cmd/root.go | 5 +++++ 4 files changed, 34 insertions(+) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 4469811..229a9a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea/ leveldb-ethdb-rpc +environments/config.toml \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7365f72 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +# Build +build: + go fmt ./... + go build \ No newline at end of file diff --git a/README.md b/README.md index 0cf1239..e6a4874 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,26 @@ # leveldb-ethdb-rpc Thin RPC wrapper around LevelDB to expose data remotely + +## Setup + +Run the following + +```bash +make build +``` + +Create a `config.toml` file from [example.toml](./environments/example.toml) file. + +Update the config for path to geth leveldb and geth ancient database + +```toml +[leveldb] + path = "/path/to/eth/data/geth/chaindata" # $LEVELDB_PATH + ancient = "/path/to/eth/data/geth/chaindata/ancient" # $LEVELDB_ANCIENT_PATH +``` + +## Usage + +After building the binary, run as + +`./leveldb-ethdb-rpc serve --config ./environments/config.toml` diff --git a/cmd/root.go b/cmd/root.go index 02b3359..59d818e 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -79,6 +79,11 @@ func logLevel() error { return nil } +func init() { + cobra.OnInitialize(initConfig) + rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file location") +} + // initConfig reads in config file and ENV variables if set. func initConfig() { if cfgFile != "" {