diff options
author | obscuren <geffobscura@gmail.com> | 2014-12-15 19:01:55 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-12-15 19:01:55 +0800 |
commit | afc8b887abfbfeaec5040a39f0f20d3071902abe (patch) | |
tree | f8f6566590cc306ff8498a270bd5bcdfc650f7c0 /whisper/whisper.go | |
parent | f111fc060884d69fbe46066b9ccae4c9aa5da890 (diff) | |
download | dexon-afc8b887abfbfeaec5040a39f0f20d3071902abe.tar dexon-afc8b887abfbfeaec5040a39f0f20d3071902abe.tar.gz dexon-afc8b887abfbfeaec5040a39f0f20d3071902abe.tar.bz2 dexon-afc8b887abfbfeaec5040a39f0f20d3071902abe.tar.lz dexon-afc8b887abfbfeaec5040a39f0f20d3071902abe.tar.xz dexon-afc8b887abfbfeaec5040a39f0f20d3071902abe.tar.zst dexon-afc8b887abfbfeaec5040a39f0f20d3071902abe.zip |
added whisper
Diffstat (limited to 'whisper/whisper.go')
-rw-r--r-- | whisper/whisper.go | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/whisper/whisper.go b/whisper/whisper.go index 356debd1c..1b3f54b67 100644 --- a/whisper/whisper.go +++ b/whisper/whisper.go @@ -4,12 +4,12 @@ import ( "bytes" "crypto/ecdsa" "errors" - "fmt" "sync" "time" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/event/filter" + "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/p2p" "gopkg.in/fatih/set.v0" ) @@ -47,6 +47,8 @@ type MessageEvent struct { const DefaultTtl = 50 * time.Second +var wlogger = logger.NewLogger("SHH") + type Whisper struct { protocol p2p.Protocol filters *filter.Filters @@ -68,16 +70,15 @@ func New() *Whisper { quit: make(chan struct{}), } whisper.filters.Start() - go whisper.update() // XXX TODO REMOVE TESTING CODE - msg := NewMessage([]byte(fmt.Sprintf("Hello world. This is whisper-go. Incase you're wondering; the time is %v", time.Now()))) - envelope, _ := msg.Seal(DefaultPow, Opts{ - Ttl: DefaultTtl, - }) - if err := whisper.Send(envelope); err != nil { - fmt.Println(err) - } + //msg := NewMessage([]byte(fmt.Sprintf("Hello world. This is whisper-go. Incase you're wondering; the time is %v", time.Now()))) + //envelope, _ := msg.Seal(DefaultPow, Opts{ + // Ttl: DefaultTtl, + //}) + //if err := whisper.Send(envelope); err != nil { + // fmt.Println(err) + //} // XXX TODO REMOVE TESTING CODE // p2p whisper sub protocol handler @@ -91,6 +92,11 @@ func New() *Whisper { return whisper } +func (self *Whisper) Start() { + wlogger.Infoln("Whisper started") + go self.update() +} + func (self *Whisper) Stop() { close(self.quit) } @@ -236,7 +242,7 @@ func (self *Whisper) postEvent(envelope *Envelope) { Str1: string(crypto.FromECDSA(key)), Str2: string(crypto.FromECDSAPub(message.Recover())), }, message) } else { - fmt.Println(err) + wlogger.Infoln(err) } } } |