Skip to content
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

Support alternative database backend (SQLite) #6

Merged
merged 3 commits into from
Aug 14, 2023
Merged
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ temp
config.yaml
test-config.yaml
config-*.yaml
log-*
log-*
tmp-*
14 changes: 5 additions & 9 deletions cmd/explorer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func main() {
utils.LogFatal(err, "invalid chain configuration specified, you must specify the slots per epoch, seconds per slot and genesis timestamp in the config file", 0)
}

db.MustInitDB((*types.DatabaseConfig)(&cfg.WriterDatabase), (*types.DatabaseConfig)(&cfg.ReaderDatabase))
db.MustInitDB()
err = db.ApplyEmbeddedDbSchema(-2)
if err != nil {
logger.Fatalf("error initializing db schema: %v", err)
Expand All @@ -56,11 +56,11 @@ func main() {
}

startFrontend()
} else {
utils.WaitForCtrlC()

logger.Println("exiting...")
}

utils.WaitForCtrlC()
logger.Println("exiting...")
db.MustCloseDB()
}

func startFrontend() {
Expand Down Expand Up @@ -121,8 +121,4 @@ func startFrontend() {
logger.WithError(err).Fatal("Error serving frontend")
}
}()

utils.WaitForCtrlC()

logger.Println("exiting...")
}
35 changes: 21 additions & 14 deletions config/default.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,24 @@ indexer:
# number of seconds to wait between each epoch (don't overload CL client)
syncEpochCooldown: 2


readerDatabase:
host: "127.0.0.1"
port: 5432
user: ""
password: ""
name: ""

writerDatabase:
host: "127.0.0.1"
port: 5432
user: ""
password: ""
name: ""
# database configuration
database:
engine: "sqlite" # sqlite / pgsql

# sqlite settings
sqlite:
file: "./explorer-db.sqlite"

# pgsql settings
pgsql:
host: "127.0.0.1"
port: 5432
user: ""
password: ""
name: ""
pgsqlWriter: # optional separate writer connection (used for replication setups)
host: ""
port: 5432
user: ""
password: ""
name: ""
Loading