mirror of
https://github.com/fluencelabs/go-libp2p-kad-dht
synced 2025-07-31 03:52:03 +00:00
SearchValue: add backward-compatible GetValues
This commit is contained in:
14
routing.go
14
routing.go
@@ -226,6 +226,20 @@ func (dht *IpfsDHT) SearchValue(ctx context.Context, key string, opts ...ropts.O
|
||||
}
|
||||
|
||||
// GetValues gets nvals values corresponding to the given key.
|
||||
func (dht *IpfsDHT) GetValues(ctx context.Context, key string, nvals int) (_ []RecvdVal, err error) {
|
||||
valCh, err := dht.getValues(ctx, key, nvals)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out := make([]RecvdVal, 0, nvals)
|
||||
for val := range valCh {
|
||||
out = append(out, val)
|
||||
}
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (dht *IpfsDHT) getValues(ctx context.Context, key string, nvals int) (<-chan RecvdVal, error) {
|
||||
eip := log.EventBegin(ctx, "GetValues")
|
||||
|
||||
|
Reference in New Issue
Block a user