Fixed imports.

pull/4455/head
frozen 1 year ago
parent 41900b0400
commit f0b70d9f71
No known key found for this signature in database
GPG Key ID: 5391C63E79B03EDE
  1. 17
      internal/utils/blockedpeers/manager.go
  2. 11
      internal/utils/blockedpeers/manager_test.go

@ -1,22 +1,23 @@
package blockedpeers
import (
"github.com/harmony-one/harmony/internal/utils/lrucache"
libp2p_peer "github.com/libp2p/go-libp2p/core/peer"
"time"
"github.com/harmony-one/harmony/internal/utils/lrucache"
"github.com/libp2p/go-libp2p/core/peer"
)
type Manager struct {
internal *lrucache.Cache[libp2p_peer.ID, time.Time]
internal *lrucache.Cache[peer.ID, time.Time]
}
func NewManager(size int) *Manager {
return &Manager{
internal: lrucache.NewCache[libp2p_peer.ID, time.Time](size),
internal: lrucache.NewCache[peer.ID, time.Time](size),
}
}
func (m *Manager) IsBanned(key libp2p_peer.ID, now time.Time) bool {
func (m *Manager) IsBanned(key peer.ID, now time.Time) bool {
future, ok := m.internal.Get(key)
if ok {
@ -25,11 +26,11 @@ func (m *Manager) IsBanned(key libp2p_peer.ID, now time.Time) bool {
return ok
}
func (m *Manager) Ban(key libp2p_peer.ID, future time.Time) {
func (m *Manager) Ban(key peer.ID, future time.Time) {
m.internal.Set(key, future)
}
func (m *Manager) Contains(key libp2p_peer.ID) bool {
func (m *Manager) Contains(key peer.ID) bool {
return m.internal.Contains(key)
}
@ -37,6 +38,6 @@ func (m *Manager) Len() int {
return m.internal.Len()
}
func (m *Manager) Keys() []libp2p_peer.ID {
func (m *Manager) Keys() []peer.ID {
return m.internal.Keys()
}

@ -1,17 +1,18 @@
package blockedpeers
import (
libp2p_peer "github.com/libp2p/go-libp2p/core/peer"
"github.com/stretchr/testify/require"
"testing"
"time"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/stretchr/testify/require"
)
func TestNewManager(t *testing.T) {
var (
peer1 libp2p_peer.ID = "peer1"
now = time.Now()
m = NewManager(4)
peer1 peer.ID = "peer1"
now = time.Now()
m = NewManager(4)
)
t.Run("check_empty", func(t *testing.T) {

Loading…
Cancel
Save