Beispiel #1
0
func main() {
	fmt.Println("Usage:")
	fmt.Println("DBCleanCopy level/bolt DBFileLocation")
	fmt.Println("Database will be copied over block by block to remove some DB inconsistencies")

	if len(os.Args) < 3 {
		fmt.Println("\nNot enough arguments passed")
		os.Exit(1)
	}
	if len(os.Args) > 3 {
		fmt.Println("\nToo many arguments passed")
		os.Exit(1)
	}

	levelBolt := os.Args[1]

	if levelBolt != level && levelBolt != bolt {
		fmt.Println("\nFirst argument should be `level` or `bolt`")
		os.Exit(1)
	}
	path := os.Args[2]

	var dbase1 *hybridDB.HybridDB
	var dbase2 *hybridDB.HybridDB

	var err error
	if levelBolt == bolt {
		dbase1 = hybridDB.NewBoltMapHybridDB(nil, path)
		dbase2 = hybridDB.NewBoltMapHybridDB(nil, "copied.db")
	} else {
		dbase1, err = hybridDB.NewLevelMapHybridDB(path, false)
		if err != nil {
			panic(err)
		}
		dbase2, err = hybridDB.NewLevelMapHybridDB("copied.db", true)
		if err != nil {
			panic(err)
		}
	}

	dbo1 := databaseOverlay.NewOverlay(dbase1)
	dbo2 := databaseOverlay.NewOverlay(dbase2)

	CopyDB(dbo1, dbo2)

	dbo1.Close()
	dbo2.Close()
}
func main() {
	fmt.Println("Usage:")
	fmt.Println("DatabaseIntegrityCheck level/bolt DBFileLocation")
	fmt.Println("Database will be analysed for integrity errors")

	if len(os.Args) < 3 {
		fmt.Println("\nNot enough arguments passed")
		os.Exit(1)
	}
	if len(os.Args) > 3 {
		fmt.Println("\nToo many arguments passed")
		os.Exit(1)
	}

	levelBolt := os.Args[1]

	if levelBolt != level && levelBolt != bolt {
		fmt.Println("\nFirst argument should be `level` or `bolt`")
		os.Exit(1)
	}
	path := os.Args[2]

	var dbase *hybridDB.HybridDB
	var err error
	if levelBolt == bolt {
		dbase = hybridDB.NewBoltMapHybridDB(nil, path)
	} else {
		dbase, err = hybridDB.NewLevelMapHybridDB(path, false)
		if err != nil {
			panic(err)
		}
	}

	CheckDatabase(dbase)
}
Beispiel #3
0
func InitBolt(cfg *util.FactomdConfig) interfaces.DBOverlay {
	//fmt.Println("InitBolt")
	path := cfg.App.BoltDBPath + "/"

	os.MkdirAll(path, 0777)
	dbase := hybridDB.NewBoltMapHybridDB(nil, path+"FactomBolt-Import.db")
	return databaseOverlay.NewOverlay(dbase)
}
Beispiel #4
0
func (s *State) InitBoltDB() error {
	if s.DB != nil {
		return nil
	}

	cfg := s.Cfg.(*util.FactomdConfig)
	path := cfg.App.BoltDBPath + "/" + cfg.App.Network + "/"
	os.MkdirAll(path, 0777)
	dbase := hybridDB.NewBoltMapHybridDB(nil, path+"FactomBolt.db")
	s.DB = databaseOverlay.NewOverlay(dbase)
	return nil
}
func main() {
	fmt.Println("Usage:")
	fmt.Println("BlockExtractor level/bolt DBFileLocation")
	fmt.Println("Database will be dumped into a json-formatted text file")

	if len(os.Args) < 3 {
		fmt.Println("\nNot enough arguments passed")
		os.Exit(1)
	}
	if len(os.Args) > 3 {
		fmt.Println("\nToo many arguments passed")
		os.Exit(1)
	}

	levelBolt := os.Args[1]

	if levelBolt != level && levelBolt != bolt {
		fmt.Println("\nFirst argument should be `level` or `bolt`")
		os.Exit(1)
	}
	path := os.Args[2]

	var dbase *hybridDB.HybridDB
	var err error
	if levelBolt == bolt {
		dbase = hybridDB.NewBoltMapHybridDB(nil, path)
	} else {
		dbase, err = hybridDB.NewLevelMapHybridDB(path, false)
		if err != nil {
			panic(err)
		}
	}

	err = ExportDatabaseJSON(dbase, true)
	if err != nil {
		panic(err)
	}
}