func NewDB(cfg config.Cfg, logger log.Logger) *dbService {
	return &dbService{
		database: pg.Connect(&pg.Options{
			Addr:     cfg.DB.Address,
			User:     cfg.DB.User,
			Password: cfg.DB.Password,
			Database: cfg.DB.Database,
		}),
		logger: logger,
		dbChan: make(chan dbWork, 512),
	}
}
NewDB create a connection commit event to db
package dbHistory
import (
	"sync"
	"github.com/KuChainNetwork/kuchain/plugins/db_history/chaindb"
	"github.com/KuChainNetwork/kuchain/plugins/db_history/config"
	"github.com/go-pg/pg/v10"
	"github.com/tendermint/tendermint/libs/log"
)
type dbWork struct {
	msg interface{}
}
func (w dbWork) IsStopped() bool {
	return w.msg == nil
}
type dbService struct {
	logger   log.Logger
	database *pg.DB
	dbChan chan dbWork
	wg     sync.WaitGroup
}