Skip to content

Commit

Permalink
whisper: minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
gluk256 committed Mar 3, 2018
1 parent 66cd41a commit 95cca85
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions cmd/wnode/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,18 +439,18 @@ func run() {
} else {
sendLoop()
}

close(done)
}

func sendLoop() {
for {
s := scanLine("")
if s == quitCommand {
fmt.Println("Quit command received")
close(done)
break
return
}
sendMsg([]byte(s))

if *asymmetricMode {
// print your own message for convenience,
// because in asymmetric mode it is impossible to decrypt it
Expand All @@ -466,13 +466,11 @@ func sendFilesLoop() {
s := scanLine("")
if s == quitCommand {
fmt.Println("Quit command received")
close(done)
break
return
}
b, err := ioutil.ReadFile(s)
if err != nil {
fmt.Printf(">>> Error: %s \n", err)
continue
} else {
h := sendMsg(b)
if (h == common.Hash{}) {
Expand All @@ -491,15 +489,13 @@ func fileReaderLoop() {
watcher2 := shh.GetFilter(asymFilterID)
if watcher1 == nil && watcher2 == nil {
fmt.Println("Error: neither symmetric nor asymmetric filter is installed")
close(done)
return
}

for {
s := scanLine("")
if s == quitCommand {
fmt.Println("Quit command received")
close(done)
return
}
raw, err := ioutil.ReadFile(s)
Expand Down

0 comments on commit 95cca85

Please sign in to comment.