This commit is contained in:
zsfelfoldi 2015-02-12 17:52:46 +01:00
commit 3de34b631d
5 changed files with 15 additions and 4 deletions

View file

@ -209,6 +209,9 @@ func (self *bzzProtocol) handle() error {
return self.protoError(ErrDecode, "->msg %v: %v", msg, err) return self.protoError(ErrDecode, "->msg %v: %v", msg, err)
} }
dpaLogger.Warnf("Request message: %#v", req) dpaLogger.Warnf("Request message: %#v", req)
if req.Key == nil || req.Timeout == nil {
return self.protoError(ErrDecode, "protocol handler: req.Key == nil || req.Timeout == nil")
}
req.peer = peer{bzzProtocol: self} req.peer = peer{bzzProtocol: self}
self.netStore.addRetrieveRequest(&req) self.netStore.addRetrieveRequest(&req)

View file

@ -65,6 +65,7 @@ var (
SHH bool SHH bool
Dial bool Dial bool
PrintVersion bool PrintVersion bool
Peers string
) )
// flags specific to cli client // flags specific to cli client
@ -103,6 +104,7 @@ func Init() {
flag.BoolVar(&SHH, "shh", true, "whisper protocol (on)") flag.BoolVar(&SHH, "shh", true, "whisper protocol (on)")
flag.BoolVar(&Dial, "dial", true, "dial out connections (on)") flag.BoolVar(&Dial, "dial", true, "dial out connections (on)")
flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key") flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key")
flag.StringVar(&Peers, "peers", "", "imports the file given (hex or mnemonic formats)")
flag.StringVar(&SecretFile, "import", "", "imports the file given (hex or mnemonic formats)") 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") flag.StringVar(&ExportDir, "export", "", "exports the session keyring to files in the directory given")
flag.StringVar(&LogFile, "logfile", "", "log file (defaults to standard output)") flag.StringVar(&LogFile, "logfile", "", "log file (defaults to standard output)")

View file

@ -134,7 +134,7 @@ func main() {
utils.StartWebSockets(ethereum) utils.StartWebSockets(ethereum)
} }
utils.StartEthereum(ethereum, UseSeed) utils.StartEthereum(ethereum, UseSeed, Peers)
if StartJsConsole { if StartJsConsole {
InitJsConsole(ethereum) InitJsConsole(ethereum)

View file

@ -120,9 +120,9 @@ func exit(err error) {
os.Exit(status) os.Exit(status)
} }
func StartEthereum(ethereum *eth.Ethereum, UseSeed bool) { func StartEthereum(ethereum *eth.Ethereum, UseSeed bool, Peers string) {
clilogger.Infof("Starting %s", ethereum.ClientIdentity()) clilogger.Infof("Starting %s", ethereum.ClientIdentity())
err := ethereum.Start(UseSeed) err := ethereum.Start(UseSeed, Peers)
if err != nil { if err != nil {
exit(err) exit(err)
} }

View file

@ -233,7 +233,7 @@ func (s *Ethereum) MaxPeers() int {
} }
// Start the ethereum // Start the ethereum
func (s *Ethereum) Start(seed bool) error { func (s *Ethereum) Start(seed bool, p string) error {
err := s.net.Start() err := s.net.Start()
if err != nil { if err != nil {
return err return err
@ -255,6 +255,12 @@ func (s *Ethereum) Start(seed bool) error {
s.blockSub = s.eventMux.Subscribe(core.NewMinedBlockEvent{}) s.blockSub = s.eventMux.Subscribe(core.NewMinedBlockEvent{})
go s.blockBroadcastLoop() go s.blockBroadcastLoop()
if len(p) > 0 {
if err := s.SuggestPeer(p); err != nil {
return err
}
}
// TODO: read peers here // TODO: read peers here
if seed { if seed {
logger.Infof("Connect to seed node %v", seedNodeAddress) logger.Infof("Connect to seed node %v", seedNodeAddress)