feat: add fetch protocol (#1036)

Adds three methods to implement the `/libp2p/fetch/0.0.1` protocol:

* `libp2p.fetch(peerId, key) => Promise<Uint8Array>`
* `libp2p.fetchService.registerLookupFunction(prefix, lookupFunction)`
* `libp2p.fetchService.unRegisterLookupFunction(prefix, [lookupFunction])`

Co-authored-by: achingbrain <alex@achingbrain.net>
This commit is contained in:
Spencer T Brody
2022-01-24 12:07:11 -05:00
committed by GitHub
parent 00e49592a3
commit d8ceb0bc66
11 changed files with 932 additions and 2 deletions

6
src/fetch/constants.js Normal file
View File

@ -0,0 +1,6 @@
'use strict'
module.exports = {
// https://github.com/libp2p/specs/tree/master/fetch#wire-protocol
PROTOCOL: '/libp2p/fetch/0.0.1'
}