You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
800 B

  1. package config
  2. import (
  3. "github.com/tendermint/tendermint/libs/log"
  4. "github.com/tendermint/tendermint/libs/service"
  5. db "github.com/tendermint/tm-db"
  6. )
  7. // ServiceProvider takes a config and a logger and returns a ready to go Node.
  8. type ServiceProvider func(*Config, log.Logger) (service.Service, error)
  9. // DBContext specifies config information for loading a new DB.
  10. type DBContext struct {
  11. ID string
  12. Config *Config
  13. }
  14. // DBProvider takes a DBContext and returns an instantiated DB.
  15. type DBProvider func(*DBContext) (db.DB, error)
  16. // DefaultDBProvider returns a database using the DBBackend and DBDir
  17. // specified in the Config.
  18. func DefaultDBProvider(ctx *DBContext) (db.DB, error) {
  19. dbType := db.BackendType(ctx.Config.DBBackend)
  20. return db.NewDB(ctx.ID, dbType, ctx.Config.DBDir())
  21. }