本文整理匯總了Golang中github.com/FactomProject/factomd/state.State.InitBoltDB方法的典型用法代碼示例。如果您正苦於以下問題:Golang State.InitBoltDB方法的具體用法?Golang State.InitBoltDB怎麽用?Golang State.InitBoltDB使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/FactomProject/factomd/state.State
的用法示例。
在下文中一共展示了State.InitBoltDB方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
fmt.Println("Usage:")
fmt.Println("ReceiptGenerator level/bolt [EntryID-To-Extract]")
fmt.Println("Leave out the last one to export all entries")
if len(os.Args) < 1 {
fmt.Println("\nNot enough arguments passed")
os.Exit(1)
}
if len(os.Args) > 2 {
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)
}
entryID := ""
if len(os.Args) == 3 {
entryID = os.Args[2]
}
state := new(state.State)
state.Cfg = util.ReadConfig("")
if levelBolt == level {
err := state.InitLevelDB()
if err != nil {
panic(err)
}
}
if levelBolt == bolt {
err := state.InitBoltDB()
if err != nil {
panic(err)
}
}
dbo := state.GetAndLockDB()
defer state.UnlockDB()
if entryID != "" {
err := ExportEntryReceipt(entryID, dbo)
if err != nil {
panic(err)
}
} else {
err := ExportAllEntryReceipts(dbo)
if err != nil {
panic(err)
}
}
}
示例2: main
func main() {
fmt.Println("Usage:")
fmt.Println("BlockExtractor level/bolt [ChainID-To-Extract]")
fmt.Println("Leave out the last one to export basic chains (A, D, EC, F)")
if len(os.Args) < 1 {
fmt.Println("\nNot enough arguments passed")
os.Exit(1)
}
if len(os.Args) > 2 {
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)
}
chainID := ""
if len(os.Args) == 3 {
chainID = os.Args[2]
}
state := new(state.State)
state.Cfg = util.ReadConfig("")
if levelBolt == level {
err := state.InitLevelDB()
if err != nil {
panic(err)
}
}
if levelBolt == bolt {
err := state.InitBoltDB()
if err != nil {
panic(err)
}
}
dbo := state.GetDB()
if chainID != "" {
err := ExportEChain(chainID, dbo)
if err != nil {
panic(err)
}
} else {
err := ExportDChain(dbo)
if err != nil {
panic(err)
}
err = ExportECChain(dbo)
if err != nil {
panic(err)
}
err = ExportAChain(dbo)
if err != nil {
panic(err)
}
err = ExportFctChain(dbo)
if err != nil {
panic(err)
}
err = ExportDirBlockInfo(dbo)
if err != nil {
panic(err)
}
}
}