Skip to content

Commit

Permalink
Merge pull request #6 from pk910/sqlite
Browse files Browse the repository at this point in the history
Support alternative database backend (SQLite)
  • Loading branch information
pk910 authored Aug 14, 2023
2 parents d82671c + 17116b4 commit e89498b
Show file tree
Hide file tree
Showing 14 changed files with 453 additions and 150 deletions.
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

0 comments on commit e89498b

Please sign in to comment.