示例#1
0
// Configure the pex.PeerList and load local data
func (self *Peers) Init() {
	peers := pex.NewPex(self.Config.Max)
	err := peers.Load(self.Config.DataDirectory)
	if err != nil {
		logger.Notice("Failed to load peer database")
		logger.Notice("Reason: %v", err)
	}
	logger.Debug("Init peers")
	peers.AllowLocalhost = self.Config.AllowLocalhost

	//Boot strap peers
	for _, addr := range BootStrapPeers {
		peers.AddPeer(addr)
	}

	self.Peers = peers
}
示例#2
0
文件: peers.go 项目: skycoin/skycoin
// Init configures the pex.PeerList and load local data
func (self *Peers) Init() {
	peers := pex.NewPex(self.Config.Max)
	err := peers.Load(self.Config.DataDirectory)
	if err != nil {
		if !os.IsNotExist(err) {
			logger.Notice("Failed to load peer database")
			logger.Notice("Reason: %v", err)
		}
	}
	logger.Debug("Init peers")
	peers.AllowLocalhost = self.Config.AllowLocalhost

	//Boot strap peers
	for _, addr := range DefaultConnections {
		peers.AddPeer(addr)
	}

	self.Peers = peers
	self.Peers.Save(self.Config.DataDirectory)
}