Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
provide full ProvideRequest to server so that it can relay signature …
Browse files Browse the repository at this point in the history
…if needed
  • Loading branch information
willscott committed Jul 29, 2022
1 parent 49c788a commit 372d78d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions server/findproviders.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package server
import (
"context"
"net/http"
"time"

"github.com/ipfs/go-cid"
"github.com/ipfs/go-delegated-routing/client"
Expand All @@ -19,7 +18,7 @@ type DelegatedRoutingService interface {
FindProviders(ctx context.Context, key cid.Cid) (<-chan client.FindProvidersAsyncResult, error)
GetIPNS(ctx context.Context, id []byte) (<-chan client.GetIPNSAsyncResult, error)
PutIPNS(ctx context.Context, id []byte, record []byte) (<-chan client.PutIPNSAsyncResult, error)
Provide(ctx context.Context, key cid.Cid, provider peer.AddrInfo, ttl time.Duration) (<-chan client.ProvideAsyncResult, error)
Provide(ctx context.Context, req *client.ProvideRequest) (<-chan client.ProvideAsyncResult, error)
}

func DelegatedRoutingAsyncHandler(svc DelegatedRoutingService) http.HandlerFunc {
Expand Down Expand Up @@ -156,7 +155,7 @@ func (drs *delegatedRoutingServer) Provide(ctx context.Context, req *proto.Provi
logger.Errorf("Provide function rejected request (%w)", err)
return
}
ch, err := drs.service.Provide(ctx, pr.Key, pr.Peer, pr.TTL)
ch, err := drs.service.Provide(ctx, pr)
if err != nil {
logger.Errorf("Provide function rejected request (%w)", err)
return
Expand Down
4 changes: 2 additions & 2 deletions test/clientserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ func (testDelegatedRoutingService) FindProviders(ctx context.Context, key cid.Ci
return ch, nil
}

func (testDelegatedRoutingService) Provide(ctx context.Context, key cid.Cid, provider peer.AddrInfo, ttl time.Duration) (<-chan client.ProvideAsyncResult, error) {
func (testDelegatedRoutingService) Provide(ctx context.Context, pr *client.ProvideRequest) (<-chan client.ProvideAsyncResult, error) {
ch := make(chan client.ProvideAsyncResult)
go func() {
ch <- client.ProvideAsyncResult{AdvisoryTTL: time.Hour}
Expand Down Expand Up @@ -394,7 +394,7 @@ func (s *hangingDelegatedRoutingService) FindProviders(ctx context.Context, key
return ch, nil
}

func (s *hangingDelegatedRoutingService) Provide(ctx context.Context, key cid.Cid, provider peer.AddrInfo, ttl time.Duration) (<-chan client.ProvideAsyncResult, error) {
func (s *hangingDelegatedRoutingService) Provide(ctx context.Context, pr *client.ProvideRequest) (<-chan client.ProvideAsyncResult, error) {
ch := make(chan client.ProvideAsyncResult)
go func() {
<-ctx.Done()
Expand Down

0 comments on commit 372d78d

Please sign in to comment.