Skip to content

Commit

Permalink
refactor: simplify ipns validation in example
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed May 17, 2023
1 parent ff20a4d commit 4fb455d
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions examples/gateway/proxy/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/gogo/protobuf/proto"
"github.com/ipfs/boxo/ipns"
ipns_pb "github.com/ipfs/boxo/ipns/pb"
ic "github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/core/routing"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
Expand Down Expand Up @@ -111,19 +110,7 @@ func (ps *proxyRouting) fetch(ctx context.Context, id peer.ID) ([]byte, error) {
return nil, err
}

pub, err := id.ExtractPublicKey()
if err != nil {
// Make sure it works with all those RSA that cannot be embedded into the
// Peer ID.
if len(entry.PubKey) > 0 {
pub, err = ic.UnmarshalPublicKey(entry.PubKey)
}
}
if err != nil {
return nil, err
}

err = ipns.Validate(pub, &entry)
err = ipns.ValidateWithPeerID(id, &entry)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 4fb455d

Please sign in to comment.