2016-12-23 18:35:37 +00:00
|
|
|
package ipfscluster
|
|
|
|
|
2017-01-30 12:12:25 +00:00
|
|
|
import (
|
2018-03-13 14:32:56 +00:00
|
|
|
"context"
|
2017-01-30 12:12:25 +00:00
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
"github.com/ipfs/ipfs-cluster/api"
|
2020-04-20 13:26:03 +00:00
|
|
|
"github.com/ipfs/ipfs-cluster/state"
|
2019-05-04 20:36:10 +00:00
|
|
|
"github.com/ipfs/ipfs-cluster/version"
|
2017-02-08 17:04:08 +00:00
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
cid "github.com/ipfs/go-cid"
|
2019-06-14 10:41:11 +00:00
|
|
|
peer "github.com/libp2p/go-libp2p-core/peer"
|
2019-05-04 20:36:10 +00:00
|
|
|
rpc "github.com/libp2p/go-libp2p-gorpc"
|
2019-06-14 10:41:11 +00:00
|
|
|
|
|
|
|
ocgorpc "github.com/lanzafame/go-libp2p-ocgorpc"
|
2018-06-27 04:03:15 +00:00
|
|
|
"go.opencensus.io/trace"
|
2019-05-04 20:36:10 +00:00
|
|
|
)
|
2018-06-27 04:03:15 +00:00
|
|
|
|
2019-05-13 20:59:59 +00:00
|
|
|
// RPC endpoint types w.r.t. trust level
|
|
|
|
const (
|
|
|
|
// RPCClosed endpoints can only be called by the local cluster peer
|
|
|
|
// on itself.
|
|
|
|
RPCClosed RPCEndpointType = iota
|
|
|
|
// RPCTrusted endpoints can be called by "trusted" peers.
|
|
|
|
// It depends which peers are considered trusted. For example,
|
|
|
|
// in "raft" mode, Cluster will all peers as "trusted". In "crdt" mode,
|
|
|
|
// trusted peers are those specified in the configuration.
|
|
|
|
RPCTrusted
|
|
|
|
// RPCOpen endpoints can be called by any peer in the Cluster swarm.
|
|
|
|
RPCOpen
|
|
|
|
)
|
|
|
|
|
|
|
|
// RPCEndpointType controls how access is granted to an RPC endpoint
|
|
|
|
type RPCEndpointType int
|
|
|
|
|
|
|
|
// A trick to find where something is used (i.e. Cluster.Pin):
|
|
|
|
// grep -R -B 3 '"Pin"' | grep -C 1 '"Cluster"'.
|
|
|
|
// This does not cover globalPinInfo*(...) broadcasts nor redirects to leader
|
|
|
|
// in Raft.
|
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
// newRPCServer returns a new RPC Server for Cluster.
|
|
|
|
func newRPCServer(c *Cluster) (*rpc.Server, error) {
|
|
|
|
var s *rpc.Server
|
2019-05-09 13:14:26 +00:00
|
|
|
|
|
|
|
authF := func(pid peer.ID, svc, method string) bool {
|
2019-05-10 10:52:37 +00:00
|
|
|
endpointType, ok := c.config.RPCPolicy[svc+"."+method]
|
2019-05-09 13:14:26 +00:00
|
|
|
if !ok {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
switch endpointType {
|
|
|
|
case RPCTrusted:
|
|
|
|
return c.consensus.IsTrustedPeer(c.ctx, pid)
|
|
|
|
case RPCOpen:
|
|
|
|
return true
|
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
if c.config.Tracing {
|
|
|
|
s = rpc.NewServer(
|
|
|
|
c.host,
|
|
|
|
version.RPCProtocol,
|
|
|
|
rpc.WithServerStatsHandler(&ocgorpc.ServerHandler{}),
|
2019-05-09 13:14:26 +00:00
|
|
|
rpc.WithAuthorizeFunc(authF),
|
2019-05-04 20:36:10 +00:00
|
|
|
)
|
|
|
|
} else {
|
2019-05-09 13:14:26 +00:00
|
|
|
s = rpc.NewServer(c.host, version.RPCProtocol, rpc.WithAuthorizeFunc(authF))
|
2019-05-04 20:36:10 +00:00
|
|
|
}
|
2019-02-27 17:04:35 +00:00
|
|
|
|
2019-05-09 12:19:07 +00:00
|
|
|
cl := &ClusterRPCAPI{c}
|
2019-05-09 14:33:59 +00:00
|
|
|
err := s.RegisterName(RPCServiceID(cl), cl)
|
2019-05-04 20:36:10 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2019-05-09 12:19:07 +00:00
|
|
|
pt := &PinTrackerRPCAPI{c.tracker}
|
2019-05-09 14:33:59 +00:00
|
|
|
err = s.RegisterName(RPCServiceID(pt), pt)
|
2019-05-04 20:36:10 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2019-05-09 12:19:07 +00:00
|
|
|
ic := &IPFSConnectorRPCAPI{c.ipfs}
|
2019-05-09 14:33:59 +00:00
|
|
|
err = s.RegisterName(RPCServiceID(ic), ic)
|
2019-05-04 20:36:10 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2019-05-09 12:19:07 +00:00
|
|
|
cons := &ConsensusRPCAPI{c.consensus}
|
2019-05-09 14:33:59 +00:00
|
|
|
err = s.RegisterName(RPCServiceID(cons), cons)
|
2019-05-04 20:36:10 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2019-05-09 12:19:07 +00:00
|
|
|
pm := &PeerMonitorRPCAPI{c.monitor}
|
2019-05-09 14:33:59 +00:00
|
|
|
err = s.RegisterName(RPCServiceID(pm), pm)
|
2019-05-04 20:36:10 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return s, nil
|
|
|
|
}
|
2016-12-23 18:35:37 +00:00
|
|
|
|
2019-05-09 14:33:59 +00:00
|
|
|
// RPCServiceID returns the Service ID for the given RPCAPI object.
|
|
|
|
func RPCServiceID(rpcSvc interface{}) string {
|
|
|
|
switch rpcSvc.(type) {
|
|
|
|
case *ClusterRPCAPI:
|
|
|
|
return "Cluster"
|
|
|
|
case *PinTrackerRPCAPI:
|
|
|
|
return "PinTracker"
|
|
|
|
case *IPFSConnectorRPCAPI:
|
|
|
|
return "IPFSConnector"
|
|
|
|
case *ConsensusRPCAPI:
|
|
|
|
return "Consensus"
|
|
|
|
case *PeerMonitorRPCAPI:
|
|
|
|
return "PeerMonitor"
|
|
|
|
default:
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
// ClusterRPCAPI is a go-libp2p-gorpc service which provides the internal peer
|
|
|
|
// API for the main cluster component.
|
|
|
|
type ClusterRPCAPI struct {
|
2017-02-08 17:04:08 +00:00
|
|
|
c *Cluster
|
2016-12-23 18:35:37 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
// PinTrackerRPCAPI is a go-libp2p-gorpc service which provides the internal
|
|
|
|
// peer API for the PinTracker component.
|
|
|
|
type PinTrackerRPCAPI struct {
|
|
|
|
tracker PinTracker
|
|
|
|
}
|
|
|
|
|
|
|
|
// IPFSConnectorRPCAPI is a go-libp2p-gorpc service which provides the
|
|
|
|
// internal peer API for the IPFSConnector component.
|
|
|
|
type IPFSConnectorRPCAPI struct {
|
|
|
|
ipfs IPFSConnector
|
|
|
|
}
|
|
|
|
|
|
|
|
// ConsensusRPCAPI is a go-libp2p-gorpc service which provides the
|
|
|
|
// internal peer API for the Consensus component.
|
|
|
|
type ConsensusRPCAPI struct {
|
|
|
|
cons Consensus
|
|
|
|
}
|
|
|
|
|
|
|
|
// PeerMonitorRPCAPI is a go-libp2p-gorpc service which provides the
|
|
|
|
// internal peer API for the PeerMonitor component.
|
|
|
|
type PeerMonitorRPCAPI struct {
|
|
|
|
mon PeerMonitor
|
|
|
|
}
|
|
|
|
|
2016-12-23 18:35:37 +00:00
|
|
|
/*
|
2019-05-04 20:36:10 +00:00
|
|
|
Cluster component methods
|
2016-12-23 18:35:37 +00:00
|
|
|
*/
|
|
|
|
|
2017-01-25 17:07:19 +00:00
|
|
|
// ID runs Cluster.ID()
|
2019-05-04 20:36:10 +00:00
|
|
|
func (rpcapi *ClusterRPCAPI) ID(ctx context.Context, in struct{}, out *api.ID) error {
|
2019-02-27 17:04:35 +00:00
|
|
|
id := rpcapi.c.ID(ctx)
|
|
|
|
*out = *id
|
2017-01-24 15:19:23 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
Improve pin/unpin method signatures (#843)
* Improve pin/unpin method signatures:
These changes the following Cluster Go API methods:
* -> Cluster.Pin(ctx, cid, options) (pin, error)
* -> Cluster.Unpin(ctx, cid) (pin, error)
* -> Cluster.PinPath(ctx, path, opts) (pin,error)
Pin and Unpin now return the pinned object.
The signature of the methods now matches that of the API Client, is clearer as
to what options the user can set and is aligned with PinPath, UnpinPath, which
returned pin methods.
The REST API now returns the Pinned/Unpinned object rather than 204-Accepted.
This was necessary for a cleaner pin/update approach, which I'm working on in
another branch.
Most of the changes here are updating tests to the new signatures
* Adapt load-balancing client to new Pin/Unpin signatures
* cluster.go: Fix typo
Co-Authored-By: Kishan Sagathiya <kishansagathiya@gmail.com>
* cluster.go: Fix typo
Co-Authored-By: Kishan Sagathiya <kishansagathiya@gmail.com>
2019-07-22 13:39:11 +00:00
|
|
|
// Pin runs Cluster.pin().
|
|
|
|
func (rpcapi *ClusterRPCAPI) Pin(ctx context.Context, in *api.Pin, out *api.Pin) error {
|
|
|
|
// we do not call the Pin method directly since that method does not
|
|
|
|
// allow to pin other than regular DataType pins. The adder will
|
|
|
|
// however send Meta, Shard and ClusterDAG pins.
|
|
|
|
pin, _, err := rpcapi.c.pin(ctx, in, []peer.ID{})
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
*out = *pin
|
|
|
|
return nil
|
2016-12-23 18:35:37 +00:00
|
|
|
}
|
|
|
|
|
2016-12-28 15:25:24 +00:00
|
|
|
// Unpin runs Cluster.Unpin().
|
Improve pin/unpin method signatures (#843)
* Improve pin/unpin method signatures:
These changes the following Cluster Go API methods:
* -> Cluster.Pin(ctx, cid, options) (pin, error)
* -> Cluster.Unpin(ctx, cid) (pin, error)
* -> Cluster.PinPath(ctx, path, opts) (pin,error)
Pin and Unpin now return the pinned object.
The signature of the methods now matches that of the API Client, is clearer as
to what options the user can set and is aligned with PinPath, UnpinPath, which
returned pin methods.
The REST API now returns the Pinned/Unpinned object rather than 204-Accepted.
This was necessary for a cleaner pin/update approach, which I'm working on in
another branch.
Most of the changes here are updating tests to the new signatures
* Adapt load-balancing client to new Pin/Unpin signatures
* cluster.go: Fix typo
Co-Authored-By: Kishan Sagathiya <kishansagathiya@gmail.com>
* cluster.go: Fix typo
Co-Authored-By: Kishan Sagathiya <kishansagathiya@gmail.com>
2019-07-22 13:39:11 +00:00
|
|
|
func (rpcapi *ClusterRPCAPI) Unpin(ctx context.Context, in *api.Pin, out *api.Pin) error {
|
|
|
|
pin, err := rpcapi.c.Unpin(ctx, in.Cid)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
*out = *pin
|
|
|
|
return nil
|
2016-12-23 18:35:37 +00:00
|
|
|
}
|
|
|
|
|
Add PinPath/UnpinPath support.
Squashed commit of the following:
commit 38cf569c6aed77c46ee4e0f8baa4d1a9daf8f03e
Merge: d125f69 aaada42
Author: Hector Sanjuan <hsanjuan@users.noreply.github.com>
Date: Wed Feb 20 11:02:00 2019 +0000
Merge pull request #634 from ipfs/issue_450
Support PinPath, UnpinPath (resolve before pinning)
commit aaada42054e1f1c7b2abb1270859d0de41a0e5d8
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 19 22:16:25 2019 +0530
formatResponse accepts api.Pin and not api.PinSerial
commit b5da4bea045865814cc422da71827b44ddd44b90
Merge: ba59036 cc8dd7e
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 19 21:36:46 2019 +0530
Merge branch 'master' into issue_450
commit ba5903649c1df1dba20f4d6f7e3573d6fe24921f
Merge: f002914 d59880c
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Mon Feb 18 08:41:11 2019 +0530
Merge branch 'issue_450' of github.com:ipfs/ipfs-cluster into issue_450
commit f00291494c0c02621c2296cbb7ac71e4c23aa9ec
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Mon Feb 18 08:31:39 2019 +0530
PinPath: more improvements
Added tracing for new methods
commit d59880c338eaa8214fe06b4f930a540793d78407
Merge: 0ca4c7c b4f0eb3
Author: Hector Sanjuan <hsanjuan@users.noreply.github.com>
Date: Wed Feb 13 15:22:49 2019 +0000
Merge branch 'master' into issue_450
commit 0ca4c7c3b0670ed9c8279f8274d36e3485c10030
Merge: d35017a ecef9ea
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 12 13:10:13 2019 +0530
Merge branch 'master' into issue_450
commit d35017a8de91ca9fc9a9a047c48c75134cee9f98
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 12 13:07:25 2019 +0530
PinPath: more improvements
- Worth having `PinOptions` as a separate field in the struct and
constructing the query in the test with ToQuery()
- sharness: "intialization" line can be placed outside the tests at
the top
commit 68e3b90417ffbad89d41a70ac81d85f9037f8848
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Sun Feb 10 21:43:50 2019 +0530
Using if-continue pattern instead of if-else
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 3c29799f3b85be328b27508332ab92049d8b82f3
Merge: 956790b 4324889
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Thu Feb 7 10:25:52 2019 +0530
Merge branch 'master' into issue_450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 956790b381db9858e4194f983e898b07dc51ba66
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 21:11:20 2019 +0530
Removing resolved path
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 7191cc46cedfbec116a9746937e28881b50ca044
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 16:45:07 2019 +0530
Fix go vet
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit f8b3d5b63b1b7569e2a3e0d82894fd4491c246c4
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 16:07:03 2019 +0530
Fixed linting error
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 23c57eb467755a1f21387a1615a7f34e97348053
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 09:20:41 2019 +0530
Fixed tests
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 0caedd94aefeb3b6649dedc214cb4b849ace2ea4
Merge: 17e555e 5a7ee1d
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 00:07:10 2019 +0530
Merge branch 'master' into issue_450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 17e555e4a7c574413df90aac70c5cc29cab98f54
Author: Hector Sanjuan <code@hector.link>
Date: Tue Feb 5 16:58:50 2019 +0000
PinPath: address some feedback + improvements
* Changed client's Pin() API and PinPath to be consistent
* Added helper methods to turn PinPath to query and back
* Make code and tests build
* Use TestCidResolved everywhere
* Fix cluster.PinPath arguments
* Fix formatting of responses with --no-status
* Make tests readable and call Fatal when needed
* Use a pathTestCases variable
commit f0e7369c47c5ddadc8ed45df5fd2d4d9b2d42b38
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 5 18:34:26 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
Addressed review comments as in
https://github.com/ipfs/ipfs-cluster/pull/634#pullrequestreview-198751932
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit a8b4f181d2d7afed32ee41331dfaab19fd66a173
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 29 22:41:27 2019 +0530
Fixing tests
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit e39b95ca19e4d75506f4f492678245ef13936a44
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 29 14:52:53 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
- PinPath and UnpinPath should return api.Pin
- PinPath should accept pin options
- Removing duplicate logic for Resolve from cluster
- And many other review comments https://github.com/ipfs/ipfs-cluster/pull/634#pullrequestreview-195509504
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit d146075126320896665ba58d337a13789f68ea86
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 23 17:08:41 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
PinPath(in both rest and rpc) should return a serializable struct in the
form `{"\":"Q...cid..string..."}` (as used in "github.com/ipfs/go-cid"
to marshal and unmarshal)
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 1f4869568a8adb450275257154ea3a26d03a30f3
Merge: 7acfd28 a244af9
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 23 07:18:56 2019 +0530
Merge branch 'master' into issue_450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 7acfd282732ddf2282a67d4f9d0170a494eb3ed4
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 22 18:14:32 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
- RPC must always use serializable structs
- In command, just use pin with path as cid is also a valid path
- Addressing many other small review comments as in
https://github.com/ipfs/ipfs-cluster/pull/634#pullrequestreview-192122534
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 36905041e1e3f0b204942030aab3ab7b5b9e4d62
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 16 09:36:42 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
Extra logic for path checking should go into resolve so that it can be
properly reused
Added sharness tests
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 9116bda3534e77bb391d873051bb520a1b01a326
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 16 08:08:07 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
error strings should not be capitalized
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit ca7e61861374f456300a85ddc0374e594f74f963
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 15 23:40:25 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
Tests
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 522fbcd899f01c01680375561a32a87464157c0a
Merge: f1a56ab f7bc468
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 15 10:40:54 2019 +0530
Merge branch 'master' into issue_450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit f1a56ab925fb74c0c44273a4524afa4843cf757f
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Mon Jan 14 20:58:17 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
- IPFS Connector should act as a pure IPFS client, any extra logic
should go to cluster.go
- Use cid.Undef, instead of cid.Cid{}
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit c83b91054f6774f1f9d4930cfc3f1fa28236f57c
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Thu Jan 10 08:57:17 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
- Separate handlers, methods and rpc apis for PinPath and UnpinPath from
Pin and Unpin
- Support ipld paths as well
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 719dff88129366ce3ccb5e04cb6f8082a0915c5c
Merge: 91ceb47 21170c4
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 9 19:38:35 2019 +0530
Merge branch 'issue_450_old' into HEAD
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 91ceb4796259ca7ef2974ec43e6a278a12796b13
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 9 19:36:41 2019 +0530
Revert "WIP: Figure out why test does not impleme"
This reverts commit 28a3a3f25dce6f296c8cbef86221644c099a7e75.
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 28a3a3f25dce6f296c8cbef86221644c099a7e75
Author: cd10012 <ced361@nyu.edu>
Date: Tue Jul 24 23:23:10 2018 -0400
WIP: Figure out why test does not implement IPFSConnector interface...
License: MIT
Signed-off-by: cd10012 <ced361@nyu.edu>
commit 21170c48e77e69583db64544b08120a9baf40d8d
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 8 10:37:59 2019 +0530
Support PinPath, UnpinPath (resolve before pinning)
This commit adds API support for pinning using path
`POST /pins/<ipfs or ipns path>` and `DELETE /pins/<ipfs or ipns path>`
will resolve the path into a cid and perform perform pinning or
unpinning
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Co-authored-by: Hector Sanjuan <hector@protocol.ai>
License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
2019-02-20 11:07:50 +00:00
|
|
|
// PinPath resolves path into a cid and runs Cluster.Pin().
|
2019-05-04 20:36:10 +00:00
|
|
|
func (rpcapi *ClusterRPCAPI) PinPath(ctx context.Context, in *api.PinPath, out *api.Pin) error {
|
Improve pin/unpin method signatures (#843)
* Improve pin/unpin method signatures:
These changes the following Cluster Go API methods:
* -> Cluster.Pin(ctx, cid, options) (pin, error)
* -> Cluster.Unpin(ctx, cid) (pin, error)
* -> Cluster.PinPath(ctx, path, opts) (pin,error)
Pin and Unpin now return the pinned object.
The signature of the methods now matches that of the API Client, is clearer as
to what options the user can set and is aligned with PinPath, UnpinPath, which
returned pin methods.
The REST API now returns the Pinned/Unpinned object rather than 204-Accepted.
This was necessary for a cleaner pin/update approach, which I'm working on in
another branch.
Most of the changes here are updating tests to the new signatures
* Adapt load-balancing client to new Pin/Unpin signatures
* cluster.go: Fix typo
Co-Authored-By: Kishan Sagathiya <kishansagathiya@gmail.com>
* cluster.go: Fix typo
Co-Authored-By: Kishan Sagathiya <kishansagathiya@gmail.com>
2019-07-22 13:39:11 +00:00
|
|
|
pin, err := rpcapi.c.PinPath(ctx, in.Path, in.PinOptions)
|
2019-02-27 18:43:29 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-02-27 17:04:35 +00:00
|
|
|
*out = *pin
|
2019-02-27 18:43:29 +00:00
|
|
|
return nil
|
Add PinPath/UnpinPath support.
Squashed commit of the following:
commit 38cf569c6aed77c46ee4e0f8baa4d1a9daf8f03e
Merge: d125f69 aaada42
Author: Hector Sanjuan <hsanjuan@users.noreply.github.com>
Date: Wed Feb 20 11:02:00 2019 +0000
Merge pull request #634 from ipfs/issue_450
Support PinPath, UnpinPath (resolve before pinning)
commit aaada42054e1f1c7b2abb1270859d0de41a0e5d8
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 19 22:16:25 2019 +0530
formatResponse accepts api.Pin and not api.PinSerial
commit b5da4bea045865814cc422da71827b44ddd44b90
Merge: ba59036 cc8dd7e
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 19 21:36:46 2019 +0530
Merge branch 'master' into issue_450
commit ba5903649c1df1dba20f4d6f7e3573d6fe24921f
Merge: f002914 d59880c
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Mon Feb 18 08:41:11 2019 +0530
Merge branch 'issue_450' of github.com:ipfs/ipfs-cluster into issue_450
commit f00291494c0c02621c2296cbb7ac71e4c23aa9ec
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Mon Feb 18 08:31:39 2019 +0530
PinPath: more improvements
Added tracing for new methods
commit d59880c338eaa8214fe06b4f930a540793d78407
Merge: 0ca4c7c b4f0eb3
Author: Hector Sanjuan <hsanjuan@users.noreply.github.com>
Date: Wed Feb 13 15:22:49 2019 +0000
Merge branch 'master' into issue_450
commit 0ca4c7c3b0670ed9c8279f8274d36e3485c10030
Merge: d35017a ecef9ea
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 12 13:10:13 2019 +0530
Merge branch 'master' into issue_450
commit d35017a8de91ca9fc9a9a047c48c75134cee9f98
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 12 13:07:25 2019 +0530
PinPath: more improvements
- Worth having `PinOptions` as a separate field in the struct and
constructing the query in the test with ToQuery()
- sharness: "intialization" line can be placed outside the tests at
the top
commit 68e3b90417ffbad89d41a70ac81d85f9037f8848
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Sun Feb 10 21:43:50 2019 +0530
Using if-continue pattern instead of if-else
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 3c29799f3b85be328b27508332ab92049d8b82f3
Merge: 956790b 4324889
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Thu Feb 7 10:25:52 2019 +0530
Merge branch 'master' into issue_450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 956790b381db9858e4194f983e898b07dc51ba66
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 21:11:20 2019 +0530
Removing resolved path
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 7191cc46cedfbec116a9746937e28881b50ca044
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 16:45:07 2019 +0530
Fix go vet
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit f8b3d5b63b1b7569e2a3e0d82894fd4491c246c4
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 16:07:03 2019 +0530
Fixed linting error
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 23c57eb467755a1f21387a1615a7f34e97348053
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 09:20:41 2019 +0530
Fixed tests
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 0caedd94aefeb3b6649dedc214cb4b849ace2ea4
Merge: 17e555e 5a7ee1d
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 00:07:10 2019 +0530
Merge branch 'master' into issue_450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 17e555e4a7c574413df90aac70c5cc29cab98f54
Author: Hector Sanjuan <code@hector.link>
Date: Tue Feb 5 16:58:50 2019 +0000
PinPath: address some feedback + improvements
* Changed client's Pin() API and PinPath to be consistent
* Added helper methods to turn PinPath to query and back
* Make code and tests build
* Use TestCidResolved everywhere
* Fix cluster.PinPath arguments
* Fix formatting of responses with --no-status
* Make tests readable and call Fatal when needed
* Use a pathTestCases variable
commit f0e7369c47c5ddadc8ed45df5fd2d4d9b2d42b38
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 5 18:34:26 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
Addressed review comments as in
https://github.com/ipfs/ipfs-cluster/pull/634#pullrequestreview-198751932
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit a8b4f181d2d7afed32ee41331dfaab19fd66a173
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 29 22:41:27 2019 +0530
Fixing tests
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit e39b95ca19e4d75506f4f492678245ef13936a44
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 29 14:52:53 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
- PinPath and UnpinPath should return api.Pin
- PinPath should accept pin options
- Removing duplicate logic for Resolve from cluster
- And many other review comments https://github.com/ipfs/ipfs-cluster/pull/634#pullrequestreview-195509504
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit d146075126320896665ba58d337a13789f68ea86
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 23 17:08:41 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
PinPath(in both rest and rpc) should return a serializable struct in the
form `{"\":"Q...cid..string..."}` (as used in "github.com/ipfs/go-cid"
to marshal and unmarshal)
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 1f4869568a8adb450275257154ea3a26d03a30f3
Merge: 7acfd28 a244af9
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 23 07:18:56 2019 +0530
Merge branch 'master' into issue_450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 7acfd282732ddf2282a67d4f9d0170a494eb3ed4
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 22 18:14:32 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
- RPC must always use serializable structs
- In command, just use pin with path as cid is also a valid path
- Addressing many other small review comments as in
https://github.com/ipfs/ipfs-cluster/pull/634#pullrequestreview-192122534
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 36905041e1e3f0b204942030aab3ab7b5b9e4d62
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 16 09:36:42 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
Extra logic for path checking should go into resolve so that it can be
properly reused
Added sharness tests
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 9116bda3534e77bb391d873051bb520a1b01a326
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 16 08:08:07 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
error strings should not be capitalized
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit ca7e61861374f456300a85ddc0374e594f74f963
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 15 23:40:25 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
Tests
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 522fbcd899f01c01680375561a32a87464157c0a
Merge: f1a56ab f7bc468
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 15 10:40:54 2019 +0530
Merge branch 'master' into issue_450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit f1a56ab925fb74c0c44273a4524afa4843cf757f
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Mon Jan 14 20:58:17 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
- IPFS Connector should act as a pure IPFS client, any extra logic
should go to cluster.go
- Use cid.Undef, instead of cid.Cid{}
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit c83b91054f6774f1f9d4930cfc3f1fa28236f57c
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Thu Jan 10 08:57:17 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
- Separate handlers, methods and rpc apis for PinPath and UnpinPath from
Pin and Unpin
- Support ipld paths as well
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 719dff88129366ce3ccb5e04cb6f8082a0915c5c
Merge: 91ceb47 21170c4
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 9 19:38:35 2019 +0530
Merge branch 'issue_450_old' into HEAD
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 91ceb4796259ca7ef2974ec43e6a278a12796b13
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 9 19:36:41 2019 +0530
Revert "WIP: Figure out why test does not impleme"
This reverts commit 28a3a3f25dce6f296c8cbef86221644c099a7e75.
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 28a3a3f25dce6f296c8cbef86221644c099a7e75
Author: cd10012 <ced361@nyu.edu>
Date: Tue Jul 24 23:23:10 2018 -0400
WIP: Figure out why test does not implement IPFSConnector interface...
License: MIT
Signed-off-by: cd10012 <ced361@nyu.edu>
commit 21170c48e77e69583db64544b08120a9baf40d8d
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 8 10:37:59 2019 +0530
Support PinPath, UnpinPath (resolve before pinning)
This commit adds API support for pinning using path
`POST /pins/<ipfs or ipns path>` and `DELETE /pins/<ipfs or ipns path>`
will resolve the path into a cid and perform perform pinning or
unpinning
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Co-authored-by: Hector Sanjuan <hector@protocol.ai>
License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
2019-02-20 11:07:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// UnpinPath resolves path into a cid and runs Cluster.Unpin().
|
2019-05-04 20:36:10 +00:00
|
|
|
func (rpcapi *ClusterRPCAPI) UnpinPath(ctx context.Context, in *api.PinPath, out *api.Pin) error {
|
2019-03-01 17:46:27 +00:00
|
|
|
pin, err := rpcapi.c.UnpinPath(ctx, in.Path)
|
2019-02-27 18:43:29 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-02-27 17:04:35 +00:00
|
|
|
*out = *pin
|
2019-02-27 18:43:29 +00:00
|
|
|
return nil
|
Add PinPath/UnpinPath support.
Squashed commit of the following:
commit 38cf569c6aed77c46ee4e0f8baa4d1a9daf8f03e
Merge: d125f69 aaada42
Author: Hector Sanjuan <hsanjuan@users.noreply.github.com>
Date: Wed Feb 20 11:02:00 2019 +0000
Merge pull request #634 from ipfs/issue_450
Support PinPath, UnpinPath (resolve before pinning)
commit aaada42054e1f1c7b2abb1270859d0de41a0e5d8
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 19 22:16:25 2019 +0530
formatResponse accepts api.Pin and not api.PinSerial
commit b5da4bea045865814cc422da71827b44ddd44b90
Merge: ba59036 cc8dd7e
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 19 21:36:46 2019 +0530
Merge branch 'master' into issue_450
commit ba5903649c1df1dba20f4d6f7e3573d6fe24921f
Merge: f002914 d59880c
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Mon Feb 18 08:41:11 2019 +0530
Merge branch 'issue_450' of github.com:ipfs/ipfs-cluster into issue_450
commit f00291494c0c02621c2296cbb7ac71e4c23aa9ec
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Mon Feb 18 08:31:39 2019 +0530
PinPath: more improvements
Added tracing for new methods
commit d59880c338eaa8214fe06b4f930a540793d78407
Merge: 0ca4c7c b4f0eb3
Author: Hector Sanjuan <hsanjuan@users.noreply.github.com>
Date: Wed Feb 13 15:22:49 2019 +0000
Merge branch 'master' into issue_450
commit 0ca4c7c3b0670ed9c8279f8274d36e3485c10030
Merge: d35017a ecef9ea
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 12 13:10:13 2019 +0530
Merge branch 'master' into issue_450
commit d35017a8de91ca9fc9a9a047c48c75134cee9f98
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 12 13:07:25 2019 +0530
PinPath: more improvements
- Worth having `PinOptions` as a separate field in the struct and
constructing the query in the test with ToQuery()
- sharness: "intialization" line can be placed outside the tests at
the top
commit 68e3b90417ffbad89d41a70ac81d85f9037f8848
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Sun Feb 10 21:43:50 2019 +0530
Using if-continue pattern instead of if-else
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 3c29799f3b85be328b27508332ab92049d8b82f3
Merge: 956790b 4324889
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Thu Feb 7 10:25:52 2019 +0530
Merge branch 'master' into issue_450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 956790b381db9858e4194f983e898b07dc51ba66
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 21:11:20 2019 +0530
Removing resolved path
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 7191cc46cedfbec116a9746937e28881b50ca044
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 16:45:07 2019 +0530
Fix go vet
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit f8b3d5b63b1b7569e2a3e0d82894fd4491c246c4
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 16:07:03 2019 +0530
Fixed linting error
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 23c57eb467755a1f21387a1615a7f34e97348053
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 09:20:41 2019 +0530
Fixed tests
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 0caedd94aefeb3b6649dedc214cb4b849ace2ea4
Merge: 17e555e 5a7ee1d
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 00:07:10 2019 +0530
Merge branch 'master' into issue_450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 17e555e4a7c574413df90aac70c5cc29cab98f54
Author: Hector Sanjuan <code@hector.link>
Date: Tue Feb 5 16:58:50 2019 +0000
PinPath: address some feedback + improvements
* Changed client's Pin() API and PinPath to be consistent
* Added helper methods to turn PinPath to query and back
* Make code and tests build
* Use TestCidResolved everywhere
* Fix cluster.PinPath arguments
* Fix formatting of responses with --no-status
* Make tests readable and call Fatal when needed
* Use a pathTestCases variable
commit f0e7369c47c5ddadc8ed45df5fd2d4d9b2d42b38
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 5 18:34:26 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
Addressed review comments as in
https://github.com/ipfs/ipfs-cluster/pull/634#pullrequestreview-198751932
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit a8b4f181d2d7afed32ee41331dfaab19fd66a173
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 29 22:41:27 2019 +0530
Fixing tests
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit e39b95ca19e4d75506f4f492678245ef13936a44
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 29 14:52:53 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
- PinPath and UnpinPath should return api.Pin
- PinPath should accept pin options
- Removing duplicate logic for Resolve from cluster
- And many other review comments https://github.com/ipfs/ipfs-cluster/pull/634#pullrequestreview-195509504
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit d146075126320896665ba58d337a13789f68ea86
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 23 17:08:41 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
PinPath(in both rest and rpc) should return a serializable struct in the
form `{"\":"Q...cid..string..."}` (as used in "github.com/ipfs/go-cid"
to marshal and unmarshal)
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 1f4869568a8adb450275257154ea3a26d03a30f3
Merge: 7acfd28 a244af9
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 23 07:18:56 2019 +0530
Merge branch 'master' into issue_450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 7acfd282732ddf2282a67d4f9d0170a494eb3ed4
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 22 18:14:32 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
- RPC must always use serializable structs
- In command, just use pin with path as cid is also a valid path
- Addressing many other small review comments as in
https://github.com/ipfs/ipfs-cluster/pull/634#pullrequestreview-192122534
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 36905041e1e3f0b204942030aab3ab7b5b9e4d62
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 16 09:36:42 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
Extra logic for path checking should go into resolve so that it can be
properly reused
Added sharness tests
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 9116bda3534e77bb391d873051bb520a1b01a326
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 16 08:08:07 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
error strings should not be capitalized
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit ca7e61861374f456300a85ddc0374e594f74f963
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 15 23:40:25 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
Tests
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 522fbcd899f01c01680375561a32a87464157c0a
Merge: f1a56ab f7bc468
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 15 10:40:54 2019 +0530
Merge branch 'master' into issue_450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit f1a56ab925fb74c0c44273a4524afa4843cf757f
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Mon Jan 14 20:58:17 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
- IPFS Connector should act as a pure IPFS client, any extra logic
should go to cluster.go
- Use cid.Undef, instead of cid.Cid{}
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit c83b91054f6774f1f9d4930cfc3f1fa28236f57c
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Thu Jan 10 08:57:17 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
- Separate handlers, methods and rpc apis for PinPath and UnpinPath from
Pin and Unpin
- Support ipld paths as well
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 719dff88129366ce3ccb5e04cb6f8082a0915c5c
Merge: 91ceb47 21170c4
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 9 19:38:35 2019 +0530
Merge branch 'issue_450_old' into HEAD
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 91ceb4796259ca7ef2974ec43e6a278a12796b13
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 9 19:36:41 2019 +0530
Revert "WIP: Figure out why test does not impleme"
This reverts commit 28a3a3f25dce6f296c8cbef86221644c099a7e75.
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 28a3a3f25dce6f296c8cbef86221644c099a7e75
Author: cd10012 <ced361@nyu.edu>
Date: Tue Jul 24 23:23:10 2018 -0400
WIP: Figure out why test does not implement IPFSConnector interface...
License: MIT
Signed-off-by: cd10012 <ced361@nyu.edu>
commit 21170c48e77e69583db64544b08120a9baf40d8d
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 8 10:37:59 2019 +0530
Support PinPath, UnpinPath (resolve before pinning)
This commit adds API support for pinning using path
`POST /pins/<ipfs or ipns path>` and `DELETE /pins/<ipfs or ipns path>`
will resolve the path into a cid and perform perform pinning or
unpinning
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Co-authored-by: Hector Sanjuan <hector@protocol.ai>
License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
2019-02-20 11:07:50 +00:00
|
|
|
}
|
|
|
|
|
2017-04-06 02:27:02 +00:00
|
|
|
// Pins runs Cluster.Pins().
|
2019-05-04 20:36:10 +00:00
|
|
|
func (rpcapi *ClusterRPCAPI) Pins(ctx context.Context, in struct{}, out *[]*api.Pin) error {
|
2019-02-20 14:24:25 +00:00
|
|
|
cidList, err := rpcapi.c.Pins(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-02-27 17:04:35 +00:00
|
|
|
*out = cidList
|
2016-12-23 18:35:37 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-04-06 02:27:02 +00:00
|
|
|
// PinGet runs Cluster.PinGet().
|
2019-05-04 20:36:10 +00:00
|
|
|
func (rpcapi *ClusterRPCAPI) PinGet(ctx context.Context, in cid.Cid, out *api.Pin) error {
|
2019-02-27 17:04:35 +00:00
|
|
|
pin, err := rpcapi.c.PinGet(ctx, in)
|
2019-02-27 18:43:29 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-02-27 17:04:35 +00:00
|
|
|
*out = *pin
|
2019-02-27 18:43:29 +00:00
|
|
|
return nil
|
2017-04-06 02:27:02 +00:00
|
|
|
}
|
|
|
|
|
2016-12-28 15:25:24 +00:00
|
|
|
// Version runs Cluster.Version().
|
2019-05-04 20:36:10 +00:00
|
|
|
func (rpcapi *ClusterRPCAPI) Version(ctx context.Context, in struct{}, out *api.Version) error {
|
2017-02-15 14:16:34 +00:00
|
|
|
*out = api.Version{
|
|
|
|
Version: rpcapi.c.Version(),
|
|
|
|
}
|
2016-12-23 18:35:37 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-01-26 18:59:31 +00:00
|
|
|
// Peers runs Cluster.Peers().
|
2019-05-04 20:36:10 +00:00
|
|
|
func (rpcapi *ClusterRPCAPI) Peers(ctx context.Context, in struct{}, out *[]*api.ID) error {
|
2019-02-27 17:04:35 +00:00
|
|
|
*out = rpcapi.c.Peers(ctx)
|
2016-12-23 18:35:37 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-01-30 12:12:25 +00:00
|
|
|
// PeerAdd runs Cluster.PeerAdd().
|
2019-05-04 20:36:10 +00:00
|
|
|
func (rpcapi *ClusterRPCAPI) PeerAdd(ctx context.Context, in peer.ID, out *api.ID) error {
|
2019-02-27 17:04:35 +00:00
|
|
|
id, err := rpcapi.c.PeerAdd(ctx, in)
|
2019-02-27 18:43:29 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-02-27 17:04:35 +00:00
|
|
|
*out = *id
|
2019-02-27 18:43:29 +00:00
|
|
|
return nil
|
2017-01-30 12:12:25 +00:00
|
|
|
}
|
|
|
|
|
2017-10-13 21:12:46 +00:00
|
|
|
// ConnectGraph runs Cluster.GetConnectGraph().
|
2019-05-04 20:36:10 +00:00
|
|
|
func (rpcapi *ClusterRPCAPI) ConnectGraph(ctx context.Context, in struct{}, out *api.ConnectGraph) error {
|
2017-10-13 21:12:46 +00:00
|
|
|
graph, err := rpcapi.c.ConnectGraph()
|
2019-02-27 18:43:29 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-02-27 17:04:35 +00:00
|
|
|
*out = graph
|
2019-02-27 18:43:29 +00:00
|
|
|
return nil
|
2017-10-13 21:12:46 +00:00
|
|
|
}
|
|
|
|
|
2017-01-30 12:12:25 +00:00
|
|
|
// PeerRemove runs Cluster.PeerRm().
|
2019-05-04 20:36:10 +00:00
|
|
|
func (rpcapi *ClusterRPCAPI) PeerRemove(ctx context.Context, in peer.ID, out *struct{}) error {
|
2018-06-27 04:03:15 +00:00
|
|
|
return rpcapi.c.PeerRemove(ctx, in)
|
2017-01-30 12:12:25 +00:00
|
|
|
}
|
|
|
|
|
2017-02-02 22:52:06 +00:00
|
|
|
// Join runs Cluster.Join().
|
2019-05-04 20:36:10 +00:00
|
|
|
func (rpcapi *ClusterRPCAPI) Join(ctx context.Context, in api.Multiaddr, out *struct{}) error {
|
2019-02-27 18:43:29 +00:00
|
|
|
return rpcapi.c.Join(ctx, in.Value())
|
2017-02-02 22:52:06 +00:00
|
|
|
}
|
|
|
|
|
2017-01-25 18:38:23 +00:00
|
|
|
// StatusAll runs Cluster.StatusAll().
|
2019-05-04 20:36:10 +00:00
|
|
|
func (rpcapi *ClusterRPCAPI) StatusAll(ctx context.Context, in struct{}, out *[]*api.GlobalPinInfo) error {
|
2018-06-27 04:03:15 +00:00
|
|
|
pinfos, err := rpcapi.c.StatusAll(ctx)
|
2019-02-27 18:43:29 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-02-27 17:04:35 +00:00
|
|
|
*out = pinfos
|
2019-02-27 18:43:29 +00:00
|
|
|
return nil
|
2016-12-23 18:35:37 +00:00
|
|
|
}
|
|
|
|
|
2017-12-01 11:56:26 +00:00
|
|
|
// StatusAllLocal runs Cluster.StatusAllLocal().
|
2019-05-04 20:36:10 +00:00
|
|
|
func (rpcapi *ClusterRPCAPI) StatusAllLocal(ctx context.Context, in struct{}, out *[]*api.PinInfo) error {
|
2018-06-27 04:03:15 +00:00
|
|
|
pinfos := rpcapi.c.StatusAllLocal(ctx)
|
2019-02-27 17:04:35 +00:00
|
|
|
*out = pinfos
|
2017-12-01 11:56:26 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-01-25 18:38:23 +00:00
|
|
|
// Status runs Cluster.Status().
|
2019-05-04 20:36:10 +00:00
|
|
|
func (rpcapi *ClusterRPCAPI) Status(ctx context.Context, in cid.Cid, out *api.GlobalPinInfo) error {
|
2019-02-27 17:04:35 +00:00
|
|
|
pinfo, err := rpcapi.c.Status(ctx, in)
|
2019-02-27 18:43:29 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-02-27 17:04:35 +00:00
|
|
|
*out = *pinfo
|
2019-02-27 18:43:29 +00:00
|
|
|
return nil
|
2016-12-23 18:35:37 +00:00
|
|
|
}
|
|
|
|
|
2017-12-01 11:56:26 +00:00
|
|
|
// StatusLocal runs Cluster.StatusLocal().
|
2019-05-04 20:36:10 +00:00
|
|
|
func (rpcapi *ClusterRPCAPI) StatusLocal(ctx context.Context, in cid.Cid, out *api.PinInfo) error {
|
2019-02-27 17:04:35 +00:00
|
|
|
pinfo := rpcapi.c.StatusLocal(ctx, in)
|
|
|
|
*out = *pinfo
|
2017-12-01 11:56:26 +00:00
|
|
|
return nil
|
2016-12-23 18:35:37 +00:00
|
|
|
}
|
|
|
|
|
2019-08-21 05:49:07 +00:00
|
|
|
// RecoverAll runs Cluster.RecoverAll().
|
|
|
|
func (rpcapi *ClusterRPCAPI) RecoverAll(ctx context.Context, in struct{}, out *[]*api.GlobalPinInfo) error {
|
|
|
|
pinfos, err := rpcapi.c.RecoverAll(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
*out = pinfos
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-12-01 11:56:26 +00:00
|
|
|
// RecoverAllLocal runs Cluster.RecoverAllLocal().
|
2019-05-04 20:36:10 +00:00
|
|
|
func (rpcapi *ClusterRPCAPI) RecoverAllLocal(ctx context.Context, in struct{}, out *[]*api.PinInfo) error {
|
2018-06-27 04:03:15 +00:00
|
|
|
pinfos, err := rpcapi.c.RecoverAllLocal(ctx)
|
2019-02-27 18:43:29 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-02-27 17:04:35 +00:00
|
|
|
*out = pinfos
|
2019-02-27 18:43:29 +00:00
|
|
|
return nil
|
2016-12-23 18:35:37 +00:00
|
|
|
}
|
|
|
|
|
2017-01-25 18:38:23 +00:00
|
|
|
// Recover runs Cluster.Recover().
|
2019-05-04 20:36:10 +00:00
|
|
|
func (rpcapi *ClusterRPCAPI) Recover(ctx context.Context, in cid.Cid, out *api.GlobalPinInfo) error {
|
2019-02-27 17:04:35 +00:00
|
|
|
pinfo, err := rpcapi.c.Recover(ctx, in)
|
2019-02-27 18:43:29 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-02-27 17:04:35 +00:00
|
|
|
*out = *pinfo
|
2019-02-27 18:43:29 +00:00
|
|
|
return nil
|
2017-01-25 18:38:23 +00:00
|
|
|
}
|
|
|
|
|
2017-11-30 00:53:31 +00:00
|
|
|
// RecoverLocal runs Cluster.RecoverLocal().
|
2019-05-04 20:36:10 +00:00
|
|
|
func (rpcapi *ClusterRPCAPI) RecoverLocal(ctx context.Context, in cid.Cid, out *api.PinInfo) error {
|
2019-02-27 17:04:35 +00:00
|
|
|
pinfo, err := rpcapi.c.RecoverLocal(ctx, in)
|
2019-02-27 18:43:29 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-02-27 17:04:35 +00:00
|
|
|
*out = *pinfo
|
2019-02-27 18:43:29 +00:00
|
|
|
return nil
|
2017-11-30 00:53:31 +00:00
|
|
|
}
|
|
|
|
|
2018-08-08 19:29:21 +00:00
|
|
|
// BlockAllocate returns allocations for blocks. This is used in the adders.
|
2018-08-08 19:11:26 +00:00
|
|
|
// It's different from pin allocations when ReplicationFactor < 0.
|
2019-05-04 20:36:10 +00:00
|
|
|
func (rpcapi *ClusterRPCAPI) BlockAllocate(ctx context.Context, in *api.Pin, out *[]peer.ID) error {
|
2019-07-30 17:42:26 +00:00
|
|
|
if rpcapi.c.config.FollowerMode {
|
|
|
|
return errFollowerMode
|
|
|
|
}
|
|
|
|
|
2020-04-20 13:26:03 +00:00
|
|
|
existing, err := rpcapi.c.PinGet(ctx, in.Cid)
|
|
|
|
if err != nil && err != state.ErrNotFound {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = rpcapi.c.setupPin(ctx, in, existing)
|
2018-07-04 16:30:24 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-08-08 19:11:26 +00:00
|
|
|
|
|
|
|
// Return the current peer list.
|
2019-02-27 17:04:35 +00:00
|
|
|
if in.ReplicationFactorMin < 0 {
|
2018-09-26 11:42:20 +00:00
|
|
|
// Returned metrics are Valid and belong to current
|
|
|
|
// Cluster peers.
|
2018-06-27 04:03:15 +00:00
|
|
|
metrics := rpcapi.c.monitor.LatestMetrics(ctx, pingMetricName)
|
2020-04-14 17:58:00 +00:00
|
|
|
peers := make([]peer.ID, len(metrics))
|
2018-09-26 11:42:20 +00:00
|
|
|
for i, m := range metrics {
|
2019-02-27 17:04:35 +00:00
|
|
|
peers[i] = m.Peer
|
2018-08-08 19:11:26 +00:00
|
|
|
}
|
2018-09-26 11:42:20 +00:00
|
|
|
|
2018-10-23 18:21:27 +00:00
|
|
|
*out = peers
|
2018-08-08 19:11:26 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-07-04 16:30:24 +00:00
|
|
|
allocs, err := rpcapi.c.allocate(
|
2018-06-27 04:03:15 +00:00
|
|
|
ctx,
|
2019-02-27 17:04:35 +00:00
|
|
|
in.Cid,
|
2020-04-20 13:26:03 +00:00
|
|
|
existing,
|
2019-02-27 17:04:35 +00:00
|
|
|
in.ReplicationFactorMin,
|
|
|
|
in.ReplicationFactorMax,
|
2019-08-31 10:54:20 +00:00
|
|
|
[]peer.ID{}, // blacklist
|
|
|
|
in.UserAllocations, // prio list
|
2018-07-04 16:30:24 +00:00
|
|
|
)
|
2018-07-23 13:56:46 +00:00
|
|
|
|
2018-07-04 16:30:24 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-02-27 17:04:35 +00:00
|
|
|
*out = allocs
|
2018-07-04 16:30:24 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-10-22 05:40:32 +00:00
|
|
|
// RepoGC performs garbage collection sweep on all peers' repos.
|
|
|
|
func (rpcapi *ClusterRPCAPI) RepoGC(ctx context.Context, in struct{}, out *api.GlobalRepoGC) error {
|
|
|
|
res, err := rpcapi.c.RepoGC(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
*out = *res
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// RepoGCLocal performs garbage collection sweep only on the local peer's IPFS daemon.
|
|
|
|
func (rpcapi *ClusterRPCAPI) RepoGCLocal(ctx context.Context, in struct{}, out *api.RepoGC) error {
|
|
|
|
res, err := rpcapi.c.RepoGCLocal(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
*out = *res
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-08-07 09:49:31 +00:00
|
|
|
// SendInformerMetric runs Cluster.sendInformerMetric().
|
2019-05-04 20:36:10 +00:00
|
|
|
func (rpcapi *ClusterRPCAPI) SendInformerMetric(ctx context.Context, in struct{}, out *api.Metric) error {
|
2019-12-05 14:08:43 +00:00
|
|
|
m, err := rpcapi.c.sendInformerMetric(ctx, rpcapi.c.informers[0])
|
2019-02-27 18:43:29 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-02-27 17:04:35 +00:00
|
|
|
*out = *m
|
2019-02-27 18:43:29 +00:00
|
|
|
return nil
|
2018-08-07 09:49:31 +00:00
|
|
|
}
|
|
|
|
|
2019-12-05 14:08:43 +00:00
|
|
|
// SendInformersMetrics runs Cluster.sendInformerMetric() on all informers.
|
|
|
|
func (rpcapi *ClusterRPCAPI) SendInformersMetrics(ctx context.Context, in struct{}, out *[]*api.Metric) error {
|
|
|
|
var metrics []*api.Metric
|
|
|
|
metrics, err := rpcapi.c.sendInformersMetrics(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
*out = metrics
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-12-12 18:51:28 +00:00
|
|
|
// Alerts runs Cluster.Alerts().
|
2021-01-13 21:09:21 +00:00
|
|
|
func (rpcapi *ClusterRPCAPI) Alerts(ctx context.Context, in struct{}, out *[]api.Alert) error {
|
2019-12-12 18:51:28 +00:00
|
|
|
alerts := rpcapi.c.Alerts()
|
|
|
|
*out = alerts
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-12-23 18:35:37 +00:00
|
|
|
/*
|
|
|
|
Tracker component methods
|
|
|
|
*/
|
|
|
|
|
2016-12-28 15:25:24 +00:00
|
|
|
// Track runs PinTracker.Track().
|
2019-05-04 20:36:10 +00:00
|
|
|
func (rpcapi *PinTrackerRPCAPI) Track(ctx context.Context, in *api.Pin, out *struct{}) error {
|
2018-06-27 04:03:15 +00:00
|
|
|
ctx, span := trace.StartSpan(ctx, "rpc/tracker/Track")
|
|
|
|
defer span.End()
|
2019-05-04 20:36:10 +00:00
|
|
|
return rpcapi.tracker.Track(ctx, in)
|
2016-12-23 18:35:37 +00:00
|
|
|
}
|
|
|
|
|
2016-12-28 15:25:24 +00:00
|
|
|
// Untrack runs PinTracker.Untrack().
|
2019-05-04 20:36:10 +00:00
|
|
|
func (rpcapi *PinTrackerRPCAPI) Untrack(ctx context.Context, in *api.Pin, out *struct{}) error {
|
2018-06-27 04:03:15 +00:00
|
|
|
ctx, span := trace.StartSpan(ctx, "rpc/tracker/Untrack")
|
|
|
|
defer span.End()
|
2019-05-04 20:36:10 +00:00
|
|
|
return rpcapi.tracker.Untrack(ctx, in.Cid)
|
2016-12-23 18:35:37 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
// StatusAll runs PinTracker.StatusAll().
|
|
|
|
func (rpcapi *PinTrackerRPCAPI) StatusAll(ctx context.Context, in struct{}, out *[]*api.PinInfo) error {
|
2018-06-27 04:03:15 +00:00
|
|
|
ctx, span := trace.StartSpan(ctx, "rpc/tracker/StatusAll")
|
|
|
|
defer span.End()
|
2019-05-04 20:36:10 +00:00
|
|
|
*out = rpcapi.tracker.StatusAll(ctx)
|
2016-12-23 18:35:37 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
// Status runs PinTracker.Status().
|
|
|
|
func (rpcapi *PinTrackerRPCAPI) Status(ctx context.Context, in cid.Cid, out *api.PinInfo) error {
|
2018-06-27 04:03:15 +00:00
|
|
|
ctx, span := trace.StartSpan(ctx, "rpc/tracker/Status")
|
|
|
|
defer span.End()
|
2019-05-04 20:36:10 +00:00
|
|
|
pinfo := rpcapi.tracker.Status(ctx, in)
|
2019-02-27 17:04:35 +00:00
|
|
|
*out = *pinfo
|
2016-12-23 18:35:37 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
// RecoverAll runs PinTracker.RecoverAll().f
|
|
|
|
func (rpcapi *PinTrackerRPCAPI) RecoverAll(ctx context.Context, in struct{}, out *[]*api.PinInfo) error {
|
2018-06-27 04:03:15 +00:00
|
|
|
ctx, span := trace.StartSpan(ctx, "rpc/tracker/RecoverAll")
|
|
|
|
defer span.End()
|
2019-05-04 20:36:10 +00:00
|
|
|
pinfos, err := rpcapi.tracker.RecoverAll(ctx)
|
2019-02-27 18:43:29 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-02-27 17:04:35 +00:00
|
|
|
*out = pinfos
|
2019-02-27 18:43:29 +00:00
|
|
|
return nil
|
2017-12-01 11:56:26 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
// Recover runs PinTracker.Recover().
|
|
|
|
func (rpcapi *PinTrackerRPCAPI) Recover(ctx context.Context, in cid.Cid, out *api.PinInfo) error {
|
2018-06-27 04:03:15 +00:00
|
|
|
ctx, span := trace.StartSpan(ctx, "rpc/tracker/Recover")
|
|
|
|
defer span.End()
|
2019-05-04 20:36:10 +00:00
|
|
|
pinfo, err := rpcapi.tracker.Recover(ctx, in)
|
2019-02-27 17:04:35 +00:00
|
|
|
*out = *pinfo
|
2017-01-25 18:38:23 +00:00
|
|
|
return err
|
|
|
|
}
|
2016-12-23 18:35:37 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
IPFS Connector component methods
|
|
|
|
*/
|
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
// Pin runs IPFSConnector.Pin().
|
|
|
|
func (rpcapi *IPFSConnectorRPCAPI) Pin(ctx context.Context, in *api.Pin, out *struct{}) error {
|
2018-06-27 04:03:15 +00:00
|
|
|
ctx, span := trace.StartSpan(ctx, "rpc/ipfsconn/IPFSPin")
|
|
|
|
defer span.End()
|
2019-07-12 14:40:29 +00:00
|
|
|
return rpcapi.ipfs.Pin(ctx, in)
|
2016-12-23 18:35:37 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
// Unpin runs IPFSConnector.Unpin().
|
|
|
|
func (rpcapi *IPFSConnectorRPCAPI) Unpin(ctx context.Context, in *api.Pin, out *struct{}) error {
|
|
|
|
return rpcapi.ipfs.Unpin(ctx, in.Cid)
|
2016-12-23 18:35:37 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
// PinLsCid runs IPFSConnector.PinLsCid().
|
2020-04-20 14:21:27 +00:00
|
|
|
func (rpcapi *IPFSConnectorRPCAPI) PinLsCid(ctx context.Context, in *api.Pin, out *api.IPFSPinStatus) error {
|
2019-05-04 20:36:10 +00:00
|
|
|
b, err := rpcapi.ipfs.PinLsCid(ctx, in)
|
2019-02-27 18:43:29 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2016-12-23 18:35:37 +00:00
|
|
|
*out = b
|
2019-02-27 18:43:29 +00:00
|
|
|
return nil
|
2016-12-23 18:35:37 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
// PinLs runs IPFSConnector.PinLs().
|
|
|
|
func (rpcapi *IPFSConnectorRPCAPI) PinLs(ctx context.Context, in string, out *map[string]api.IPFSPinStatus) error {
|
|
|
|
m, err := rpcapi.ipfs.PinLs(ctx, in)
|
2019-02-27 18:43:29 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-01-25 17:07:19 +00:00
|
|
|
*out = m
|
2019-02-27 18:43:29 +00:00
|
|
|
return nil
|
2017-01-25 17:07:19 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
// ConfigKey runs IPFSConnector.ConfigKey().
|
|
|
|
func (rpcapi *IPFSConnectorRPCAPI) ConfigKey(ctx context.Context, in string, out *interface{}) error {
|
|
|
|
res, err := rpcapi.ipfs.ConfigKey(in)
|
2019-02-27 18:43:29 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-03-27 13:07:12 +00:00
|
|
|
*out = res
|
2019-02-27 18:43:29 +00:00
|
|
|
return nil
|
2017-03-27 13:07:12 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
// RepoStat runs IPFSConnector.RepoStat().
|
|
|
|
func (rpcapi *IPFSConnectorRPCAPI) RepoStat(ctx context.Context, in struct{}, out *api.IPFSRepoStat) error {
|
|
|
|
res, err := rpcapi.ipfs.RepoStat(ctx)
|
2019-02-27 17:04:35 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
*out = *res
|
2017-03-27 13:07:12 +00:00
|
|
|
return err
|
2017-03-23 18:34:33 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
// SwarmPeers runs IPFSConnector.SwarmPeers().
|
|
|
|
func (rpcapi *IPFSConnectorRPCAPI) SwarmPeers(ctx context.Context, in struct{}, out *[]peer.ID) error {
|
|
|
|
res, err := rpcapi.ipfs.SwarmPeers(ctx)
|
2019-02-27 17:04:35 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
*out = res
|
|
|
|
return nil
|
2017-10-13 21:12:46 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
// BlockPut runs IPFSConnector.BlockPut().
|
|
|
|
func (rpcapi *IPFSConnectorRPCAPI) BlockPut(ctx context.Context, in *api.NodeWithMeta, out *struct{}) error {
|
|
|
|
return rpcapi.ipfs.BlockPut(ctx, in)
|
2018-02-09 05:23:24 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
// BlockGet runs IPFSConnector.BlockGet().
|
|
|
|
func (rpcapi *IPFSConnectorRPCAPI) BlockGet(ctx context.Context, in cid.Cid, out *[]byte) error {
|
|
|
|
res, err := rpcapi.ipfs.BlockGet(ctx, in)
|
2019-02-27 17:04:35 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-03-18 19:29:02 +00:00
|
|
|
*out = res
|
2019-02-27 17:04:35 +00:00
|
|
|
return nil
|
2018-03-18 19:29:02 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
// Resolve runs IPFSConnector.Resolve().
|
|
|
|
func (rpcapi *IPFSConnectorRPCAPI) Resolve(ctx context.Context, in string, out *cid.Cid) error {
|
|
|
|
c, err := rpcapi.ipfs.Resolve(ctx, in)
|
2019-04-29 14:36:40 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
*out = c
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-12-23 18:35:37 +00:00
|
|
|
/*
|
|
|
|
Consensus component methods
|
|
|
|
*/
|
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
// LogPin runs Consensus.LogPin().
|
|
|
|
func (rpcapi *ConsensusRPCAPI) LogPin(ctx context.Context, in *api.Pin, out *struct{}) error {
|
2018-06-27 04:03:15 +00:00
|
|
|
ctx, span := trace.StartSpan(ctx, "rpc/consensus/LogPin")
|
|
|
|
defer span.End()
|
2019-05-04 20:36:10 +00:00
|
|
|
return rpcapi.cons.LogPin(ctx, in)
|
2016-12-23 18:35:37 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
// LogUnpin runs Consensus.LogUnpin().
|
|
|
|
func (rpcapi *ConsensusRPCAPI) LogUnpin(ctx context.Context, in *api.Pin, out *struct{}) error {
|
2018-06-27 04:03:15 +00:00
|
|
|
ctx, span := trace.StartSpan(ctx, "rpc/consensus/LogUnpin")
|
|
|
|
defer span.End()
|
2019-05-04 20:36:10 +00:00
|
|
|
return rpcapi.cons.LogUnpin(ctx, in)
|
2016-12-23 18:35:37 +00:00
|
|
|
}
|
2017-01-30 12:12:25 +00:00
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
// AddPeer runs Consensus.AddPeer().
|
|
|
|
func (rpcapi *ConsensusRPCAPI) AddPeer(ctx context.Context, in peer.ID, out *struct{}) error {
|
2018-06-27 04:03:15 +00:00
|
|
|
ctx, span := trace.StartSpan(ctx, "rpc/consensus/AddPeer")
|
|
|
|
defer span.End()
|
2019-05-04 20:36:10 +00:00
|
|
|
return rpcapi.cons.AddPeer(ctx, in)
|
2017-02-02 22:52:06 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
// RmPeer runs Consensus.RmPeer().
|
|
|
|
func (rpcapi *ConsensusRPCAPI) RmPeer(ctx context.Context, in peer.ID, out *struct{}) error {
|
2018-06-27 04:03:15 +00:00
|
|
|
ctx, span := trace.StartSpan(ctx, "rpc/consensus/RmPeer")
|
|
|
|
defer span.End()
|
2019-05-04 20:36:10 +00:00
|
|
|
return rpcapi.cons.RmPeer(ctx, in)
|
2017-02-02 22:52:06 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
// Peers runs Consensus.Peers().
|
|
|
|
func (rpcapi *ConsensusRPCAPI) Peers(ctx context.Context, in struct{}, out *[]peer.ID) error {
|
|
|
|
peers, err := rpcapi.cons.Peers(ctx)
|
2019-02-27 17:04:35 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-11-14 11:26:42 +00:00
|
|
|
*out = peers
|
2019-02-27 17:04:35 +00:00
|
|
|
return nil
|
2017-11-14 11:26:42 +00:00
|
|
|
}
|
|
|
|
|
2017-02-13 15:46:53 +00:00
|
|
|
/*
|
|
|
|
PeerMonitor
|
|
|
|
*/
|
|
|
|
|
2019-05-04 20:36:10 +00:00
|
|
|
// LatestMetrics runs PeerMonitor.LatestMetrics().
|
|
|
|
func (rpcapi *PeerMonitorRPCAPI) LatestMetrics(ctx context.Context, in string, out *[]*api.Metric) error {
|
|
|
|
*out = rpcapi.mon.LatestMetrics(ctx, in)
|
2017-02-13 15:46:53 +00:00
|
|
|
return nil
|
|
|
|
}
|
2019-10-24 14:37:26 +00:00
|
|
|
|
|
|
|
// MetricNames runs PeerMonitor.MetricNames().
|
|
|
|
func (rpcapi *PeerMonitorRPCAPI) MetricNames(ctx context.Context, in struct{}, out *[]string) error {
|
|
|
|
*out = rpcapi.mon.MetricNames(ctx)
|
|
|
|
return nil
|
|
|
|
}
|