mirror of https://github.com/status-im/op-geth.git
Peer changes broadcasting and minor miner fix
This commit is contained in:
parent
b15e03acd7
commit
17c825f53a
|
@ -238,6 +238,7 @@ func (s *Ethereum) ConnectToPeer(addr string) error {
|
||||||
s.peers.PushBack(peer)
|
s.peers.PushBack(peer)
|
||||||
|
|
||||||
ethutil.Config.Log.Infof("[SERV] Adding peer (%s) %d / %d\n", addr, s.peers.Len(), s.MaxPeers)
|
ethutil.Config.Log.Infof("[SERV] Adding peer (%s) %d / %d\n", addr, s.peers.Len(), s.MaxPeers)
|
||||||
|
s.reactor.Post("peerList", s.peers)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -149,7 +149,7 @@ func (self *Miner) mineNewBlock() {
|
||||||
// Find a valid nonce
|
// Find a valid nonce
|
||||||
self.block.Nonce = self.pow.Search(self.block, self.powQuitChan)
|
self.block.Nonce = self.pow.Search(self.block, self.powQuitChan)
|
||||||
if self.block.Nonce != nil {
|
if self.block.Nonce != nil {
|
||||||
err := self.ethereum.StateManager().Process(self.block, true)
|
err := self.ethereum.StateManager().Process(self.block, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ethutil.Config.Log.Infoln(err)
|
ethutil.Config.Log.Infoln(err)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -22,26 +22,54 @@ type config struct {
|
||||||
Identifier string
|
Identifier string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const defaultConf = `
|
||||||
|
id = ""
|
||||||
|
port = 30303
|
||||||
|
upnp = true
|
||||||
|
maxpeer = 10
|
||||||
|
rpc = false
|
||||||
|
rpcport = 8080
|
||||||
|
`
|
||||||
|
|
||||||
var Config *config
|
var Config *config
|
||||||
|
|
||||||
|
func ApplicationFolder(base string) string {
|
||||||
|
usr, _ := user.Current()
|
||||||
|
p := path.Join(usr.HomeDir, base)
|
||||||
|
|
||||||
|
if len(base) > 0 {
|
||||||
|
//Check if the logging directory already exists, create it if not
|
||||||
|
_, err := os.Stat(p)
|
||||||
|
if err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
log.Printf("Debug logging directory %s doesn't exist, creating it\n", p)
|
||||||
|
os.Mkdir(p, 0777)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
iniFilePath := path.Join(p, "conf.ini")
|
||||||
|
_, err = os.Stat(iniFilePath)
|
||||||
|
if err != nil && os.IsNotExist(err) {
|
||||||
|
file, err := os.Create(iniFilePath)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
} else {
|
||||||
|
assetPath := path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "ethereal", "assets")
|
||||||
|
file.Write([]byte(defaultConf + "\nasset_path = " + assetPath))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
// Read config
|
// Read config
|
||||||
//
|
//
|
||||||
// Initialize the global Config variable with default settings
|
// Initialize the global Config variable with default settings
|
||||||
func ReadConfig(base string, logTypes LoggerType, id string) *config {
|
func ReadConfig(base string, logTypes LoggerType, id string) *config {
|
||||||
if Config == nil {
|
if Config == nil {
|
||||||
usr, _ := user.Current()
|
path := ApplicationFolder(base)
|
||||||
path := path.Join(usr.HomeDir, base)
|
|
||||||
|
|
||||||
if len(base) > 0 {
|
|
||||||
//Check if the logging directory already exists, create it if not
|
|
||||||
_, err := os.Stat(path)
|
|
||||||
if err != nil {
|
|
||||||
if os.IsNotExist(err) {
|
|
||||||
log.Printf("Debug logging directory %s doesn't exist, creating it\n", path)
|
|
||||||
os.Mkdir(path, 0777)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Config = &config{ExecPath: path, Debug: true, Ver: "0.5.0 RC11"}
|
Config = &config{ExecPath: path, Debug: true, Ver: "0.5.0 RC11"}
|
||||||
Config.Identifier = id
|
Config.Identifier = id
|
||||||
|
|
Loading…
Reference in New Issue