add dial bool flag to prevent test nodes from dialing out (maxpeers not enough, cos server dialloop steals first slot for dialing)

This commit is contained in:
zelig 2015-01-05 01:06:34 +00:00
parent 38edc428eb
commit a4c9a99494
4 changed files with 8 additions and 1 deletions

View file

@ -60,6 +60,7 @@ var (
VmType int
ImportChain string
SHH bool
Dial bool
)
// flags specific to cli client
@ -96,6 +97,7 @@ func Init() {
flag.BoolVar(&NonInteractive, "y", false, "non-interactive mode (say yes to confirmations)")
flag.BoolVar(&UseSeed, "seed", true, "seed peers")
flag.BoolVar(&SHH, "shh", true, "whisper protocol (on)")
flag.BoolVar(&Dial, "dial", true, "dial out connections (on)")
flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key")
flag.StringVar(&SecretFile, "import", "", "imports the file given (hex or mnemonic formats)")
flag.StringVar(&ExportDir, "export", "", "exports the session keyring to files in the directory given")

View file

@ -65,6 +65,7 @@ func main() {
PMPGateway: PMPGateway,
KeyRing: KeyRing,
Shh: SHH,
Dial: Dial,
})
if err != nil {

View file

@ -37,6 +37,7 @@ type Config struct {
PMPGateway string
Shh bool
Dial bool
KeyManager *crypto.KeyManager
}
@ -150,6 +151,7 @@ func New(config *Config) (*Ethereum, error) {
Protocols: protocols,
Blacklist: eth.blacklist,
NAT: nat,
NoDial: !config.Dial,
}
if len(config.Port) > 0 {

View file

@ -189,6 +189,7 @@ func (srv *Server) Start() (err error) {
// make all slots available
for i := range srv.peers {
srvlog.Debugf("add slot %v", i)
srv.peerSlots <- i
}
// note: discLoop is not part of WaitGroup
@ -260,6 +261,7 @@ func (srv *Server) listenLoop() {
for {
select {
case slot := <-srv.peerSlots:
srvlog.Debugf("grabbed slot %v for listening", slot)
conn, err := srv.listener.Accept()
if err != nil {
srv.peerSlots <- slot