Exemple #1
0
func (sw *swdl) doSaveBlock() {
	defer sw.wg.Done()
	for bm := range sw.chblock {
		saveBlock(bm.Message, bm.I, false)
	}
	log.Infoln("doSaveBlock exit")
}
Exemple #2
0
func (sw *swdl) doDownload() {
	running := true
	for running {
		select {
		case req := <-sw.chout:
			if req != nil {
				sw.chin <- download(req)
			} else {
				time.Sleep(30 * time.Second)
				sw.chin <- nil
			}
		case <-sw.done:
			running = false
		}
	}
	log.Infoln("doDownload exit")
}
Exemple #3
0
func blocksCatchUp() {
	total := cold.Get().Headers().Len()
	db := cold.Get().OutputDB()
	for {
		tag, err := db.Tag()
		if err != nil {
			log.Panicf("Error reading OutputDB tag: %s", err)
		}
		begin := int(tag) + 1
		if begin >= total {
			break
		}
		end, paral, load := swdlParam(begin, total)
		dl := newSwdl(begin, end, paral, load)
		dl.start()
	}
	log.Infoln("Block downloading done.")
}
Exemple #4
0
func init() {
	err := readConfig()
	if err != nil {
		log.Panicln("Failed to read config file: ", err)
	}

	path := filepath.Join(ConfigFileDir(), cfg.LogFileName)
	klog.Init(path)

	runtime.GOMAXPROCS(runtime.NumCPU())
	rand.Seed(time.Now().UTC().UnixNano())

	// Print working directory
	wd, err := os.Getwd()
	if err == nil {
		klog.Infoln("Working directory:", wd)
	} else {
		klog.Panicln("Failed to print working directory:", err)
	}
}