diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-04-16 16:20:01 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-04-16 16:20:01 +0800 |
commit | ee6531c5ff712307325e8866b73397179f4bb8cd (patch) | |
tree | 5a3d44c18fbf4eb1955d866ba4742aa8cc535d58 /whisper | |
parent | 6ceb253f743ec0d2bdd9a676c7f365de2201470c (diff) | |
download | go-tangerine-ee6531c5ff712307325e8866b73397179f4bb8cd.tar go-tangerine-ee6531c5ff712307325e8866b73397179f4bb8cd.tar.gz go-tangerine-ee6531c5ff712307325e8866b73397179f4bb8cd.tar.bz2 go-tangerine-ee6531c5ff712307325e8866b73397179f4bb8cd.tar.lz go-tangerine-ee6531c5ff712307325e8866b73397179f4bb8cd.tar.xz go-tangerine-ee6531c5ff712307325e8866b73397179f4bb8cd.tar.zst go-tangerine-ee6531c5ff712307325e8866b73397179f4bb8cd.zip |
whisper: remove dead code, rename a few constants
Diffstat (limited to 'whisper')
-rw-r--r-- | whisper/peer.go | 4 | ||||
-rw-r--r-- | whisper/peer_test.go | 2 | ||||
-rw-r--r-- | whisper/sort.go | 29 | ||||
-rw-r--r-- | whisper/sort_test.go | 23 | ||||
-rw-r--r-- | whisper/whisper.go | 6 | ||||
-rw-r--r-- | whisper/whisper_test.go | 2 |
6 files changed, 7 insertions, 59 deletions
diff --git a/whisper/peer.go b/whisper/peer.go index 8bf848855..e4301f37c 100644 --- a/whisper/peer.go +++ b/whisper/peer.go @@ -88,8 +88,8 @@ func (self *peer) handshake() error { // and expiration. func (self *peer) update() { // Start the tickers for the updates - expire := time.NewTicker(expirationTicks) - transmit := time.NewTicker(transmissionTicks) + expire := time.NewTicker(expirationCycle) + transmit := time.NewTicker(transmissionCycle) // Loop and transmit until termination is requested for { diff --git a/whisper/peer_test.go b/whisper/peer_test.go index 53aff7c55..de67b2463 100644 --- a/whisper/peer_test.go +++ b/whisper/peer_test.go @@ -185,7 +185,7 @@ func TestPeerDeliver(t *testing.T) { t.Fatalf("failed to transfer message: %v", err) } select { - case <-time.After(2 * transmissionTicks): + case <-time.After(2 * transmissionCycle): case <-arrived: t.Fatalf("repeating message arrived") } diff --git a/whisper/sort.go b/whisper/sort.go deleted file mode 100644 index 313ba5ac0..000000000 --- a/whisper/sort.go +++ /dev/null @@ -1,29 +0,0 @@ -package whisper - -import ( - "sort" - - "github.com/ethereum/go-ethereum/common" -) - -type sortedKeys struct { - k []int32 -} - -func (self *sortedKeys) Len() int { return len(self.k) } -func (self *sortedKeys) Less(i, j int) bool { return self.k[i] < self.k[j] } -func (self *sortedKeys) Swap(i, j int) { self.k[i], self.k[j] = self.k[j], self.k[i] } - -func sortKeys(m map[int32]common.Hash) []int32 { - sorted := new(sortedKeys) - sorted.k = make([]int32, len(m)) - i := 0 - for key, _ := range m { - sorted.k[i] = key - i++ - } - - sort.Sort(sorted) - - return sorted.k -} diff --git a/whisper/sort_test.go b/whisper/sort_test.go deleted file mode 100644 index a61fde4c2..000000000 --- a/whisper/sort_test.go +++ /dev/null @@ -1,23 +0,0 @@ -package whisper - -import ( - "testing" - - "github.com/ethereum/go-ethereum/common" -) - -func TestSorting(t *testing.T) { - m := map[int32]common.Hash{ - 1: {1}, - 3: {3}, - 2: {2}, - 5: {5}, - } - exp := []int32{1, 2, 3, 5} - res := sortKeys(m) - for i, k := range res { - if k != exp[i] { - t.Error(k, "failed. Expected", exp[i]) - } - } -} diff --git a/whisper/whisper.go b/whisper/whisper.go index b83e3f1c6..f04075e1f 100644 --- a/whisper/whisper.go +++ b/whisper/whisper.go @@ -25,8 +25,8 @@ const ( signatureFlag = byte(1 << 7) signatureLength = 65 - expirationTicks = 800 * time.Millisecond - transmissionTicks = 300 * time.Millisecond + expirationCycle = 800 * time.Millisecond + transmissionCycle = 300 * time.Millisecond ) const ( @@ -275,7 +275,7 @@ func createFilter(message *Message, topics []Topic) filter.Filter { // state by expiring stale messages from the pool. func (self *Whisper) update() { // Start a ticker to check for expirations - expire := time.NewTicker(expirationTicks) + expire := time.NewTicker(expirationCycle) // Repeat updates until termination is requested for { diff --git a/whisper/whisper_test.go b/whisper/whisper_test.go index 554a12cb1..def8e68d8 100644 --- a/whisper/whisper_test.go +++ b/whisper/whisper_test.go @@ -178,7 +178,7 @@ func TestMessageExpiration(t *testing.T) { } // Wait for expiration and check cache again time.Sleep(time.Second) // wait for expiration - time.Sleep(expirationTicks) // wait for cleanup cycle + time.Sleep(expirationCycle) // wait for cleanup cycle if _, ok := node.messages[envelope.Hash()]; ok { t.Fatalf("message not expired from cache") } |