Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

test details

contentRouting.findProviders

real browser dht network network size 60 kbucket 20 maxPeers 40 randomWalk off visible connection churn due to maxPeers targets are guaranteed to be in network, but not necesarily routable

findProviders: async (key) => {
  if (!this.node._dht) throw new Error('Dht doesnt exist')
  const start = Date.now()
  const cid = await makeKeyId(Buffer.from(key))
  const providers = await pify(cb => node.contentRouting.findProviders(cid, 10 * 1000, cb))()
  // map to id strings
  const providerIds = providers.map(provider => provider.id.toB58String())
  // remove self
  const providerPeerIds = providerIds.filter(providerId => clientId !== providerId)
  const time = Date.now() - start
  return { time, result: providerPeerIds }
}

results

clientId time providers routingTable target

QmYhKytoUim3EKvegRabNe8u99LhSTDKPRvwuJKRdSqetx	3334	0	56	"group-20"
QmUT6CWYgvW8xX7HDoza3LAak6XEsddMEbaBiEp5HApfei	3490	6	56	"group-49"
QmceBmaPnYKA7DRJeRed7179z2eVmqYMopeDTB3vDZwYXJ	1429	0	54	"group-41"
QmUwR7gCenAUmCygsPLoNeepq8ynQbtqhFU7dg93JJNBf3	1298	0	53	"group-11"
QmeXma4Z4CHqDwvzFpReuBbDCePBcqUMHQNdCuxkuyxqJr	1492	0	50	"group-100"
QmX37Jq3kpWD7RR72vi8beQM1tB2PJDkwdgF4S7SmBi444	1622	0	0	"group-81"
QmaW6A3SgepudAjpLLcNHEpX5k9T5ZxkbJbGBu2y23Y1d6	2671	0	58	"group-73"
QmfDVxRrozu573C9SbgRubSrCsX9ZfvE2a2c1x9dzRe7NR	781	5	52	"group-87"
QmXUi2yWbdWZY44BC8BK1EQsWhGEWSh3DZbN7TwDTXHfqC	1090	0	61	"group-94"

Qmdn1UsFs2jLXgDTyv6dyEAA8MNZvAEYCeubzKP94askBz	1671	7	47	"group-30"
QmSbS7dTy7rsJ8sFt5CQQwVETdRFECZXuTfYQBFeYWZRKf	1827	0	4	"group-84"
QmXUi2yWbdWZY44BC8BK1EQsWhGEWSh3DZbN7TwDTXHfqC	606	12	46	"group-84"
QmZZDj89q7G2ZLMb9HxR4CR4537JBB2Mjp9U7Ke9Jrvg89	1699	5	46	"group-47"
QmaJoQsFpCAq8CyntVfjjgerj4qPrkhfxr4HmgQSQVMTft	1600	4	47	"group-11"
QmT4KhhWWbdzLch2VkER9q8DFtFTqwF1H4vt1iCVJ6Ai62	1574	0	53	"group-31"
QmU3wdKbZKYXwxJ19e8shm2yXJLLge8S3rRZT73aj37EFE	1502	0	45	"group-27"
QmZKRn9CsWkA6SQnDevxg3c1J42wj2ZeD1rnFd32H9rYjf	4566	0	62	"group-94"
QmceBmaPnYKA7DRJeRed7179z2eVmqYMopeDTB3vDZwYXJ	1070	0	53	"group-11"
QmVfAFccscquV1vFqvSabbA8EAGwftDEvhW9o28hk3CTVh	3023	10	54	"group-97"

QmTDb8GQEMjZiAJHcyDsRaomv5Zz8XGPPN1u78B7WwjuDb	896	0	5	"group-17"
QmVZhWSbPpu7D9TaJdKZ9uUe87zbDP939iKuMdSmtBLBTx	1389	5	0	"group-45"
QmSDwgdH4J2JDc8X48MFChDLieppcSc9QNpuRWKVVEgUPm	1003	10	56	"group-20"
QmXi3dMzzUGFHoX3Fqrrv6wtYbDdAwWbo2N48D4NnJcKAm	3348	12	54	"group-94"
QmRKoCTxnGX4M3JayMDsPwi1r4Tckhk29ZVvSREhhpuYn6	984	0	45	"group-78"
QmWhcFZr1AzbYAnXQvVjVhQMhmgNXAWJhBy1UECxPxgJ2C	2062	7	41	"group-75"
QmY21rMh75gC5nXdphvAEtcZqbkj3ejXG2Q4bXUXeToqyN	1546	3	0	"group-97"
QmX37Jq3kpWD7RR72vi8beQM1tB2PJDkwdgF4S7SmBi444	4406	0	52	"group-55"
QmbKrzgHyoPJX34kDCgpu43Dmehr4Y6Ad45senzLqKMcZt	10007	3	43	"group-84"
QmbF3E3j1c32nrWtDf7B9imMo47CY4yNeKmc79bzjiTnGY	5433	0	48	"group-9"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.