mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-03 04:37:30 +08:00
dont potentially kill our memory
This commit is contained in:
@ -1,7 +1,6 @@
|
|||||||
package dht
|
package dht
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -89,7 +88,7 @@ func (dht *IpfsDHT) GetValue(ctx context.Context, key u.Key) ([]byte, error) {
|
|||||||
|
|
||||||
// get closest peers in the routing table
|
// get closest peers in the routing table
|
||||||
rtp := dht.routingTable.ListPeers()
|
rtp := dht.routingTable.ListPeers()
|
||||||
log.Debugf("peers in rt: %s", len(rtp), rtp)
|
log.Errorf("peers in rt: %s", len(rtp), rtp)
|
||||||
if len(rtp) == 0 {
|
if len(rtp) == 0 {
|
||||||
log.Warning("No peers from routing table!")
|
log.Warning("No peers from routing table!")
|
||||||
return nil, errors.Wrap(kb.ErrLookupFailure)
|
return nil, errors.Wrap(kb.ErrLookupFailure)
|
||||||
@ -169,7 +168,7 @@ func (dht *IpfsDHT) Provide(ctx context.Context, key u.Key) error {
|
|||||||
// FindProviders searches until the context expires.
|
// FindProviders searches until the context expires.
|
||||||
func (dht *IpfsDHT) FindProviders(ctx context.Context, key u.Key) ([]peer.PeerInfo, error) {
|
func (dht *IpfsDHT) FindProviders(ctx context.Context, key u.Key) ([]peer.PeerInfo, error) {
|
||||||
var providers []peer.PeerInfo
|
var providers []peer.PeerInfo
|
||||||
for p := range dht.FindProvidersAsync(ctx, key, math.MaxInt32) {
|
for p := range dht.FindProvidersAsync(ctx, key, KValue) {
|
||||||
providers = append(providers, p)
|
providers = append(providers, p)
|
||||||
}
|
}
|
||||||
return providers, nil
|
return providers, nil
|
||||||
|
Reference in New Issue
Block a user