diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-11-27 17:41:22 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-11-27 17:41:22 +0800 |
commit | 7dde2b902cf81e90b484b1a48f6d45e0abd10e0f (patch) | |
tree | 9b92cb3e42269697e0a2b553ba31c36aef73cc25 /whisper | |
parent | ffe58bf5abe5100b29ac1091c882f586cd3a2ef9 (diff) | |
parent | 3e1000fda3424d880bc43ebbb16d8a33447d4182 (diff) | |
download | go-tangerine-7dde2b902cf81e90b484b1a48f6d45e0abd10e0f.tar go-tangerine-7dde2b902cf81e90b484b1a48f6d45e0abd10e0f.tar.gz go-tangerine-7dde2b902cf81e90b484b1a48f6d45e0abd10e0f.tar.bz2 go-tangerine-7dde2b902cf81e90b484b1a48f6d45e0abd10e0f.tar.lz go-tangerine-7dde2b902cf81e90b484b1a48f6d45e0abd10e0f.tar.xz go-tangerine-7dde2b902cf81e90b484b1a48f6d45e0abd10e0f.tar.zst go-tangerine-7dde2b902cf81e90b484b1a48f6d45e0abd10e0f.zip |
Merge pull request #1970 from karalabe/customizable-protocol-stacks
Customizable protocol stacks
Diffstat (limited to 'whisper')
-rw-r--r-- | whisper/peer_test.go | 2 | ||||
-rw-r--r-- | whisper/whisper.go | 16 | ||||
-rw-r--r-- | whisper/whisper_test.go | 2 |
3 files changed, 13 insertions, 7 deletions
diff --git a/whisper/peer_test.go b/whisper/peer_test.go index b3d2031c1..636bd8ca1 100644 --- a/whisper/peer_test.go +++ b/whisper/peer_test.go @@ -37,7 +37,7 @@ func startTestPeer() *testPeer { // Create a whisper client and connect with it to the tester peer client := New() - client.Start() + client.Start(nil) termed := make(chan struct{}) go func() { diff --git a/whisper/whisper.go b/whisper/whisper.go index a341f23e4..7201062b8 100644 --- a/whisper/whisper.go +++ b/whisper/whisper.go @@ -98,9 +98,9 @@ func New() *Whisper { return whisper } -// Protocol returns the whisper sub-protocol handler for this particular client. -func (self *Whisper) Protocol() p2p.Protocol { - return self.protocol +// Protocols returns the whisper sub-protocols ran by this particular client. +func (self *Whisper) Protocols() []p2p.Protocol { + return []p2p.Protocol{self.protocol} } // Version returns the whisper sub-protocols version number. @@ -156,14 +156,20 @@ func (self *Whisper) Send(envelope *Envelope) error { return self.add(envelope) } -func (self *Whisper) Start() { +// Start implements node.Service, starting the background data propagation thread +// of the Whisper protocol. +func (self *Whisper) Start(*p2p.Server) error { glog.V(logger.Info).Infoln("Whisper started") go self.update() + return nil } -func (self *Whisper) Stop() { +// Stop implements node.Service, stopping the background data propagation thread +// of the Whisper protocol. +func (self *Whisper) Stop() error { close(self.quit) glog.V(logger.Info).Infoln("Whisper stopped") + return nil } // Messages retrieves all the currently pooled messages matching a filter id. diff --git a/whisper/whisper_test.go b/whisper/whisper_test.go index b83ce0fe7..9cc235e7a 100644 --- a/whisper/whisper_test.go +++ b/whisper/whisper_test.go @@ -33,7 +33,7 @@ func startTestCluster(n int) []*Whisper { whispers := make([]*Whisper, n) for i := 0; i < n; i++ { whispers[i] = New() - whispers[i].Start() + whispers[i].Start(nil) } // Wire all the peers to the root one for i := 1; i < n; i++ { |