Beispiel #1
0
// Initialize the level db and share it with other components
func initDB() {

	//init factoid_bolt db
	fmt.Println("boltDBpath:", boltDBpath)
	common.FactoidState = stateinit.NewFactoidState(boltDBpath + "factoid_bolt.db")

	//init db
	var err error
	db, err = ldb.OpenLevelDB(ldbpath, false)

	if err != nil {
		ftmdLog.Errorf("err opening db: %v\n", err)

	}

	if db == nil {
		ftmdLog.Info("Creating new db ...")
		db, err = ldb.OpenLevelDB(ldbpath, true)

		if err != nil {
			panic(err)
		}
	}
	ftmdLog.Info("Database started from: " + ldbpath)

}
Beispiel #2
0
func initDB(ldbpath string) {
	var err error
	db, err = ldb.OpenLevelDB(ldbpath, false)
	if err != nil {
		fmt.Errorf("err opening db: %v\n", err)
	}

	if db == nil {
		fmt.Println("Creating new db ...")
		db, err = ldb.OpenLevelDB(ldbpath, true)
		if err != nil {
			panic(err)
		}
	}
	fmt.Println("Database started from: " + ldbpath)
}