Skip to content

Commit

Permalink
docs: misc & changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Aug 8, 2023
1 parent 1a17ee8 commit c4ed06e
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 36 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,27 @@ The following emojis are used to highlight certain changes:

### Added

* The `routing/http` client and server now support Delegated IPNS as per [IPIP-379](https://specs.ipfs.tech/ipips/ipip-0379/).
* ✨ The `routing/http` package has received the following additions:
* Supports Delegated IPNS as per [IPIP-379](https://specs.ipfs.tech/ipips/ipip-0379/).
* Supports Delegated Peer Routing as per [IPIP-417](https://github.com/ipfs/specs/pull/417).

### Changed

* 🛠 The `routing/http` package has suffered the following modifications:
* Client `FindProviders` has been renamed to `GetProviders`. Similarly, the
required function names in the server `ContentRouter` have also been updated
for higher consistency with the remaining code and the specifications.
* Many types regarding response types were updated to conform to the updated
Peer Schema discussed in [IPIP-417](https://github.com/ipfs/specs/pull/417).

### Removed

* 🛠 The `routing/http` package has suffered the following removals:
* Server and client no longer support the `Provide*` methods for content routing.
These methods did not conform to any specification, as it is still being worked
out in [IPIP-378](https://github.com/ipfs/specs/pull/378).
* Server no longer exports `FindProvidersPath` and `ProvidePath`.

### Fixed

### Security
Expand Down
23 changes: 4 additions & 19 deletions routing/http/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
go-delegated-routing
Routing V1 Server and Client
=======================

> Delegated routing Client and Server over Reframe RPC
This package provides delegated routing implementation in Go:
- Client (for IPFS nodes like [Kubo](https://github.com/ipfs/kubo/blob/master/docs/config.md#routingrouters-parameters)),
- Server (for public indexers such as https://cid.contact)
> Delegated Routing V1 Server and Client over HTTP API.
## Documentation

- Go docs: https://pkg.go.dev/github.com/ipfs/boxo/routing/http/

## Lead Maintainer

🦗🎶

## Contributing

Contributions are welcome! This repository is part of the IPFS project and therefore governed by our [contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md).

## License

[SPDX-License-Identifier: Apache-2.0 OR MIT](LICENSE.md)
- Go Documentation: https://pkg.go.dev/github.com/ipfs/boxo/routing/http
- Routing V1 Specification: https://specs.ipfs.tech/routing/http-routing-v1/
2 changes: 1 addition & 1 deletion routing/http/contentrouter/contentrouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/multiformats/go-multihash"
)

var logger = logging.Logger("service/contentrouting")
var logger = logging.Logger("routing/http/contentrouter")

type Client interface {
GetProviders(ctx context.Context, key cid.Cid) (iter.ResultIter[types.Record], error)
Expand Down
6 changes: 3 additions & 3 deletions routing/http/contentrouter/contentrouter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ func TestGetProvidersAsync(t *testing.T) {
ID: &p2,
Protocols: []string{"transport-bitswap"},
},
// &types.UnknownRecord{
// Protocol: "UNKNOWN",
// },
&types.UnknownRecord{
Schema: "UNKNOWN",
},
}
aisIter := iter.ToResultIter[types.Record](iter.FromSlice(ais))

Expand Down
25 changes: 13 additions & 12 deletions routing/http/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ const (
DefaultStreamingRecordsLimit = 0
)

var logger = logging.Logger("service/server/delegatedrouting")
var logger = logging.Logger("routing/http/server")

const (
GetProvidersPath = "/routing/v1/providers/{cid}"
GetPeersPath = "/routing/v1/peers/{peer-id}"
GetIPNSRecordPath = "/routing/v1/ipns/{cid}"
getProvidersPath = "/routing/v1/providers/{cid}"
getPeersPath = "/routing/v1/peers/{peer-id}"
getIPNSRecordPath = "/routing/v1/ipns/{cid}"
)

type GetProvidersAsyncResponse struct {
Expand All @@ -50,7 +50,7 @@ type GetProvidersAsyncResponse struct {
type ContentRouter interface {
// GetProviders searches for peers who are able to provide the given [cid.Cid].
// Limit indicates the maximum amount of results to return; 0 means unbounded.
GetProviders(ctx context.Context, key cid.Cid, limit int) (iter.ResultIter[types.Record], error)
GetProviders(ctx context.Context, cid cid.Cid, limit int) (iter.ResultIter[types.Record], error)

// GetPeers searches for peers who have the provided [peer.ID].
// Limit indicates the maximum amount of results to return; 0 means unbounded.
Expand All @@ -74,15 +74,17 @@ func WithStreamingResultsDisabled() Option {
}

// WithRecordsLimit sets a limit that will be passed to [ContentRouter.GetProviders]
// for non-streaming requests (application/json). Default is [DefaultRecordsLimit].
// and [ContentRouter.GetPeers] for non-streaming requests (application/json).
// Default is [DefaultRecordsLimit].
func WithRecordsLimit(limit int) Option {
return func(s *server) {
s.recordsLimit = limit
}
}

// WithStreamingRecordsLimit sets a limit that will be passed to [ContentRouter.GetProviders]
// for streaming requests (application/x-ndjson). Default is [DefaultStreamingRecordsLimit].
// and [ContentRouter.GetPeers] for streaming requests (application/x-ndjson).
// Default is [DefaultStreamingRecordsLimit].
func WithStreamingRecordsLimit(limit int) Option {
return func(s *server) {
s.streamingRecordsLimit = limit
Expand All @@ -101,11 +103,10 @@ func Handler(svc ContentRouter, opts ...Option) http.Handler {
}

r := mux.NewRouter()
r.HandleFunc(GetProvidersPath, server.getProviders).Methods(http.MethodGet)
r.HandleFunc(GetPeersPath, server.getPeers).Methods(http.MethodGet)
r.HandleFunc(GetIPNSRecordPath, server.getIPNSRecord).Methods(http.MethodGet)
r.HandleFunc(GetIPNSRecordPath, server.putIPNSRecord).Methods(http.MethodPut)

r.HandleFunc(getProvidersPath, server.getProviders).Methods(http.MethodGet)
r.HandleFunc(getPeersPath, server.getPeers).Methods(http.MethodGet)
r.HandleFunc(getIPNSRecordPath, server.getIPNSRecord).Methods(http.MethodGet)
r.HandleFunc(getIPNSRecordPath, server.putIPNSRecord).Methods(http.MethodPut)
return r
}

Expand Down

0 comments on commit c4ed06e

Please sign in to comment.