whisper: input method changed

This commit is contained in:
Vlad 2017-01-04 23:14:29 +01:00
parent 697a50385b
commit 5b682d6485

View file

@ -20,6 +20,7 @@
package main package main
import ( import (
"bufio"
"crypto/ecdsa" "crypto/ecdsa"
"crypto/sha1" "crypto/sha1"
"crypto/sha256" "crypto/sha256"
@ -28,6 +29,7 @@ import (
"fmt" "fmt"
"os" "os"
"strconv" "strconv"
"strings"
"time" "time"
"github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/cmd/utils"
@ -55,6 +57,7 @@ var pow float64 = whisper.MinimumPoW
var ttl uint32 = 30 var ttl uint32 = 30
var workTime uint32 = 5 var workTime uint32 = 5
var ipAddress, enode, salt, topicStr, pubStr, NodeIdFile string var ipAddress, enode, salt, topicStr, pubStr, NodeIdFile string
var input *bufio.Reader = bufio.NewReader(os.Stdin)
var bootstrapNode bool // does not actively connect to peers, wait for incoming connections var bootstrapNode bool // does not actively connect to peers, wait for incoming connections
var daemonMode bool // only forward messages, neither send nor track var daemonMode bool // only forward messages, neither send nor track
@ -417,11 +420,15 @@ func run() {
} }
func scanLine(prompt string) string { func scanLine(prompt string) string {
txt, err := console.Stdin.PromptInput(prompt) if len(prompt) > 0 {
fmt.Print(prompt)
}
//txt, err := console.Stdin.PromptInput(prompt) // todo: delete
txt, err := input.ReadString('\n')
if err != nil { if err != nil {
utils.Fatalf("input error: %s", err) utils.Fatalf("input error: %s", err)
} }
return txt return strings.TrimRight(txt, "\n\r")
} }
func sendMsg(payload []byte) { func sendMsg(payload []byte) {