review changes

This commit is contained in:
gammazero 2022-02-09 10:29:49 -08:00
parent b2805823ce
commit a62e027002
3 changed files with 6 additions and 7 deletions

View File

@ -6,7 +6,6 @@ import (
"time"
address "github.com/filecoin-project/go-address"
//"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain"
"github.com/filecoin-project/lotus/chain/consensus"
@ -465,7 +464,7 @@ type IndexerMessageValidator struct {
}
func NewIndexerMessageValidator(self peer.ID, chainApi full.ChainModuleAPI, stateApi full.StateModuleAPI) *IndexerMessageValidator {
peerCache, _ := lru.New2Q(1024)
peerCache, _ := lru.New2Q(8192)
return &IndexerMessageValidator{
self: self,
@ -498,7 +497,7 @@ func (v *IndexerMessageValidator) Validate(ctx context.Context, pid peer.ID, msg
}
if minerID == "" {
log.Warnw("ignoring messsage missing miner id", "peer", originPeer)
log.Debugw("ignoring messsage missing miner id", "peer", originPeer)
return pubsub.ValidationIgnore
}

View File

@ -2,7 +2,7 @@ package ratelimit
import "errors"
var ErrRate = errors.New("rate exceeded")
var ErrRateLimitExceeded = errors.New("rate limit exceeded")
type queue struct {
buf []int64
@ -24,7 +24,7 @@ func (q *queue) len() int {
// push adds an element to the end of the queue.
func (q *queue) push(elem int64) error {
if q.count == len(q.buf) {
return ErrRate
return ErrRateLimitExceeded
}
q.buf[q.tail] = elem

View File

@ -37,8 +37,8 @@ func TestWindow(t *testing.T) {
if w.Len() != maxEvents {
t.Fatalf("q.Len() is %d, expected %d", w.Len(), maxEvents)
}
if err = w.Add(); err == nil {
t.Fatalf("add event %d within time limit should have failed", maxEvents+1)
if err = w.Add(); err != ErrRateLimitExceeded {
t.Fatalf("add event %d within time limit should have failed with err: %s", maxEvents+1, ErrRateLimitExceeded)
}
time.Sleep(timeLimit)