diff options
author | Guillaume Ballet <gballet@gmail.com> | 2018-02-27 04:23:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-27 04:23:51 +0800 |
commit | 4c845bdc271c46706ea4af248a1efec8683dc53a (patch) | |
tree | b29d502f8be0c5113db4e26126389a56684c5da6 /cmd | |
parent | 61c9730b2de2719059f0fb2ce8f965c0cde34527 (diff) | |
parent | f4e676cccdeaf781a449410482e75267672db61b (diff) | |
download | go-tangerine-4c845bdc271c46706ea4af248a1efec8683dc53a.tar go-tangerine-4c845bdc271c46706ea4af248a1efec8683dc53a.tar.gz go-tangerine-4c845bdc271c46706ea4af248a1efec8683dc53a.tar.bz2 go-tangerine-4c845bdc271c46706ea4af248a1efec8683dc53a.tar.lz go-tangerine-4c845bdc271c46706ea4af248a1efec8683dc53a.tar.xz go-tangerine-4c845bdc271c46706ea4af248a1efec8683dc53a.tar.zst go-tangerine-4c845bdc271c46706ea4af248a1efec8683dc53a.zip |
Merge pull request #16198 from gluk256/266-wnode
whisper: refactor wnode to systematically store messages if a directory is provided
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/wnode/main.go | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/cmd/wnode/main.go b/cmd/wnode/main.go index 971b1c0ab..0f86adb81 100644 --- a/cmd/wnode/main.go +++ b/cmd/wnode/main.go @@ -76,14 +76,14 @@ var ( // cmd arguments var ( - bootstrapMode = flag.Bool("standalone", false, "boostrap node: don't actively connect to peers, wait for incoming connections") - forwarderMode = flag.Bool("forwarder", false, "forwarder mode: only forward messages, neither send nor decrypt messages") + bootstrapMode = flag.Bool("standalone", false, "boostrap node: don't initiate connection to peers, just wait for incoming connections") + forwarderMode = flag.Bool("forwarder", false, "forwarder mode: only forward messages, neither encrypt nor decrypt messages") mailServerMode = flag.Bool("mailserver", false, "mail server mode: delivers expired messages on demand") requestMail = flag.Bool("mailclient", false, "request expired messages from the bootstrap server") asymmetricMode = flag.Bool("asym", false, "use asymmetric encryption") generateKey = flag.Bool("generatekey", false, "generate and show the private key") fileExMode = flag.Bool("fileexchange", false, "file exchange mode") - testMode = flag.Bool("test", false, "use of predefined parameters for diagnostics") + testMode = flag.Bool("test", false, "use of predefined parameters for diagnostics (password, etc.)") echoMode = flag.Bool("echo", false, "echo mode: prints some arguments for diagnostics") argVerbosity = flag.Int("verbosity", int(log.LvlError), "log verbosity level") @@ -99,7 +99,7 @@ var ( argIDFile = flag.String("idfile", "", "file name with node id (private key)") argEnode = flag.String("boot", "", "bootstrap node you want to connect to (e.g. enode://e454......08d50@52.176.211.200:16428)") argTopic = flag.String("topic", "", "topic in hexadecimal format (e.g. 70a4beef)") - argSaveDir = flag.String("savedir", "", "directory where incoming messages will be saved as files") + argSaveDir = flag.String("savedir", "", "directory where all incoming messages will be saved as files") ) func main() { @@ -548,20 +548,18 @@ func messageLoop() { for { select { case <-ticker.C: - messages := sf.Retrieve() + m1 := sf.Retrieve() + m2 := af.Retrieve() + messages := append(m1, m2...) for _, msg := range messages { - if *fileExMode || len(msg.Payload) > 2048 { + // All messages are saved upon specifying argSaveDir. + // fileExMode only specifies how messages are displayed on the console after they are saved. + // if fileExMode == true, only the hashes are displayed, since messages might be too big. + if len(*argSaveDir) > 0 { writeMessageToFile(*argSaveDir, msg) - } else { - printMessageInfo(msg) } - } - messages = af.Retrieve() - for _, msg := range messages { - if *fileExMode || len(msg.Payload) > 2048 { - writeMessageToFile(*argSaveDir, msg) - } else { + if !*fileExMode && len(msg.Payload) <= 2048 { printMessageInfo(msg) } } |