forked from cerc-io/plugeth
whisper: remove dead code, rename a few constants
This commit is contained in:
parent
6ceb253f74
commit
ee6531c5ff
@ -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 {
|
||||
|
@ -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")
|
||||
}
|
||||
|
@ -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
|
||||
}
|
@ -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])
|
||||
}
|
||||
}
|
||||
}
|
@ -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 {
|
||||
|
@ -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")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user