add documentation. fix formatting

This commit is contained in:
Jared Wasinger 2018-04-09 06:57:37 +00:00
parent 04367fc5ea
commit ac39a0ccb1
2 changed files with 5 additions and 7 deletions

View file

@ -759,7 +759,7 @@ func (self *Pss) forward(msg *PssMsg) {
// SECTION: Caching // SECTION: Caching
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
// remove expired entries from forward cache // cleanFwdCache is used to periodically remove expired entries from the forward cache
func (self *Pss) cleanFwdCache() { func (self *Pss) cleanFwdCache() {
self.fwdCacheMu.Lock() self.fwdCacheMu.Lock()
defer self.fwdCacheMu.Unlock() defer self.fwdCacheMu.Unlock()

View file

@ -144,11 +144,10 @@ func TestCache(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
ps := newTestPss(privkey, nil, nil) ps := newTestPss(privkey, nil, nil)
pp := NewPssParams(privkey) pp := NewPssParams(privkey)
data := []byte("foo") data := []byte("foo")
datatwo := []byte("bar") datatwo := []byte("bar")
datathree := []byte("baz") datathree := []byte("baz")
wparams := &whisper.MessageParams{ wparams := &whisper.MessageParams{
TTL: defaultWhisperTTL, TTL: defaultWhisperTTL,
Src: privkey, Src: privkey,
@ -192,7 +191,6 @@ func TestCache(t *testing.T) {
t.Fatalf("could not store cache msgthree: %v", err) t.Fatalf("could not store cache msgthree: %v", err)
} }
if digest == digesttwo { if digest == digesttwo {
t.Fatalf("different msgs return same hash: %d", digesttwo) t.Fatalf("different msgs return same hash: %d", digesttwo)
} }
@ -212,7 +210,7 @@ func TestCache(t *testing.T) {
} }
time.Sleep(pp.CacheTTL + 1*time.Second) time.Sleep(pp.CacheTTL + 1*time.Second)
err = ps.addFwdCache(msgthree) err = ps.addFwdCache(msgthree)
if err != nil { if err != nil {
t.Fatalf("write to pss expire cache failed: %v", err) t.Fatalf("write to pss expire cache failed: %v", err)
} }
@ -221,9 +219,9 @@ func TestCache(t *testing.T) {
t.Fatalf("message %v should have expired from cache but checkCache returned true", msg) t.Fatalf("message %v should have expired from cache but checkCache returned true", msg)
} }
if _, ok := ps.fwdCache[digestthree]; !ok { if _, ok := ps.fwdCache[digestthree]; !ok {
t.Fatalf("unexpired message should be in the cache: %v", digestthree) t.Fatalf("unexpired message should be in the cache: %v", digestthree)
} }
if _, ok := ps.fwdCache[digesttwo]; ok { if _, ok := ps.fwdCache[digesttwo]; ok {
t.Fatalf("expired message should have been cleared from the cache: %v", digesttwo) t.Fatalf("expired message should have been cleared from the cache: %v", digesttwo)