Skip to content

Commit

Permalink
Merge pull request #130 from openrelayxyz/bugfix/pragma-pagesize-default
Browse files Browse the repository at this point in the history
Added pragma page size logic to config
  • Loading branch information
AusIV authored May 2, 2024
2 parents 97f2884 + 5cf8290 commit 56b16d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type broker struct {
}

type Config struct {
PageSize int64 `yaml:"pragmaPageSize"`
Port int64 `yaml:"port"`
PprofPort int `yaml:"pprofPort"`
HealthcheckPort int64 `yaml:"healthcheck"`
Expand Down Expand Up @@ -154,6 +155,10 @@ func LoadConfig(fname string) (*Config, error) {

log.Root().SetHandler(log.LvlFilterHandler(logLvl, log.Root().GetHandler()))

if cfg.PageSize < 4096 || cfg.PageSize > 65536 || (cfg.PageSize&(cfg.PageSize-1)) != 0 {
log.Warn(fmt.Sprintf("config: invalid pragma page size of %v, setting to default of 4096", cfg.PageSize))
}

if cfg.Port == 0 {
cfg.Port = 8000
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func main() {
&sqlite3.SQLiteDriver{
ConnectHook: func(conn *sqlite3.SQLiteConn) error {
for name, path := range cfg.Databases {
conn.Exec(fmt.Sprintf("ATTACH DATABASE '%v' AS '%v'; PRAGMA %v.page_size = 65536 ; PRAGMA %v.journal_mode = WAL ; PRAGMA %v.synchronous = OFF ; pragma %v.max_page_count = 4294967294;", path, name, name, name, name, name), nil)
conn.Exec(fmt.Sprintf("ATTACH DATABASE '%v' AS '%v'; PRAGMA %v.page_size = %v ; PRAGMA %v.journal_mode = WAL ; PRAGMA %v.synchronous = OFF ; pragma %v.max_page_count = 4294967294;", path, name, name, cfg.PageSize, name, name, name), nil)
}
return nil
},
Expand Down

0 comments on commit 56b16d8

Please sign in to comment.