本文整理匯總了Golang中github.com/ethereum/go-ethereum/logger/glog.Infoln函數的典型用法代碼示例。如果您正苦於以下問題:Golang Infoln函數的具體用法?Golang Infoln怎麽用?Golang Infoln使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Infoln函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: upgradeDB
func upgradeDB(ctx *cli.Context) {
glog.Infoln("Upgrading blockchain database")
chain, chainDb := utils.MakeChain(ctx)
v, _ := chainDb.Get([]byte("BlockchainVersion"))
bcVersion := int(common.NewValue(v).Uint())
if bcVersion == 0 {
bcVersion = core.BlockChainVersion
}
// Export the current chain.
filename := fmt.Sprintf("blockchain_%d_%s.chain", bcVersion, time.Now().Format("20060102_150405"))
exportFile := filepath.Join(ctx.GlobalString(utils.DataDirFlag.Name), filename)
if err := utils.ExportChain(chain, exportFile); err != nil {
utils.Fatalf("Unable to export chain for reimport %s", err)
}
chainDb.Close()
os.RemoveAll(filepath.Join(ctx.GlobalString(utils.DataDirFlag.Name), "chaindata"))
// Import the chain file.
chain, chainDb = utils.MakeChain(ctx)
chainDb.Put([]byte("BlockchainVersion"), common.NewValue(core.BlockChainVersion).Bytes())
err := utils.ImportChain(chain, exportFile)
chainDb.Close()
if err != nil {
utils.Fatalf("Import error %v (a backup is made in %s, use the import command to import it)", err, exportFile)
} else {
os.Remove(exportFile)
glog.Infoln("Import finished")
}
}
示例2: RunTransactionTestsWithReader
func RunTransactionTestsWithReader(r io.Reader, skipTests []string) error {
skipTest := make(map[string]bool, len(skipTests))
for _, name := range skipTests {
skipTest[name] = true
}
bt := make(map[string]TransactionTest)
if err := readJson(r, &bt); err != nil {
return err
}
for name, test := range bt {
// if the test should be skipped, return
if skipTest[name] {
glog.Infoln("Skipping transaction test", name)
return nil
}
// test the block
if err := runTransactionTest(test); err != nil {
return err
}
glog.Infoln("Transaction test passed: ", name)
}
return nil
}
示例3: getFiles
func getFiles(path string) ([]string, error) {
glog.Infoln("getFiles", path)
var files []string
f, err := os.Open(path)
if err != nil {
return nil, err
}
defer f.Close()
fi, err := f.Stat()
if err != nil {
return nil, err
}
switch mode := fi.Mode(); {
case mode.IsDir():
fi, _ := ioutil.ReadDir(path)
files = make([]string, len(fi))
for i, v := range fi {
// only go 1 depth and leave directory entires blank
if !v.IsDir() && v.Name()[len(v.Name())-len(testExtension):len(v.Name())] == testExtension {
files[i] = filepath.Join(path, v.Name())
glog.Infoln("Found file", files[i])
}
}
case mode.IsRegular():
files = make([]string, 1)
files[0] = path
}
return files, nil
}
示例4: ExportChain
func ExportChain(blockchain *core.BlockChain, fn string) error {
glog.Infoln("Exporting blockchain to", fn)
fh, err := os.OpenFile(fn, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.ModePerm)
if err != nil {
return err
}
defer fh.Close()
if err := blockchain.Export(fh); err != nil {
return err
}
glog.Infoln("Exported blockchain to", fn)
return nil
}
示例5: ExportAppendChain
func ExportAppendChain(blockchain *core.BlockChain, fn string, first uint64, last uint64) error {
glog.Infoln("Exporting blockchain to", fn)
// TODO verify mode perms
fh, err := os.OpenFile(fn, os.O_CREATE|os.O_APPEND|os.O_WRONLY, os.ModePerm)
if err != nil {
return err
}
defer fh.Close()
if err := blockchain.ExportN(fh, first, last); err != nil {
return err
}
glog.Infoln("Exported blockchain to", fn)
return nil
}
示例6: runTestWithReader
func runTestWithReader(test string, r io.Reader) error {
glog.Infoln("runTest", test)
var err error
switch strings.ToLower(test) {
case "bk", "block", "blocktest", "blockchaintest", "blocktests", "blockchaintests":
err = tests.RunBlockTestWithReader(params.MainNetHomesteadBlock, r, skipTests)
case "st", "state", "statetest", "statetests":
rs := tests.RuleSet{HomesteadBlock: params.MainNetHomesteadBlock}
err = tests.RunStateTestWithReader(rs, r, skipTests)
case "tx", "transactiontest", "transactiontests":
err = tests.RunTransactionTestsWithReader(r, skipTests)
case "vm", "vmtest", "vmtests":
err = tests.RunVmTestWithReader(r, skipTests)
case "rlp", "rlptest", "rlptests":
err = tests.RunRLPTestWithReader(r, skipTests)
default:
err = fmt.Errorf("Invalid test type specified: %v", test)
}
if err != nil {
return err
}
return nil
}
示例7: push
func (self *worker) push(work *Work) {
if atomic.LoadInt32(&self.mining) == 1 {
if core.Canary(work.state) {
glog.Infoln("Toxicity levels rising to deadly levels. Your canary has died. You can go back or continue down the mineshaft --more--")
glog.Infoln("You turn back and abort mining")
return
}
// push new work to agents
for agent := range self.agents {
atomic.AddInt32(&self.atWork, 1)
if agent.Work() != nil {
agent.Work() <- work
}
}
}
}
示例8: importTx
func (self *ImportMaster) importTx(tx *types.Transaction, blockId *bson.ObjectId) {
if glog.V(logger.Info) {
glog.Infoln("Importing tx", tx.Hash().Hex())
}
err := self.txCollection.Insert(self.parseTx(tx, blockId))
if err != nil {
clilogger.Infoln(err)
}
}
示例9: runSuite
func runSuite(test, file string) {
var tests []string
if test == defaultTest {
tests = allTests
} else {
tests = []string{test}
}
for _, curTest := range tests {
glog.Infoln("runSuite", curTest, file)
var err error
var files []string
if test == defaultTest {
// check if we have an explicit directory mapping for the test
if _, ok := testDirMapping[curTest]; ok {
files, err = getFiles(filepath.Join(file, testDirMapping[curTest]))
} else {
// otherwise assume test name
files, err = getFiles(filepath.Join(file, curTest))
}
} else {
files, err = getFiles(file)
}
if err != nil {
glog.Fatalln(err)
}
if len(files) == 0 {
glog.Warningln("No files matched path")
}
for _, curFile := range files {
// Skip blank entries
if len(curFile) == 0 {
continue
}
r, err := os.Open(curFile)
if err != nil {
glog.Fatalln(err)
}
defer r.Close()
err = runTestWithReader(curTest, r)
if err != nil {
if continueOnError {
glog.Errorln(err)
} else {
glog.Fatalln(err)
}
}
}
}
}
示例10: runBlockTests
func runBlockTests(homesteadBlock, daoForkBlock *big.Int, bt map[string]*BlockTest, skipTests []string) error {
skipTest := make(map[string]bool, len(skipTests))
for _, name := range skipTests {
skipTest[name] = true
}
for name, test := range bt {
if skipTest[name] {
glog.Infoln("Skipping block test", name)
continue
}
// test the block
if err := runBlockTest(homesteadBlock, daoForkBlock, test); err != nil {
return fmt.Errorf("%s: %v", name, err)
}
glog.Infoln("Block test passed: ", name)
}
return nil
}
示例11: push
func (self *worker) push() {
if atomic.LoadInt32(&self.mining) == 1 {
if core.Canary(self.current.state) {
glog.Infoln("Toxicity levels rising to deadly levels. Your canary has died. You can go back or continue down the mineshaft --more--")
glog.Infoln("You turn back and abort mining")
return
}
// push new work to agents
for _, agent := range self.agents {
atomic.AddInt32(&self.atWork, 1)
if agent.Work() != nil {
agent.Work() <- self.current.block
} else {
common.Report(fmt.Sprintf("%v %T\n", agent, agent))
}
}
}
}
示例12: runVmTests
func runVmTests(tests map[string]VmTest, skipTests []string) error {
skipTest := make(map[string]bool, len(skipTests))
for _, name := range skipTests {
skipTest[name] = true
}
for name, test := range tests {
if skipTest[name] {
glog.Infoln("Skipping VM test", name)
return nil
}
if err := runVmTest(test); err != nil {
return fmt.Errorf("%s %s", name, err.Error())
}
glog.Infoln("VM test passed: ", name)
//fmt.Println(string(statedb.Dump()))
}
return nil
}
示例13: runTransactionTests
func runTransactionTests(tests map[string]TransactionTest, skipTests []string) error {
skipTest := make(map[string]bool, len(skipTests))
for _, name := range skipTests {
skipTest[name] = true
}
for name, test := range tests {
// if the test should be skipped, return
if skipTest[name] {
glog.Infoln("Skipping transaction test", name)
return nil
}
// test the block
if err := runTransactionTest(test); err != nil {
return err
}
glog.Infoln("Transaction test passed: ", name)
}
return nil
}
示例14: runBlockTests
func runBlockTests(bt map[string]*BlockTest, skipTests []string) error {
skipTest := make(map[string]bool, len(skipTests))
for _, name := range skipTests {
skipTest[name] = true
}
for name, test := range bt {
// if the test should be skipped, return
if skipTest[name] {
glog.Infoln("Skipping block test", name)
continue
}
// test the block
if err := runBlockTest(test); err != nil {
return fmt.Errorf("%s: %v", name, err)
}
glog.Infoln("Block test passed: ", name)
}
return nil
}
示例15: runSuite
func runSuite(test, file string) {
var tests []string
if test == defaultTest {
tests = allTests
} else {
tests = []string{test}
}
for _, curTest := range tests {
glog.Infoln("runSuite", curTest, file)
var err error
var files []string
if test == defaultTest {
files, err = getFiles(filepath.Join(file, curTest))
} else {
files, err = getFiles(file)
}
if err != nil {
glog.Fatalln(err)
}
if len(files) == 0 {
glog.Warningln("No files matched path")
}
for _, curFile := range files {
// Skip blank entries
if len(curFile) == 0 {
continue
}
r, err := os.Open(curFile)
if err != nil {
glog.Fatalln(err)
}
defer r.Close()
err = runTestWithReader(curTest, r)
if err != nil {
if continueOnError {
glog.Errorln(err)
} else {
glog.Fatalln(err)
}
}
}
}
}