2017-02-08 17:04:08 +00:00
|
|
|
// Package api holds declarations for types used in ipfs-cluster APIs to make
|
|
|
|
// them re-usable across differen tools. This include RPC API "Serial[izable]"
|
|
|
|
// versions for types. The Go API uses natives types, while RPC API,
|
2017-12-06 14:00:01 +00:00
|
|
|
// REST APIs etc use serializable types (i.e. json format). Conversion methods
|
2017-02-08 17:04:08 +00:00
|
|
|
// exists between types.
|
|
|
|
//
|
|
|
|
// Note that all conversion methods ignore any parsing errors. All values must
|
|
|
|
// be validated first before initializing any of the types defined here.
|
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
2018-10-23 18:21:27 +00:00
|
|
|
"encoding/json"
|
2017-12-08 14:39:30 +00:00
|
|
|
"fmt"
|
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
|
|
|
"net/url"
|
2018-01-16 10:21:34 +00:00
|
|
|
"sort"
|
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
|
|
|
"strconv"
|
2018-01-16 10:21:34 +00:00
|
|
|
"strings"
|
2017-02-08 17:04:08 +00:00
|
|
|
"time"
|
|
|
|
|
2022-06-15 09:19:17 +00:00
|
|
|
pb "github.com/ipfs-cluster/ipfs-cluster/api/pb"
|
2019-02-19 17:59:46 +00:00
|
|
|
|
2017-02-08 17:04:08 +00:00
|
|
|
cid "github.com/ipfs/go-cid"
|
2020-03-13 20:40:02 +00:00
|
|
|
logging "github.com/ipfs/go-log/v2"
|
2022-09-06 14:57:17 +00:00
|
|
|
peer "github.com/libp2p/go-libp2p/core/peer"
|
|
|
|
protocol "github.com/libp2p/go-libp2p/core/protocol"
|
2019-02-27 17:04:35 +00:00
|
|
|
multiaddr "github.com/multiformats/go-multiaddr"
|
2017-12-07 22:59:24 +00:00
|
|
|
|
|
|
|
// needed to parse /ws multiaddresses
|
2022-06-20 16:23:50 +00:00
|
|
|
_ "github.com/libp2p/go-libp2p/p2p/transport/websocket"
|
2018-03-16 12:37:32 +00:00
|
|
|
// needed to parse /dns* multiaddresses
|
2017-12-07 22:59:24 +00:00
|
|
|
_ "github.com/multiformats/go-multiaddr-dns"
|
2019-06-14 10:41:11 +00:00
|
|
|
|
2019-11-05 09:11:50 +00:00
|
|
|
"github.com/pkg/errors"
|
2020-04-14 18:41:43 +00:00
|
|
|
proto "google.golang.org/protobuf/proto"
|
2017-02-08 17:04:08 +00:00
|
|
|
)
|
|
|
|
|
2017-12-07 22:59:24 +00:00
|
|
|
var logger = logging.Logger("apitypes")
|
|
|
|
|
2019-09-18 16:05:55 +00:00
|
|
|
var unixZero = time.Unix(0, 0)
|
|
|
|
|
2019-01-07 18:45:07 +00:00
|
|
|
func init() {
|
|
|
|
// intialize trackerStatusString
|
|
|
|
stringTrackerStatus = make(map[string]TrackerStatus)
|
|
|
|
for k, v := range trackerStatusString {
|
|
|
|
stringTrackerStatus[v] = k
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-08 17:04:08 +00:00
|
|
|
// TrackerStatus values
|
|
|
|
const (
|
2019-01-07 18:45:07 +00:00
|
|
|
// IPFSStatus should never take this value.
|
|
|
|
// When used as a filter. It means "all".
|
|
|
|
TrackerStatusUndefined TrackerStatus = 0
|
2017-02-08 17:04:08 +00:00
|
|
|
// The cluster node is offline or not responding
|
2019-01-07 18:45:07 +00:00
|
|
|
TrackerStatusClusterError TrackerStatus = 1 << iota
|
2017-02-08 17:04:08 +00:00
|
|
|
// An error occurred pinning
|
|
|
|
TrackerStatusPinError
|
|
|
|
// An error occurred unpinning
|
|
|
|
TrackerStatusUnpinError
|
|
|
|
// The IPFS daemon has pinned the item
|
|
|
|
TrackerStatusPinned
|
|
|
|
// The IPFS daemon is currently pinning the item
|
|
|
|
TrackerStatusPinning
|
|
|
|
// The IPFS daemon is currently unpinning the item
|
|
|
|
TrackerStatusUnpinning
|
|
|
|
// The IPFS daemon is not pinning the item
|
|
|
|
TrackerStatusUnpinned
|
2018-04-18 04:53:41 +00:00
|
|
|
// The IPFS daemon is not pinning the item but it is being tracked
|
2017-02-13 15:46:53 +00:00
|
|
|
TrackerStatusRemote
|
2018-04-18 04:53:41 +00:00
|
|
|
// The item has been queued for pinning on the IPFS daemon
|
|
|
|
TrackerStatusPinQueued
|
|
|
|
// The item has been queued for unpinning on the IPFS daemon
|
|
|
|
TrackerStatusUnpinQueued
|
2018-03-18 19:29:02 +00:00
|
|
|
// The IPFS daemon is not pinning the item through this cid but it is
|
|
|
|
// tracked in a cluster dag
|
|
|
|
TrackerStatusSharded
|
2021-07-04 21:40:15 +00:00
|
|
|
// The item is in the state and should be pinned, but
|
|
|
|
// it is however not pinned and not queued/pinning.
|
|
|
|
TrackerStatusUnexpectedlyUnpinned
|
2017-02-08 17:04:08 +00:00
|
|
|
)
|
|
|
|
|
2019-01-05 09:10:54 +00:00
|
|
|
// Composite TrackerStatus.
|
2019-01-04 17:57:26 +00:00
|
|
|
const (
|
|
|
|
TrackerStatusError = TrackerStatusClusterError | TrackerStatusPinError | TrackerStatusUnpinError
|
|
|
|
TrackerStatusQueued = TrackerStatusPinQueued | TrackerStatusUnpinQueued
|
|
|
|
)
|
|
|
|
|
2017-02-08 17:04:08 +00:00
|
|
|
// TrackerStatus represents the status of a tracked Cid in the PinTracker
|
|
|
|
type TrackerStatus int
|
|
|
|
|
|
|
|
var trackerStatusString = map[TrackerStatus]string{
|
2021-07-04 21:40:15 +00:00
|
|
|
TrackerStatusUndefined: "undefined",
|
|
|
|
TrackerStatusClusterError: "cluster_error",
|
|
|
|
TrackerStatusPinError: "pin_error",
|
|
|
|
TrackerStatusUnpinError: "unpin_error",
|
|
|
|
TrackerStatusError: "error",
|
|
|
|
TrackerStatusPinned: "pinned",
|
|
|
|
TrackerStatusPinning: "pinning",
|
|
|
|
TrackerStatusUnpinning: "unpinning",
|
|
|
|
TrackerStatusUnpinned: "unpinned",
|
|
|
|
TrackerStatusRemote: "remote",
|
|
|
|
TrackerStatusPinQueued: "pin_queued",
|
|
|
|
TrackerStatusUnpinQueued: "unpin_queued",
|
|
|
|
TrackerStatusQueued: "queued",
|
|
|
|
TrackerStatusSharded: "sharded",
|
|
|
|
TrackerStatusUnexpectedlyUnpinned: "unexpectedly_unpinned",
|
2017-02-08 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2019-01-07 18:45:07 +00:00
|
|
|
// values autofilled in init()
|
|
|
|
var stringTrackerStatus map[string]TrackerStatus
|
|
|
|
|
2017-02-08 17:04:08 +00:00
|
|
|
// String converts a TrackerStatus into a readable string.
|
2019-01-07 18:45:07 +00:00
|
|
|
// If the given TrackerStatus is a filter (with several
|
|
|
|
// bits set), it will return a comma-separated list.
|
2017-02-08 17:04:08 +00:00
|
|
|
func (st TrackerStatus) String() string {
|
2019-01-07 18:45:07 +00:00
|
|
|
var values []string
|
|
|
|
|
|
|
|
// simple and known composite values
|
|
|
|
if v, ok := trackerStatusString[st]; ok {
|
|
|
|
return v
|
|
|
|
}
|
2017-02-08 17:04:08 +00:00
|
|
|
|
2019-01-07 18:45:07 +00:00
|
|
|
// other filters
|
|
|
|
for k, v := range trackerStatusString {
|
|
|
|
if st&k > 0 {
|
|
|
|
values = append(values, v)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return strings.Join(values, ",")
|
2019-01-05 09:10:54 +00:00
|
|
|
}
|
2019-01-04 17:57:26 +00:00
|
|
|
|
2019-01-05 09:10:54 +00:00
|
|
|
// Match returns true if the tracker status matches the given filter.
|
2019-01-07 18:45:07 +00:00
|
|
|
// For example TrackerStatusPinError will match TrackerStatusPinError
|
2021-07-04 21:40:15 +00:00
|
|
|
// and TrackerStatusError.
|
2019-01-05 09:10:54 +00:00
|
|
|
func (st TrackerStatus) Match(filter TrackerStatus) bool {
|
2021-07-04 21:40:15 +00:00
|
|
|
return filter == TrackerStatusUndefined ||
|
|
|
|
st == TrackerStatusUndefined ||
|
|
|
|
st&filter > 0
|
2019-01-04 17:57:26 +00:00
|
|
|
}
|
|
|
|
|
2019-02-27 17:04:35 +00:00
|
|
|
// MarshalJSON uses the string representation of TrackerStatus for JSON
|
|
|
|
// encoding.
|
|
|
|
func (st TrackerStatus) MarshalJSON() ([]byte, error) {
|
|
|
|
return json.Marshal(st.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalJSON sets a tracker status from its JSON representation.
|
|
|
|
func (st *TrackerStatus) UnmarshalJSON(data []byte) error {
|
|
|
|
var v string
|
|
|
|
err := json.Unmarshal(data, &v)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
*st = TrackerStatusFromString(v)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-02-08 17:04:08 +00:00
|
|
|
// TrackerStatusFromString parses a string and returns the matching
|
2019-01-07 18:45:07 +00:00
|
|
|
// TrackerStatus value. The string can be a comma-separated list
|
|
|
|
// representing a TrackerStatus filter. Unknown status names are
|
|
|
|
// ignored.
|
2017-02-08 17:04:08 +00:00
|
|
|
func TrackerStatusFromString(str string) TrackerStatus {
|
2019-01-07 18:45:07 +00:00
|
|
|
values := strings.Split(strings.Replace(str, " ", "", -1), ",")
|
|
|
|
var status TrackerStatus
|
|
|
|
for _, v := range values {
|
|
|
|
st, ok := stringTrackerStatus[v]
|
|
|
|
if ok {
|
|
|
|
status |= st
|
2017-02-08 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
2019-01-07 18:45:07 +00:00
|
|
|
return status
|
2017-02-08 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2019-01-07 18:45:07 +00:00
|
|
|
// TrackerStatusAll all known TrackerStatus values.
|
2019-01-05 09:10:54 +00:00
|
|
|
func TrackerStatusAll() []TrackerStatus {
|
2019-01-07 18:45:07 +00:00
|
|
|
var list []TrackerStatus
|
2019-01-05 09:10:54 +00:00
|
|
|
for k := range trackerStatusString {
|
2019-01-07 18:45:07 +00:00
|
|
|
if k != TrackerStatusUndefined {
|
|
|
|
list = append(list, k)
|
2018-12-26 05:45:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-07 18:45:07 +00:00
|
|
|
return list
|
2019-01-04 17:57:26 +00:00
|
|
|
}
|
|
|
|
|
2017-02-08 17:04:08 +00:00
|
|
|
// IPFSPinStatus values
|
2018-07-04 16:30:24 +00:00
|
|
|
// FIXME include maxdepth
|
2017-02-08 17:04:08 +00:00
|
|
|
const (
|
2018-06-01 15:27:21 +00:00
|
|
|
IPFSPinStatusBug IPFSPinStatus = iota
|
2017-02-08 17:04:08 +00:00
|
|
|
IPFSPinStatusError
|
|
|
|
IPFSPinStatusDirect
|
|
|
|
IPFSPinStatusRecursive
|
|
|
|
IPFSPinStatusIndirect
|
|
|
|
IPFSPinStatusUnpinned
|
|
|
|
)
|
|
|
|
|
|
|
|
// IPFSPinStatus represents the status of a pin in IPFS (direct, recursive etc.)
|
|
|
|
type IPFSPinStatus int
|
|
|
|
|
2022-01-28 18:31:13 +00:00
|
|
|
// IPFSPinStatusFromString parses a string and returns the matching
|
2017-02-08 17:04:08 +00:00
|
|
|
// IPFSPinStatus.
|
|
|
|
func IPFSPinStatusFromString(t string) IPFSPinStatus {
|
2019-06-04 18:12:33 +00:00
|
|
|
// Since indirect statuses are of the form "indirect through <cid>"
|
|
|
|
// use a prefix match
|
|
|
|
|
2017-02-08 17:04:08 +00:00
|
|
|
switch {
|
2019-06-04 18:12:33 +00:00
|
|
|
case strings.HasPrefix(t, "indirect"):
|
2017-02-08 17:04:08 +00:00
|
|
|
return IPFSPinStatusIndirect
|
2019-06-04 18:12:33 +00:00
|
|
|
case strings.HasPrefix(t, "recursive"):
|
2018-07-04 16:30:24 +00:00
|
|
|
// FIXME: Maxdepth?
|
|
|
|
return IPFSPinStatusRecursive
|
2017-02-08 17:04:08 +00:00
|
|
|
case t == "direct":
|
|
|
|
return IPFSPinStatusDirect
|
|
|
|
default:
|
|
|
|
return IPFSPinStatusBug
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-22 09:56:16 +00:00
|
|
|
// String returns the string form of the status as written by IPFS.
|
|
|
|
func (ips IPFSPinStatus) String() string {
|
|
|
|
switch ips {
|
|
|
|
case IPFSPinStatusDirect:
|
|
|
|
return "direct"
|
|
|
|
case IPFSPinStatusRecursive:
|
|
|
|
return "recursive"
|
|
|
|
case IPFSPinStatusIndirect:
|
|
|
|
return "indirect"
|
|
|
|
default:
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalJSON parses a status from JSON
|
|
|
|
func (ips *IPFSPinStatus) UnmarshalJSON(b []byte) error {
|
|
|
|
var str string
|
|
|
|
err := json.Unmarshal(b, &str)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
*ips = IPFSPinStatusFromString(str)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// MarshalJSON converts a status to JSON.
|
|
|
|
func (ips IPFSPinStatus) MarshalJSON() ([]byte, error) {
|
|
|
|
return json.Marshal(ips.String())
|
|
|
|
}
|
|
|
|
|
2018-07-04 16:30:24 +00:00
|
|
|
// IsPinned returns true if the item is pinned as expected by the
|
|
|
|
// maxDepth parameter.
|
2020-04-20 13:15:08 +00:00
|
|
|
func (ips IPFSPinStatus) IsPinned(maxDepth PinDepth) bool {
|
2018-07-04 16:30:24 +00:00
|
|
|
switch {
|
|
|
|
case maxDepth < 0:
|
|
|
|
return ips == IPFSPinStatusRecursive
|
|
|
|
case maxDepth == 0:
|
|
|
|
return ips == IPFSPinStatusDirect
|
2018-08-06 12:31:45 +00:00
|
|
|
case maxDepth > 0:
|
|
|
|
// FIXME: when we know how ipfs returns partial pins.
|
2018-07-04 16:30:24 +00:00
|
|
|
return ips == IPFSPinStatusRecursive
|
|
|
|
}
|
|
|
|
return false
|
2017-02-08 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2018-05-25 09:05:35 +00:00
|
|
|
// ToTrackerStatus converts the IPFSPinStatus value to the
|
|
|
|
// appropriate TrackerStatus value.
|
|
|
|
func (ips IPFSPinStatus) ToTrackerStatus() TrackerStatus {
|
|
|
|
return ipfsPinStatus2TrackerStatusMap[ips]
|
|
|
|
}
|
|
|
|
|
|
|
|
var ipfsPinStatus2TrackerStatusMap = map[IPFSPinStatus]TrackerStatus{
|
|
|
|
IPFSPinStatusDirect: TrackerStatusPinned,
|
|
|
|
IPFSPinStatusRecursive: TrackerStatusPinned,
|
|
|
|
IPFSPinStatusIndirect: TrackerStatusUnpinned,
|
|
|
|
IPFSPinStatusUnpinned: TrackerStatusUnpinned,
|
2019-01-07 18:45:07 +00:00
|
|
|
IPFSPinStatusBug: TrackerStatusUndefined,
|
2018-05-25 09:05:35 +00:00
|
|
|
IPFSPinStatusError: TrackerStatusClusterError, //TODO(ajl): check suitability
|
|
|
|
}
|
|
|
|
|
2022-04-07 11:53:30 +00:00
|
|
|
// Cid embeds a cid.Cid with the MarshalJSON/UnmarshalJSON methods overwritten.
|
|
|
|
type Cid struct {
|
|
|
|
cid.Cid
|
|
|
|
}
|
|
|
|
|
|
|
|
// CidUndef is an Undefined CID.
|
|
|
|
var CidUndef = Cid{cid.Undef}
|
|
|
|
|
|
|
|
// NewCid wraps a cid.Cid in a Cid.
|
|
|
|
func NewCid(c cid.Cid) Cid {
|
|
|
|
return Cid{
|
|
|
|
Cid: c,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DecodeCid parses a CID from its string form.
|
|
|
|
func DecodeCid(str string) (Cid, error) {
|
|
|
|
c, err := cid.Decode(str)
|
|
|
|
return Cid{c}, err
|
|
|
|
}
|
2022-03-22 09:56:16 +00:00
|
|
|
|
2022-04-07 11:53:30 +00:00
|
|
|
// CastCid returns a CID from its bytes.
|
|
|
|
func CastCid(bs []byte) (Cid, error) {
|
|
|
|
c, err := cid.Cast(bs)
|
|
|
|
return Cid{c}, err
|
2022-03-22 09:56:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// MarshalJSON marshals a CID as JSON as a normal CID string.
|
|
|
|
func (c Cid) MarshalJSON() ([]byte, error) {
|
2022-04-07 11:53:30 +00:00
|
|
|
if !c.Defined() {
|
|
|
|
return []byte("null"), nil
|
|
|
|
}
|
|
|
|
return []byte(`"` + c.String() + `"`), nil
|
2022-03-22 09:56:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalJSON reads a CID from its representation as JSON string.
|
|
|
|
func (c *Cid) UnmarshalJSON(b []byte) error {
|
2022-04-07 11:53:30 +00:00
|
|
|
if string(b) == "null" {
|
|
|
|
*c = CidUndef
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-03-22 09:56:16 +00:00
|
|
|
var cidStr string
|
|
|
|
err := json.Unmarshal(b, &cidStr)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-04-07 11:53:30 +00:00
|
|
|
cc, err := DecodeCid(cidStr)
|
2022-03-22 09:56:16 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-04-07 11:53:30 +00:00
|
|
|
*c = cc
|
2022-03-22 09:56:16 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-04-07 11:53:30 +00:00
|
|
|
// Equals returns true if two Cids are equal.
|
|
|
|
func (c Cid) Equals(c2 Cid) bool {
|
|
|
|
return c.Cid.Equals(c2.Cid)
|
|
|
|
}
|
|
|
|
|
2022-03-22 09:56:16 +00:00
|
|
|
// IPFSPinInfo represents an IPFS Pin, which only has a CID and type.
|
|
|
|
// Its JSON form is what IPFS returns when querying a pinset.
|
|
|
|
type IPFSPinInfo struct {
|
|
|
|
Cid Cid `json:"Cid" codec:"c"`
|
|
|
|
Type IPFSPinStatus `json:"Type" codec:"t"`
|
|
|
|
}
|
|
|
|
|
2017-02-08 17:04:08 +00:00
|
|
|
// GlobalPinInfo contains cluster-wide status information about a tracked Cid,
|
|
|
|
// indexed by cluster peer.
|
|
|
|
type GlobalPinInfo struct {
|
2022-04-07 11:53:30 +00:00
|
|
|
Cid Cid `json:"cid" codec:"c"`
|
2021-10-07 10:45:36 +00:00
|
|
|
Name string `json:"name" codec:"n"`
|
|
|
|
Allocations []peer.ID `json:"allocations" codec:"a,omitempty"`
|
|
|
|
Origins []Multiaddr `json:"origins" codec:"g,omitempty"`
|
2022-03-14 11:21:08 +00:00
|
|
|
Created time.Time `json:"created" codec:"t,omitempty"`
|
2021-10-07 10:45:36 +00:00
|
|
|
Metadata map[string]string `json:"metadata" codec:"m,omitempty"`
|
|
|
|
|
2019-02-27 17:04:35 +00:00
|
|
|
// https://github.com/golang/go/issues/28827
|
|
|
|
// Peer IDs are of string Kind(). We can't use peer IDs here
|
|
|
|
// as Go ignores TextMarshaler.
|
2022-02-01 23:39:09 +00:00
|
|
|
PeerMap map[string]PinInfoShort `json:"peer_map" codec:"pm,omitempty"`
|
2017-02-08 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2019-05-07 02:04:59 +00:00
|
|
|
// String returns the string representation of a GlobalPinInfo.
|
2022-03-19 01:52:46 +00:00
|
|
|
func (gpi GlobalPinInfo) String() string {
|
2022-02-01 23:39:09 +00:00
|
|
|
str := fmt.Sprintf("Cid: %s\n", gpi.Cid)
|
|
|
|
str = str + "Peers:\n"
|
|
|
|
for pid, p := range gpi.PeerMap {
|
|
|
|
str = str + fmt.Sprintf("\t%s: %+v\n", pid, p)
|
2019-05-07 02:04:59 +00:00
|
|
|
}
|
|
|
|
return str
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:32:28 +00:00
|
|
|
// Add adds a PinInfo object to a GlobalPinInfo
|
2022-02-01 23:39:09 +00:00
|
|
|
func (gpi *GlobalPinInfo) Add(pi PinInfo) {
|
2021-10-07 10:45:36 +00:00
|
|
|
if !gpi.Cid.Defined() || !pi.Status.Match(TrackerStatusClusterError) {
|
2020-05-15 22:32:28 +00:00
|
|
|
gpi.Cid = pi.Cid
|
|
|
|
gpi.Name = pi.Name
|
2021-10-07 10:45:36 +00:00
|
|
|
gpi.Allocations = pi.Allocations
|
|
|
|
gpi.Origins = pi.Origins
|
2022-03-14 11:21:08 +00:00
|
|
|
gpi.Created = pi.Created
|
2021-10-07 10:45:36 +00:00
|
|
|
gpi.Metadata = pi.Metadata
|
2020-05-15 22:32:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if gpi.PeerMap == nil {
|
2022-02-01 23:39:09 +00:00
|
|
|
gpi.PeerMap = make(map[string]PinInfoShort)
|
2020-05-15 22:32:28 +00:00
|
|
|
}
|
|
|
|
|
2022-09-06 14:57:17 +00:00
|
|
|
gpi.PeerMap[pi.Peer.String()] = pi.PinInfoShort
|
2020-05-15 22:32:28 +00:00
|
|
|
}
|
|
|
|
|
2022-03-19 01:52:46 +00:00
|
|
|
// Defined returns if the object is not empty.
|
|
|
|
func (gpi *GlobalPinInfo) Defined() bool {
|
|
|
|
return gpi.Cid.Defined()
|
|
|
|
}
|
|
|
|
|
2022-04-07 11:53:30 +00:00
|
|
|
// Match returns true if one of the statuses in GlobalPinInfo matches
|
2021-10-07 10:45:36 +00:00
|
|
|
// the given filter.
|
2022-03-19 01:52:46 +00:00
|
|
|
func (gpi GlobalPinInfo) Match(filter TrackerStatus) bool {
|
2021-10-07 10:45:36 +00:00
|
|
|
for _, pi := range gpi.PeerMap {
|
|
|
|
if pi.Status.Match(filter) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:32:28 +00:00
|
|
|
// PinInfoShort is a subset of PinInfo which is embedded in GlobalPinInfo
|
|
|
|
// objects and does not carry redundant information as PinInfo would.
|
|
|
|
type PinInfoShort struct {
|
2022-03-10 12:42:43 +00:00
|
|
|
PeerName string `json:"peername" codec:"pn,omitempty"`
|
|
|
|
IPFS peer.ID `json:"ipfs_peer_id,omitempty" codec:"i,omitempty"`
|
|
|
|
IPFSAddresses []Multiaddr `json:"ipfs_peer_addresses,omitempty" codec:"ia,omitempty"`
|
|
|
|
Status TrackerStatus `json:"status" codec:"st,omitempty"`
|
|
|
|
TS time.Time `json:"timestamp" codec:"ts,omitempty"`
|
|
|
|
Error string `json:"error" codec:"e,omitempty"`
|
|
|
|
AttemptCount int `json:"attempt_count" codec:"a,omitempty"`
|
|
|
|
PriorityPin bool `json:"priority_pin" codec:"y,omitempty"`
|
2017-02-08 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2022-03-22 09:56:16 +00:00
|
|
|
// String provides a string representation of PinInfoShort.
|
|
|
|
func (pis PinInfoShort) String() string {
|
|
|
|
var b strings.Builder
|
|
|
|
fmt.Fprintf(&b, "status: %s\n", pis.Status)
|
|
|
|
fmt.Fprintf(&b, "peername: %s\n", pis.PeerName)
|
|
|
|
fmt.Fprintf(&b, "ipfs: %s\n", pis.IPFS)
|
|
|
|
fmt.Fprintf(&b, "ipfsAddresses: %v\n", pis.IPFSAddresses)
|
|
|
|
fmt.Fprintf(&b, "error: %s\n", pis.Error)
|
|
|
|
fmt.Fprintf(&b, "attemptCount: %d\n", pis.AttemptCount)
|
|
|
|
fmt.Fprintf(&b, "priority: %t\n", pis.PriorityPin)
|
|
|
|
return b.String()
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:32:28 +00:00
|
|
|
// PinInfo holds information about local pins. This is used by the Pin
|
|
|
|
// Trackers.
|
|
|
|
type PinInfo struct {
|
2022-04-07 11:53:30 +00:00
|
|
|
Cid Cid `json:"cid" codec:"c"`
|
2021-10-07 10:45:36 +00:00
|
|
|
Name string `json:"name" codec:"m,omitempty"`
|
|
|
|
Peer peer.ID `json:"peer" codec:"p,omitempty"`
|
2022-03-11 15:18:08 +00:00
|
|
|
Allocations []peer.ID `json:"allocations" codec:"o,omitempty"`
|
2021-10-07 10:45:36 +00:00
|
|
|
Origins []Multiaddr `json:"origins" codec:"g,omitempty"`
|
2022-03-14 11:21:08 +00:00
|
|
|
Created time.Time `json:"created" codec:"t,omitempty"`
|
2021-10-07 10:45:36 +00:00
|
|
|
Metadata map[string]string `json:"metadata" codec:"md,omitempty"`
|
2020-05-15 22:32:28 +00:00
|
|
|
|
|
|
|
PinInfoShort
|
|
|
|
}
|
|
|
|
|
|
|
|
// ToGlobal converts a PinInfo object to a GlobalPinInfo with
|
|
|
|
// a single peer corresponding to the given PinInfo.
|
2022-02-01 23:39:09 +00:00
|
|
|
func (pi PinInfo) ToGlobal() GlobalPinInfo {
|
2022-03-19 01:52:46 +00:00
|
|
|
gpi := GlobalPinInfo{}
|
2020-05-15 22:32:28 +00:00
|
|
|
gpi.Add(pi)
|
2022-03-19 01:52:46 +00:00
|
|
|
return gpi
|
|
|
|
}
|
|
|
|
|
2022-06-15 10:16:05 +00:00
|
|
|
// Defined returns if the PinInfo is not zero.
|
2022-03-19 01:52:46 +00:00
|
|
|
func (pi PinInfo) Defined() bool {
|
|
|
|
return pi.Cid.Defined()
|
2020-05-15 22:32:28 +00:00
|
|
|
}
|
|
|
|
|
2022-03-22 09:56:16 +00:00
|
|
|
// String provides a string representation of PinInfo.
|
|
|
|
func (pi PinInfo) String() string {
|
|
|
|
var b strings.Builder
|
|
|
|
fmt.Fprintf(&b, "cid: %s\n", pi.Cid)
|
|
|
|
fmt.Fprintf(&b, "name: %s\n", pi.Name)
|
|
|
|
fmt.Fprintf(&b, "peer: %s\n", pi.Peer)
|
|
|
|
fmt.Fprintf(&b, "allocations: %v\n", pi.Allocations)
|
|
|
|
fmt.Fprintf(&b, "%s\n", pi.PinInfoShort)
|
|
|
|
return b.String()
|
|
|
|
}
|
|
|
|
|
2017-02-08 17:04:08 +00:00
|
|
|
// Version holds version information
|
|
|
|
type Version struct {
|
2019-04-10 09:15:56 +00:00
|
|
|
Version string `json:"version" codec:"v"`
|
2017-02-08 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2019-02-27 18:43:29 +00:00
|
|
|
// ConnectGraph holds information about the connectivity of the cluster To
|
|
|
|
// read, traverse the keys of ClusterLinks. Each such id is one of the peers
|
|
|
|
// of the "ClusterID" peer running the query. ClusterLinks[id] in turn lists
|
|
|
|
// the ids that peer "id" sees itself connected to. It is possible that id is
|
|
|
|
// a peer of ClusterID, but ClusterID can not reach id over rpc, in which case
|
|
|
|
// ClusterLinks[id] == [], as id's view of its connectivity can not be
|
|
|
|
// retrieved.
|
2017-10-13 21:12:46 +00:00
|
|
|
//
|
2019-02-27 18:43:29 +00:00
|
|
|
// Iff there was an error reading the IPFSID of the peer then id will not be a
|
|
|
|
// key of ClustertoIPFS or IPFSLinks. Finally iff id is a key of ClustertoIPFS
|
|
|
|
// then id will be a key of IPFSLinks. In the event of a SwarmPeers error
|
|
|
|
// IPFSLinks[id] == [].
|
2017-10-13 21:12:46 +00:00
|
|
|
type ConnectGraph struct {
|
2019-09-18 06:08:13 +00:00
|
|
|
ClusterID peer.ID `json:"cluster_id" codec:"id"`
|
|
|
|
IDtoPeername map[string]string `json:"id_to_peername" codec:"ip,omitempty"`
|
2019-02-27 17:04:35 +00:00
|
|
|
// ipfs to ipfs links
|
|
|
|
IPFSLinks map[string][]peer.ID `json:"ipfs_links" codec:"il,omitempty"`
|
|
|
|
// cluster to cluster links
|
|
|
|
ClusterLinks map[string][]peer.ID `json:"cluster_links" codec:"cl,omitempty"`
|
2019-09-18 06:08:13 +00:00
|
|
|
// cluster trust links
|
|
|
|
ClusterTrustLinks map[string]bool `json:"cluster_trust_links" codec:"ctl,omitempty"`
|
2019-02-27 17:04:35 +00:00
|
|
|
// cluster to ipfs links
|
|
|
|
ClustertoIPFS map[string]peer.ID `json:"cluster_to_ipfs" codec:"ci,omitempty"`
|
2017-10-13 21:12:46 +00:00
|
|
|
}
|
|
|
|
|
2019-02-27 18:43:29 +00:00
|
|
|
// Multiaddr is a concrete type to wrap a Multiaddress so that it knows how to
|
|
|
|
// serialize and deserialize itself.
|
2019-02-27 17:04:35 +00:00
|
|
|
type Multiaddr struct {
|
|
|
|
multiaddr.Multiaddr
|
2017-10-13 21:12:46 +00:00
|
|
|
}
|
|
|
|
|
2019-02-27 18:43:29 +00:00
|
|
|
// NewMultiaddr returns a cluster Multiaddr wrapper creating the
|
|
|
|
// multiaddr.Multiaddr with the given string.
|
2019-02-27 17:04:35 +00:00
|
|
|
func NewMultiaddr(mstr string) (Multiaddr, error) {
|
|
|
|
m, err := multiaddr.NewMultiaddr(mstr)
|
|
|
|
return Multiaddr{Multiaddr: m}, err
|
2017-10-13 21:12:46 +00:00
|
|
|
}
|
|
|
|
|
2019-02-27 18:43:29 +00:00
|
|
|
// NewMultiaddrWithValue returns a new cluster Multiaddr wrapper using the
|
|
|
|
// given multiaddr.Multiaddr.
|
2019-02-27 17:04:35 +00:00
|
|
|
func NewMultiaddrWithValue(ma multiaddr.Multiaddr) Multiaddr {
|
|
|
|
return Multiaddr{Multiaddr: ma}
|
2018-01-18 02:49:35 +00:00
|
|
|
}
|
|
|
|
|
2019-02-27 18:43:29 +00:00
|
|
|
// MarshalJSON returns a JSON-formatted multiaddress.
|
2019-02-27 17:04:35 +00:00
|
|
|
func (maddr Multiaddr) MarshalJSON() ([]byte, error) {
|
|
|
|
return maddr.Multiaddr.MarshalJSON()
|
2017-10-13 21:12:46 +00:00
|
|
|
}
|
|
|
|
|
2019-02-27 18:43:29 +00:00
|
|
|
// UnmarshalJSON parses a cluster Multiaddr from the JSON representation.
|
2019-02-27 17:04:35 +00:00
|
|
|
func (maddr *Multiaddr) UnmarshalJSON(data []byte) error {
|
2019-05-21 09:34:33 +00:00
|
|
|
maddr.Multiaddr, _ = multiaddr.NewMultiaddr("/ip4/127.0.0.1") // null multiaddresses not allowed
|
2019-02-27 17:04:35 +00:00
|
|
|
return maddr.Multiaddr.UnmarshalJSON(data)
|
2017-10-13 21:12:46 +00:00
|
|
|
}
|
|
|
|
|
2019-02-27 18:43:29 +00:00
|
|
|
// MarshalBinary returs the bytes of the wrapped multiaddress.
|
2019-02-27 17:04:35 +00:00
|
|
|
func (maddr Multiaddr) MarshalBinary() ([]byte, error) {
|
|
|
|
return maddr.Multiaddr.MarshalBinary()
|
|
|
|
}
|
2019-02-27 18:43:29 +00:00
|
|
|
|
|
|
|
// UnmarshalBinary casts some bytes as a multiaddress wraps it with
|
|
|
|
// the given cluster Multiaddr.
|
2019-02-27 17:04:35 +00:00
|
|
|
func (maddr *Multiaddr) UnmarshalBinary(data []byte) error {
|
|
|
|
datacopy := make([]byte, len(data)) // This is super important
|
|
|
|
copy(datacopy, data)
|
2019-05-21 09:34:33 +00:00
|
|
|
maddr.Multiaddr, _ = multiaddr.NewMultiaddr("/ip4/127.0.0.1") // null multiaddresses not allowed
|
2019-02-27 17:04:35 +00:00
|
|
|
return maddr.Multiaddr.UnmarshalBinary(datacopy)
|
2017-10-13 21:12:46 +00:00
|
|
|
}
|
|
|
|
|
2019-02-27 18:43:29 +00:00
|
|
|
// Value returns the wrapped multiaddr.Multiaddr.
|
2019-02-27 17:04:35 +00:00
|
|
|
func (maddr Multiaddr) Value() multiaddr.Multiaddr {
|
|
|
|
return maddr.Multiaddr
|
2017-10-13 21:12:46 +00:00
|
|
|
}
|
|
|
|
|
2017-02-08 17:04:08 +00:00
|
|
|
// ID holds information about the Cluster peer
|
|
|
|
type ID struct {
|
2019-02-27 17:04:35 +00:00
|
|
|
ID peer.ID `json:"id" codec:"i,omitempty"`
|
|
|
|
Addresses []Multiaddr `json:"addresses" codec:"a,omitempty"`
|
|
|
|
ClusterPeers []peer.ID `json:"cluster_peers" codec:"cp,omitempty"`
|
|
|
|
ClusterPeersAddresses []Multiaddr `json:"cluster_peers_addresses" codec:"cpa,omitempty"`
|
|
|
|
Version string `json:"version" codec:"v,omitempty"`
|
|
|
|
Commit string `json:"commit" codec:"c,omitempty"`
|
|
|
|
RPCProtocolVersion protocol.ID `json:"rpc_protocol_version" codec:"rv,omitempty"`
|
|
|
|
Error string `json:"error" codec:"e,omitempty"`
|
2022-01-28 17:21:11 +00:00
|
|
|
IPFS IPFSID `json:"ipfs,omitempty" codec:"ip,omitempty"`
|
2019-02-27 17:04:35 +00:00
|
|
|
Peername string `json:"peername" codec:"pn,omitempty"`
|
2017-02-08 17:04:08 +00:00
|
|
|
//PublicKey crypto.PubKey
|
|
|
|
}
|
|
|
|
|
2019-02-27 17:04:35 +00:00
|
|
|
// IPFSID is used to store information about the underlying IPFS daemon
|
|
|
|
type IPFSID struct {
|
2019-03-14 12:58:36 +00:00
|
|
|
ID peer.ID `json:"id,omitempty" codec:"i,omitempty"`
|
2019-02-27 17:04:35 +00:00
|
|
|
Addresses []Multiaddr `json:"addresses" codec:"a,omitempty"`
|
|
|
|
Error string `json:"error" codec:"e,omitempty"`
|
2018-03-18 19:29:02 +00:00
|
|
|
}
|
|
|
|
|
2018-08-09 11:22:47 +00:00
|
|
|
// PinType specifies which sort of Pin object we are dealing with.
|
|
|
|
// In practice, the PinType decides how a Pin object is treated by the
|
|
|
|
// PinTracker.
|
|
|
|
// See descriptions above.
|
|
|
|
// A sharded Pin would look like:
|
|
|
|
//
|
|
|
|
// [ Meta ] (not pinned on IPFS, only present in cluster state)
|
2022-09-06 14:57:17 +00:00
|
|
|
//
|
|
|
|
// |
|
|
|
|
// v
|
|
|
|
//
|
2018-08-09 11:22:47 +00:00
|
|
|
// [ Cluster DAG ] (pinned everywhere in "direct")
|
2022-09-06 14:57:17 +00:00
|
|
|
//
|
|
|
|
// | .. |
|
|
|
|
// v v
|
|
|
|
//
|
2018-08-09 11:22:47 +00:00
|
|
|
// [Shard1] .. [ShardN] (allocated to peers and pinned with max-depth=1
|
|
|
|
// | | .. | | | .. |
|
|
|
|
// v v .. v v v .. v
|
|
|
|
// [][]..[] [][]..[] Blocks (indirectly pinned on ipfs, not tracked in cluster)
|
2018-08-10 12:39:44 +00:00
|
|
|
type PinType uint64
|
2018-08-06 09:12:57 +00:00
|
|
|
|
2018-07-04 16:30:24 +00:00
|
|
|
// PinType values. See PinType documentation for further explanation.
|
2018-03-18 19:29:02 +00:00
|
|
|
const (
|
2018-07-04 16:30:24 +00:00
|
|
|
// BadType type showing up anywhere indicates a bug
|
2018-08-09 11:22:47 +00:00
|
|
|
BadType PinType = 1 << iota
|
2018-07-23 13:56:46 +00:00
|
|
|
// DataType is a regular, non-sharded pin. It is pinned recursively.
|
|
|
|
// It has no associated reference.
|
2018-06-28 15:01:39 +00:00
|
|
|
DataType
|
2018-07-23 13:56:46 +00:00
|
|
|
// MetaType tracks the original CID of a sharded DAG. Its Reference
|
|
|
|
// points to the Cluster DAG CID.
|
2018-03-18 19:29:02 +00:00
|
|
|
MetaType
|
2018-08-09 11:22:47 +00:00
|
|
|
// ClusterDAGType pins carry the CID of the root node that points to
|
2018-07-04 16:30:24 +00:00
|
|
|
// all the shard-root-nodes of the shards in which a DAG has been
|
2018-07-23 13:56:46 +00:00
|
|
|
// divided. Its Reference carries the MetaType CID.
|
2018-07-04 16:30:24 +00:00
|
|
|
// ClusterDAGType pins are pinned directly everywhere.
|
|
|
|
ClusterDAGType
|
|
|
|
// ShardType pins carry the root CID of a shard, which points
|
|
|
|
// to individual blocks on the original DAG that the user is adding,
|
|
|
|
// which has been sharded.
|
2018-07-23 13:56:46 +00:00
|
|
|
// They carry a Reference to the previous shard.
|
2018-07-04 16:30:24 +00:00
|
|
|
// ShardTypes are pinned with MaxDepth=1 (root and
|
|
|
|
// direct children only).
|
2018-03-18 19:29:02 +00:00
|
|
|
ShardType
|
|
|
|
)
|
|
|
|
|
2018-08-09 11:22:47 +00:00
|
|
|
// AllType is a PinType used for filtering all pin types
|
|
|
|
const AllType PinType = DataType | MetaType | ClusterDAGType | ShardType
|
2018-03-18 19:29:02 +00:00
|
|
|
|
|
|
|
// PinTypeFromString is the inverse of String. It returns the PinType value
|
|
|
|
// corresponding to the input string
|
|
|
|
func PinTypeFromString(str string) PinType {
|
|
|
|
switch str {
|
|
|
|
case "pin":
|
|
|
|
return DataType
|
|
|
|
case "meta-pin":
|
|
|
|
return MetaType
|
|
|
|
case "clusterdag-pin":
|
2018-07-04 16:30:24 +00:00
|
|
|
return ClusterDAGType
|
2018-03-18 19:29:02 +00:00
|
|
|
case "shard-pin":
|
|
|
|
return ShardType
|
|
|
|
case "all":
|
|
|
|
return AllType
|
2019-04-24 14:54:08 +00:00
|
|
|
case "":
|
|
|
|
return AllType
|
2018-03-18 19:29:02 +00:00
|
|
|
default:
|
2018-06-28 15:01:39 +00:00
|
|
|
return BadType
|
2018-03-18 19:29:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// String returns a printable value to identify the PinType
|
2018-08-10 12:39:44 +00:00
|
|
|
func (pT PinType) String() string {
|
|
|
|
switch pT {
|
2018-03-18 19:29:02 +00:00
|
|
|
case DataType:
|
|
|
|
return "pin"
|
|
|
|
case MetaType:
|
|
|
|
return "meta-pin"
|
2018-07-04 16:30:24 +00:00
|
|
|
case ClusterDAGType:
|
2018-03-18 19:29:02 +00:00
|
|
|
return "clusterdag-pin"
|
|
|
|
case ShardType:
|
|
|
|
return "shard-pin"
|
|
|
|
case AllType:
|
|
|
|
return "all"
|
|
|
|
default:
|
2018-08-10 12:39:44 +00:00
|
|
|
return "bad-type"
|
2018-03-18 19:29:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-07 12:44:04 +00:00
|
|
|
// MarshalJSON provides json-representation of the pin type.
|
|
|
|
func (pT PinType) MarshalJSON() ([]byte, error) {
|
|
|
|
return json.Marshal(pT.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalJSON provides json-representation of the pin type.
|
|
|
|
func (pT *PinType) UnmarshalJSON(b []byte) error {
|
|
|
|
var str string
|
|
|
|
err := json.Unmarshal(b, &str)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
t := PinTypeFromString(str)
|
|
|
|
*pT = t
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-02-20 12:49:30 +00:00
|
|
|
var pinOptionsMetaPrefix = "meta-"
|
|
|
|
|
2020-04-17 11:36:05 +00:00
|
|
|
// PinMode is a PinOption that indicates how to pin something on IPFS,
|
|
|
|
// recursively or direct.
|
|
|
|
type PinMode int
|
|
|
|
|
|
|
|
// PinMode values
|
|
|
|
const (
|
|
|
|
PinModeRecursive PinMode = 0
|
|
|
|
PinModeDirect PinMode = 1
|
|
|
|
)
|
|
|
|
|
2022-06-15 10:16:05 +00:00
|
|
|
// PinModeFromString converts a string to PinMode.
|
2020-04-17 11:36:05 +00:00
|
|
|
func PinModeFromString(s string) PinMode {
|
|
|
|
switch s {
|
|
|
|
case "recursive", "":
|
|
|
|
return PinModeRecursive
|
|
|
|
case "direct":
|
|
|
|
return PinModeDirect
|
|
|
|
default:
|
2022-06-16 15:13:15 +00:00
|
|
|
logger.Warn("unknown pin mode string. Defaulting to recursive")
|
2020-04-17 11:36:05 +00:00
|
|
|
return PinModeRecursive
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// String returns a human-readable value for PinMode.
|
|
|
|
func (pm PinMode) String() string {
|
|
|
|
switch pm {
|
|
|
|
case PinModeRecursive:
|
|
|
|
return "recursive"
|
|
|
|
case PinModeDirect:
|
|
|
|
return "direct"
|
|
|
|
default:
|
|
|
|
return "recursive"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-22 09:56:16 +00:00
|
|
|
// ToIPFSPinStatus converts a PinMode to IPFSPinStatus.
|
|
|
|
func (pm PinMode) ToIPFSPinStatus() IPFSPinStatus {
|
|
|
|
if pm == PinModeDirect {
|
|
|
|
return IPFSPinStatusDirect
|
|
|
|
}
|
|
|
|
if pm == PinModeRecursive {
|
|
|
|
return IPFSPinStatusRecursive
|
|
|
|
}
|
|
|
|
return IPFSPinStatusBug
|
|
|
|
}
|
|
|
|
|
2020-04-17 11:36:05 +00:00
|
|
|
// MarshalJSON converts the PinMode into a readable string in JSON.
|
|
|
|
func (pm PinMode) MarshalJSON() ([]byte, error) {
|
|
|
|
return json.Marshal(pm.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalJSON takes a JSON value and parses it into PinMode.
|
|
|
|
func (pm *PinMode) UnmarshalJSON(b []byte) error {
|
|
|
|
var s string
|
|
|
|
err := json.Unmarshal(b, &s)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
*pm = PinModeFromString(s)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-04-20 13:15:08 +00:00
|
|
|
// ToPinDepth converts the Mode to Depth.
|
|
|
|
func (pm PinMode) ToPinDepth() PinDepth {
|
|
|
|
switch pm {
|
|
|
|
case PinModeRecursive:
|
|
|
|
return -1
|
|
|
|
case PinModeDirect:
|
|
|
|
return 0
|
|
|
|
default:
|
|
|
|
logger.Warn("unknown pin mode %d. Defaulting to -1 depth", pm)
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-04 16:30:24 +00:00
|
|
|
// PinOptions wraps user-defined options for Pins
|
|
|
|
type PinOptions struct {
|
2021-12-13 16:31:18 +00:00
|
|
|
ReplicationFactorMin int `json:"replication_factor_min" codec:"rn,omitempty"`
|
|
|
|
ReplicationFactorMax int `json:"replication_factor_max" codec:"rx,omitempty"`
|
|
|
|
Name string `json:"name" codec:"n,omitempty"`
|
|
|
|
Mode PinMode `json:"mode" codec:"o,omitempty"`
|
|
|
|
ShardSize uint64 `json:"shard_size" codec:"s,omitempty"`
|
|
|
|
UserAllocations []peer.ID `json:"user_allocations" codec:"ua,omitempty"`
|
|
|
|
ExpireAt time.Time `json:"expire_at" codec:"e,omitempty"`
|
|
|
|
Metadata map[string]string `json:"metadata" codec:"m,omitempty"`
|
2022-04-07 11:53:30 +00:00
|
|
|
PinUpdate Cid `json:"pin_update,omitempty" codec:"pu,omitempty"`
|
2021-12-13 16:31:18 +00:00
|
|
|
Origins []Multiaddr `json:"origins" codec:"g,omitempty"`
|
2018-07-04 16:30:24 +00:00
|
|
|
}
|
|
|
|
|
2019-02-20 14:24:25 +00:00
|
|
|
// Equals returns true if two PinOption objects are equivalent. po and po2 may
|
|
|
|
// be nil.
|
2022-03-19 01:52:46 +00:00
|
|
|
func (po PinOptions) Equals(po2 PinOptions) bool {
|
2019-09-06 15:56:00 +00:00
|
|
|
if po.Name != po2.Name {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-04-17 11:36:05 +00:00
|
|
|
if po.Mode != po2.Mode {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-02-20 12:49:30 +00:00
|
|
|
if po.ReplicationFactorMax != po2.ReplicationFactorMax {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if po.ReplicationFactorMin != po2.ReplicationFactorMin {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if po.ShardSize != po2.ShardSize {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
lenAllocs1 := len(po.UserAllocations)
|
|
|
|
lenAllocs2 := len(po2.UserAllocations)
|
|
|
|
if lenAllocs1 != lenAllocs2 {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-02-21 16:44:20 +00:00
|
|
|
// avoid side effects in the original objects
|
2019-04-29 14:24:38 +00:00
|
|
|
allocs1 := PeersToStrings(po.UserAllocations)
|
|
|
|
allocs2 := PeersToStrings(po2.UserAllocations)
|
2019-02-20 12:49:30 +00:00
|
|
|
sort.Strings(allocs1)
|
|
|
|
sort.Strings(allocs2)
|
|
|
|
if strings.Join(allocs1, ",") != strings.Join(allocs2, ",") {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-09-18 16:05:55 +00:00
|
|
|
if !po.ExpireAt.Equal(po2.ExpireAt) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-02-20 12:49:30 +00:00
|
|
|
for k, v := range po.Metadata {
|
|
|
|
v2 := po2.Metadata[k]
|
|
|
|
if k != "" && v != v2 {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
2019-07-12 14:40:29 +00:00
|
|
|
|
|
|
|
// deliberately ignore Update
|
|
|
|
|
2021-07-01 23:42:51 +00:00
|
|
|
lenOrigins1 := len(po.Origins)
|
|
|
|
lenOrigins2 := len(po2.Origins)
|
|
|
|
if lenOrigins1 != lenOrigins2 {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, o1 := range po.Origins {
|
|
|
|
found := false
|
|
|
|
for _, o2 := range po2.Origins {
|
2021-12-13 16:31:18 +00:00
|
|
|
if o1.Value().Equal(o2.Value()) {
|
2021-07-01 23:42:51 +00:00
|
|
|
found = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if !found {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-20 12:49:30 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
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
|
|
|
// ToQuery returns the PinOption as query arguments.
|
2022-03-19 01:52:46 +00:00
|
|
|
func (po PinOptions) ToQuery() (string, error) {
|
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
|
|
|
q := url.Values{}
|
|
|
|
q.Set("replication-min", fmt.Sprintf("%d", po.ReplicationFactorMin))
|
|
|
|
q.Set("replication-max", fmt.Sprintf("%d", po.ReplicationFactorMax))
|
|
|
|
q.Set("name", po.Name)
|
2020-04-17 11:36:05 +00:00
|
|
|
q.Set("mode", po.Mode.String())
|
2019-02-20 12:49:30 +00:00
|
|
|
q.Set("shard-size", fmt.Sprintf("%d", po.ShardSize))
|
2019-04-29 14:24:38 +00:00
|
|
|
q.Set("user-allocations", strings.Join(PeersToStrings(po.UserAllocations), ","))
|
2019-09-18 16:05:55 +00:00
|
|
|
if !po.ExpireAt.IsZero() {
|
|
|
|
v, err := po.ExpireAt.MarshalText()
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
q.Set("expire-at", string(v))
|
|
|
|
}
|
2019-02-20 12:49:30 +00:00
|
|
|
for k, v := range po.Metadata {
|
|
|
|
if k == "" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
q.Set(fmt.Sprintf("%s%s", pinOptionsMetaPrefix, k), v)
|
|
|
|
}
|
2022-04-07 11:53:30 +00:00
|
|
|
if po.PinUpdate.Defined() {
|
2019-08-14 12:09:46 +00:00
|
|
|
q.Set("pin-update", po.PinUpdate.String())
|
|
|
|
}
|
2021-07-01 23:42:51 +00:00
|
|
|
|
|
|
|
if len(po.Origins) > 0 {
|
|
|
|
origins := make([]string, len(po.Origins))
|
|
|
|
for i, o := range po.Origins {
|
|
|
|
origins[i] = o.String()
|
|
|
|
}
|
|
|
|
q.Set("origins", strings.Join(origins, ","))
|
|
|
|
}
|
|
|
|
|
2019-09-18 16:05:55 +00:00
|
|
|
return q.Encode(), 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
|
|
|
}
|
|
|
|
|
|
|
|
// FromQuery is the inverse of ToQuery().
|
2019-09-06 16:38:55 +00:00
|
|
|
func (po *PinOptions) FromQuery(q url.Values) error {
|
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
|
|
|
po.Name = q.Get("name")
|
2020-04-17 11:36:05 +00:00
|
|
|
|
|
|
|
po.Mode = PinModeFromString(q.Get("mode"))
|
|
|
|
|
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
|
|
|
rplStr := q.Get("replication")
|
|
|
|
if rplStr != "" { // override
|
2019-09-06 16:38:55 +00:00
|
|
|
q.Set("replication-min", rplStr)
|
|
|
|
q.Set("replication-max", rplStr)
|
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
|
|
|
}
|
2019-09-06 16:38:55 +00:00
|
|
|
|
|
|
|
err := parseIntParam(q, "replication-min", &po.ReplicationFactorMin)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
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
|
|
|
}
|
2019-09-06 16:38:55 +00:00
|
|
|
|
|
|
|
err = parseIntParam(q, "replication-max", &po.ReplicationFactorMax)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
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
|
|
|
}
|
2019-02-20 12:49:30 +00:00
|
|
|
|
2019-09-06 16:38:55 +00:00
|
|
|
if v := q.Get("shard-size"); v != "" {
|
|
|
|
shardSize, err := strconv.ParseUint(v, 10, 64)
|
|
|
|
if err != nil {
|
|
|
|
return errors.New("parameter shard_size is invalid")
|
|
|
|
}
|
|
|
|
po.ShardSize = shardSize
|
2019-02-20 12:49:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if allocs := q.Get("user-allocations"); allocs != "" {
|
2019-04-29 14:24:38 +00:00
|
|
|
po.UserAllocations = StringsToPeers(strings.Split(allocs, ","))
|
2019-02-20 12:49:30 +00:00
|
|
|
}
|
|
|
|
|
2019-09-18 16:05:55 +00:00
|
|
|
if v := q.Get("expire-at"); v != "" {
|
|
|
|
var tm time.Time
|
|
|
|
err := tm.UnmarshalText([]byte(v))
|
|
|
|
if err != nil {
|
2019-11-05 09:11:50 +00:00
|
|
|
return errors.Wrap(err, "expire-at cannot be parsed")
|
2019-09-18 16:05:55 +00:00
|
|
|
}
|
2019-11-05 09:11:50 +00:00
|
|
|
po.ExpireAt = tm
|
2019-09-18 16:05:55 +00:00
|
|
|
} else if v = q.Get("expire-in"); v != "" {
|
|
|
|
d, err := time.ParseDuration(v)
|
|
|
|
if err != nil {
|
2019-11-05 09:11:50 +00:00
|
|
|
return errors.Wrap(err, "expire-in cannot be parsed")
|
2019-09-18 16:05:55 +00:00
|
|
|
}
|
2019-11-05 09:11:50 +00:00
|
|
|
if d < time.Second {
|
|
|
|
return errors.New("expire-in duration too short")
|
2019-09-18 16:05:55 +00:00
|
|
|
}
|
2019-11-05 09:11:50 +00:00
|
|
|
po.ExpireAt = time.Now().Add(d)
|
2019-09-18 16:05:55 +00:00
|
|
|
}
|
|
|
|
|
2019-02-20 12:49:30 +00:00
|
|
|
po.Metadata = make(map[string]string)
|
|
|
|
for k := range q {
|
|
|
|
if !strings.HasPrefix(k, pinOptionsMetaPrefix) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
metaKey := strings.TrimPrefix(k, pinOptionsMetaPrefix)
|
|
|
|
if metaKey == "" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
po.Metadata[metaKey] = q.Get(k)
|
|
|
|
}
|
2019-07-12 14:40:29 +00:00
|
|
|
|
|
|
|
updateStr := q.Get("pin-update")
|
|
|
|
if updateStr != "" {
|
2022-04-07 11:53:30 +00:00
|
|
|
updateCid, err := DecodeCid(updateStr)
|
2019-07-12 14:40:29 +00:00
|
|
|
if err != nil {
|
2019-09-06 16:38:55 +00:00
|
|
|
return fmt.Errorf("error decoding update option parameter: %s", err)
|
2019-07-12 14:40:29 +00:00
|
|
|
}
|
|
|
|
po.PinUpdate = updateCid
|
|
|
|
}
|
2021-07-01 23:42:51 +00:00
|
|
|
|
|
|
|
originsStr := q.Get("origins")
|
|
|
|
if originsStr != "" {
|
|
|
|
origins := strings.Split(originsStr, ",")
|
2021-12-13 16:31:18 +00:00
|
|
|
maOrigins := make([]Multiaddr, len(origins))
|
2021-07-01 23:42:51 +00:00
|
|
|
for i, ostr := range origins {
|
2021-12-13 16:31:18 +00:00
|
|
|
maOrig, err := NewMultiaddr(ostr)
|
2021-07-01 23:42:51 +00:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("error decoding multiaddress: %w", err)
|
|
|
|
}
|
2021-07-01 23:49:30 +00:00
|
|
|
_, err = maOrig.ValueForProtocol(multiaddr.P_P2P)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("multiaddress does not contain peer ID: %w", err)
|
|
|
|
}
|
|
|
|
|
2021-07-01 23:42:51 +00:00
|
|
|
maOrigins[i] = maOrig
|
|
|
|
}
|
|
|
|
po.Origins = maOrigins
|
|
|
|
}
|
|
|
|
|
2019-09-06 16:38:55 +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
|
|
|
}
|
|
|
|
|
2020-04-20 13:15:08 +00:00
|
|
|
// PinDepth indicates how deep a pin should be pinned, with
|
|
|
|
// -1 meaning "to the bottom", or "recursive".
|
|
|
|
type PinDepth int
|
|
|
|
|
|
|
|
// ToPinMode converts PinDepth to PinMode
|
|
|
|
func (pd PinDepth) ToPinMode() PinMode {
|
|
|
|
switch pd {
|
|
|
|
case -1:
|
|
|
|
return PinModeRecursive
|
|
|
|
case 0:
|
|
|
|
return PinModeDirect
|
|
|
|
default:
|
|
|
|
logger.Warnf("bad pin depth: %d", pd)
|
|
|
|
return PinModeRecursive
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-04 16:30:24 +00:00
|
|
|
// Pin carries all the information associated to a CID that is pinned
|
2019-07-12 14:40:29 +00:00
|
|
|
// in IPFS Cluster. It also carries transient information (that may not
|
|
|
|
// get protobuffed, like UserAllocations).
|
2017-03-08 15:57:27 +00:00
|
|
|
type Pin struct {
|
2018-07-04 16:30:24 +00:00
|
|
|
PinOptions
|
|
|
|
|
2022-04-07 11:53:30 +00:00
|
|
|
Cid Cid `json:"cid" codec:"c"`
|
2018-07-04 16:30:24 +00:00
|
|
|
|
|
|
|
// See PinType comments
|
2019-02-27 17:04:35 +00:00
|
|
|
Type PinType `json:"type" codec:"t,omitempty"`
|
2018-07-04 16:30:24 +00:00
|
|
|
|
|
|
|
// The peers to which this pin is allocated
|
2019-02-27 17:04:35 +00:00
|
|
|
Allocations []peer.ID `json:"allocations" codec:"a,omitempty"`
|
2018-07-04 16:30:24 +00:00
|
|
|
|
|
|
|
// MaxDepth associated to this pin. -1 means
|
|
|
|
// recursive.
|
2020-04-20 13:15:08 +00:00
|
|
|
MaxDepth PinDepth `json:"max_depth" codec:"d,omitempty"`
|
2018-07-04 16:30:24 +00:00
|
|
|
|
2018-07-23 13:56:46 +00:00
|
|
|
// We carry a reference CID to this pin. For
|
|
|
|
// ClusterDAGs, it is the MetaPin CID. For the
|
|
|
|
// MetaPin it is the ClusterDAG CID. For Shards,
|
|
|
|
// it is the previous shard CID.
|
2019-02-27 17:04:35 +00:00
|
|
|
// When not needed the pointer is nil
|
2022-04-07 11:53:30 +00:00
|
|
|
Reference *Cid `json:"reference" codec:"r,omitempty"`
|
2021-10-20 09:38:12 +00:00
|
|
|
|
|
|
|
// The time that the pin was submitted to the consensus layer.
|
|
|
|
Timestamp time.Time `json:"timestamp" codec:"i,omitempty"`
|
2017-02-13 15:46:53 +00:00
|
|
|
}
|
|
|
|
|
2019-05-07 08:50:03 +00:00
|
|
|
// String is a string representation of a Pin.
|
2022-03-19 01:52:46 +00:00
|
|
|
func (pin Pin) String() string {
|
2019-05-07 08:50:03 +00:00
|
|
|
var b strings.Builder
|
|
|
|
fmt.Fprintf(&b, "cid: %s\n", pin.Cid.String())
|
|
|
|
fmt.Fprintf(&b, "type: %s\n", pin.Type)
|
|
|
|
fmt.Fprintf(&b, "allocations: %v\n", pin.Allocations)
|
|
|
|
fmt.Fprintf(&b, "maxdepth: %d\n", pin.MaxDepth)
|
|
|
|
if pin.Reference != nil {
|
|
|
|
fmt.Fprintf(&b, "reference: %s\n", pin.Reference)
|
|
|
|
}
|
|
|
|
return b.String()
|
|
|
|
}
|
|
|
|
|
2021-03-23 23:47:15 +00:00
|
|
|
// IsPinEverywhere returns when the both replication factors are set to -1.
|
2022-03-19 01:52:46 +00:00
|
|
|
func (pin Pin) IsPinEverywhere() bool {
|
2021-03-23 23:47:15 +00:00
|
|
|
return pin.ReplicationFactorMin == -1 && pin.ReplicationFactorMax == -1
|
|
|
|
}
|
|
|
|
|
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 is a wrapper for holding pin options and path of the content.
|
|
|
|
type PinPath struct {
|
|
|
|
PinOptions
|
|
|
|
Path string `json:"path"`
|
|
|
|
}
|
|
|
|
|
2022-03-19 01:52:46 +00:00
|
|
|
// Defined returns if the path has a value.
|
|
|
|
func (pp PinPath) Defined() bool {
|
|
|
|
return pp.Path != ""
|
|
|
|
}
|
|
|
|
|
2018-02-16 20:20:13 +00:00
|
|
|
// PinCid is a shortcut to create a Pin only with a Cid. Default is for pin to
|
2018-07-24 12:21:29 +00:00
|
|
|
// be recursive and the pin to be of DataType.
|
2022-04-07 11:53:30 +00:00
|
|
|
func PinCid(c Cid) Pin {
|
2022-03-19 01:52:46 +00:00
|
|
|
return Pin{
|
2018-01-16 10:21:34 +00:00
|
|
|
Cid: c,
|
2018-03-18 19:29:02 +00:00
|
|
|
Type: DataType,
|
2018-01-16 10:21:34 +00:00
|
|
|
Allocations: []peer.ID{},
|
2020-04-17 11:36:05 +00:00
|
|
|
MaxDepth: -1, // Recursive
|
2021-10-20 09:38:12 +00:00
|
|
|
Timestamp: time.Now(),
|
2017-02-13 15:46:53 +00:00
|
|
|
}
|
2017-02-08 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2020-04-17 11:36:05 +00:00
|
|
|
// PinWithOpts creates a new Pin calling PinCid(c) and then sets its
|
|
|
|
// PinOptions fields with the given options. Pin fields that are linked to
|
|
|
|
// options are set accordingly (MaxDepth from Mode).
|
2022-04-07 11:53:30 +00:00
|
|
|
func PinWithOpts(c Cid, opts PinOptions) Pin {
|
2018-07-04 16:30:24 +00:00
|
|
|
p := PinCid(c)
|
2019-02-19 17:59:46 +00:00
|
|
|
p.PinOptions = opts
|
2020-04-20 13:15:08 +00:00
|
|
|
p.MaxDepth = p.Mode.ToPinDepth()
|
2018-07-04 16:30:24 +00:00
|
|
|
return p
|
|
|
|
}
|
|
|
|
|
2019-02-19 17:59:46 +00:00
|
|
|
func convertPinType(t PinType) pb.Pin_PinType {
|
|
|
|
var i pb.Pin_PinType
|
|
|
|
for t != 1 {
|
|
|
|
if t == 0 {
|
|
|
|
return pb.Pin_BadType
|
|
|
|
}
|
|
|
|
t = t >> 1
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
return i
|
|
|
|
}
|
|
|
|
|
|
|
|
// ProtoMarshal marshals this Pin using probobuf.
|
2022-03-19 01:52:46 +00:00
|
|
|
func (pin Pin) ProtoMarshal() ([]byte, error) {
|
2020-04-14 17:58:00 +00:00
|
|
|
allocs := make([][]byte, len(pin.Allocations))
|
2019-02-19 17:59:46 +00:00
|
|
|
for i, pid := range pin.Allocations {
|
|
|
|
bs, err := pid.Marshal()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
allocs[i] = bs
|
|
|
|
}
|
|
|
|
|
2021-07-01 23:42:51 +00:00
|
|
|
// Cursory google search says len=0 slices will be
|
|
|
|
// decoded as null, which is fine.
|
|
|
|
origins := make([][]byte, len(pin.Origins))
|
|
|
|
for i, orig := range pin.Origins {
|
|
|
|
origins[i] = orig.Bytes()
|
|
|
|
}
|
|
|
|
|
2019-09-18 16:05:55 +00:00
|
|
|
var expireAtProto uint64
|
|
|
|
// Only set the protobuf field with non-zero times.
|
2019-11-05 09:11:50 +00:00
|
|
|
if !(pin.ExpireAt.IsZero() || pin.ExpireAt.Equal(unixZero)) {
|
2019-09-18 16:05:55 +00:00
|
|
|
expireAtProto = uint64(pin.ExpireAt.Unix())
|
|
|
|
}
|
|
|
|
|
2021-10-20 09:38:12 +00:00
|
|
|
var timestampProto uint64
|
|
|
|
// Only set the protobuf field with non-zero times.
|
|
|
|
if !(pin.Timestamp.IsZero() || pin.Timestamp.Equal(unixZero)) {
|
|
|
|
timestampProto = uint64(pin.Timestamp.Unix())
|
|
|
|
}
|
|
|
|
|
2022-05-05 22:37:59 +00:00
|
|
|
// Our metadata needs to always be seralized in exactly the same way,
|
|
|
|
// and that is why we use an array sorted by key and deprecated using
|
|
|
|
// a protobuf map.
|
|
|
|
var sortedMetadata []*pb.Metadata
|
|
|
|
var metaKeys []string
|
|
|
|
for k := range pin.Metadata {
|
|
|
|
metaKeys = append(metaKeys, k)
|
|
|
|
}
|
|
|
|
sort.Strings(metaKeys)
|
|
|
|
|
|
|
|
for _, k := range metaKeys {
|
|
|
|
metadata := &pb.Metadata{
|
|
|
|
Key: k,
|
|
|
|
Value: pin.Metadata[k],
|
|
|
|
}
|
|
|
|
sortedMetadata = append(sortedMetadata, metadata)
|
|
|
|
}
|
|
|
|
|
2019-02-20 12:49:30 +00:00
|
|
|
opts := &pb.PinOptions{
|
2019-02-19 17:59:46 +00:00
|
|
|
ReplicationFactorMin: int32(pin.ReplicationFactorMin),
|
|
|
|
ReplicationFactorMax: int32(pin.ReplicationFactorMax),
|
|
|
|
Name: pin.Name,
|
|
|
|
ShardSize: pin.ShardSize,
|
2022-05-05 22:37:59 +00:00
|
|
|
// Metadata: pin.Metadata,
|
|
|
|
PinUpdate: pin.PinUpdate.Bytes(),
|
|
|
|
ExpireAt: expireAtProto,
|
2020-04-17 11:36:05 +00:00
|
|
|
// Mode: pin.Mode,
|
2019-02-24 20:33:16 +00:00
|
|
|
// UserAllocations: pin.UserAllocations,
|
2022-05-05 22:37:59 +00:00
|
|
|
Origins: origins,
|
|
|
|
SortedMetadata: sortedMetadata,
|
2019-02-19 17:59:46 +00:00
|
|
|
}
|
2019-02-20 12:49:30 +00:00
|
|
|
|
|
|
|
pbPin := &pb.Pin{
|
|
|
|
Cid: pin.Cid.Bytes(),
|
|
|
|
Type: convertPinType(pin.Type),
|
|
|
|
Allocations: allocs,
|
|
|
|
MaxDepth: int32(pin.MaxDepth),
|
|
|
|
Options: opts,
|
2021-10-20 09:38:12 +00:00
|
|
|
Timestamp: timestampProto,
|
2019-02-19 17:59:46 +00:00
|
|
|
}
|
2019-02-27 17:04:35 +00:00
|
|
|
if ref := pin.Reference; ref != nil {
|
|
|
|
pbPin.Reference = ref.Bytes()
|
|
|
|
}
|
2019-02-19 17:59:46 +00:00
|
|
|
return proto.Marshal(pbPin)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ProtoUnmarshal unmarshals this fields from protobuf-encoded bytes.
|
|
|
|
func (pin *Pin) ProtoUnmarshal(data []byte) error {
|
|
|
|
pbPin := pb.Pin{}
|
|
|
|
err := proto.Unmarshal(data, &pbPin)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-04-07 11:53:30 +00:00
|
|
|
ci, err := CastCid(pbPin.GetCid())
|
2019-02-19 17:59:46 +00:00
|
|
|
if err != nil {
|
2022-04-07 11:53:30 +00:00
|
|
|
pin.Cid = CidUndef
|
2019-02-19 17:59:46 +00:00
|
|
|
} else {
|
|
|
|
pin.Cid = ci
|
|
|
|
}
|
|
|
|
|
|
|
|
pin.Type = 1 << uint64(pbPin.GetType())
|
|
|
|
|
|
|
|
pbAllocs := pbPin.GetAllocations()
|
|
|
|
lenAllocs := len(pbAllocs)
|
2020-04-14 17:58:00 +00:00
|
|
|
allocs := make([]peer.ID, lenAllocs)
|
2019-02-19 17:59:46 +00:00
|
|
|
for i, pidb := range pbAllocs {
|
|
|
|
pid, err := peer.IDFromBytes(pidb)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
allocs[i] = pid
|
|
|
|
}
|
|
|
|
|
|
|
|
pin.Allocations = allocs
|
2020-04-20 13:15:08 +00:00
|
|
|
pin.MaxDepth = PinDepth(pbPin.GetMaxDepth())
|
2022-04-07 11:53:30 +00:00
|
|
|
ref, err := CastCid(pbPin.GetReference())
|
2019-02-19 17:59:46 +00:00
|
|
|
if err != nil {
|
2019-02-27 17:04:35 +00:00
|
|
|
pin.Reference = nil
|
2019-02-19 17:59:46 +00:00
|
|
|
|
|
|
|
} else {
|
2019-02-27 17:04:35 +00:00
|
|
|
pin.Reference = &ref
|
2019-02-19 17:59:46 +00:00
|
|
|
}
|
2019-02-20 12:49:30 +00:00
|
|
|
|
2021-10-20 09:38:12 +00:00
|
|
|
ts := pbPin.GetTimestamp()
|
|
|
|
if ts > 0 {
|
|
|
|
pin.Timestamp = time.Unix(int64(ts), 0)
|
|
|
|
}
|
|
|
|
|
2019-02-20 12:49:30 +00:00
|
|
|
opts := pbPin.GetOptions()
|
|
|
|
pin.ReplicationFactorMin = int(opts.GetReplicationFactorMin())
|
|
|
|
pin.ReplicationFactorMax = int(opts.GetReplicationFactorMax())
|
|
|
|
pin.Name = opts.GetName()
|
|
|
|
pin.ShardSize = opts.GetShardSize()
|
2021-10-20 09:38:12 +00:00
|
|
|
|
2019-02-24 20:33:16 +00:00
|
|
|
// pin.UserAllocations = opts.GetUserAllocations()
|
2021-10-20 09:38:12 +00:00
|
|
|
exp := opts.GetExpireAt()
|
|
|
|
if exp > 0 {
|
|
|
|
pin.ExpireAt = time.Unix(int64(exp), 0)
|
2019-09-18 16:05:55 +00:00
|
|
|
}
|
2022-05-05 22:37:59 +00:00
|
|
|
|
|
|
|
// Use whatever metadata is available.
|
2022-05-05 22:57:29 +00:00
|
|
|
//lint:ignore SA1019 we keed to keep backwards compat
|
2019-02-20 12:49:30 +00:00
|
|
|
pin.Metadata = opts.GetMetadata()
|
2022-05-05 22:37:59 +00:00
|
|
|
sortedMetadata := opts.GetSortedMetadata()
|
|
|
|
if len(sortedMetadata) > 0 && pin.Metadata == nil {
|
|
|
|
pin.Metadata = make(map[string]string, len(sortedMetadata))
|
|
|
|
}
|
|
|
|
for _, md := range opts.GetSortedMetadata() {
|
|
|
|
pin.Metadata[md.Key] = md.Value
|
|
|
|
}
|
|
|
|
|
2022-04-07 11:53:30 +00:00
|
|
|
pinUpdate, err := CastCid(opts.GetPinUpdate())
|
2019-07-12 14:40:29 +00:00
|
|
|
if err == nil {
|
|
|
|
pin.PinUpdate = pinUpdate
|
|
|
|
}
|
2020-04-17 11:36:05 +00:00
|
|
|
|
|
|
|
// We do not store the PinMode option but we can
|
|
|
|
// derive it from the MaxDepth setting.
|
2020-04-20 13:15:08 +00:00
|
|
|
pin.Mode = pin.MaxDepth.ToPinMode()
|
2021-07-01 23:42:51 +00:00
|
|
|
|
|
|
|
pbOrigins := opts.GetOrigins()
|
2021-12-13 16:31:18 +00:00
|
|
|
origins := make([]Multiaddr, len(pbOrigins))
|
2021-07-01 23:42:51 +00:00
|
|
|
for i, orig := range pbOrigins {
|
|
|
|
maOrig, err := multiaddr.NewMultiaddrBytes(orig)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-12-13 16:31:18 +00:00
|
|
|
origins[i] = NewMultiaddrWithValue(maOrig)
|
2021-07-01 23:42:51 +00:00
|
|
|
}
|
|
|
|
pin.Origins = origins
|
|
|
|
|
2019-02-19 17:59:46 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-01-16 10:21:34 +00:00
|
|
|
// Equals checks if two pins are the same (with the same allocations).
|
|
|
|
// If allocations are the same but in different order, they are still
|
|
|
|
// considered equivalent.
|
2022-03-19 01:52:46 +00:00
|
|
|
func (pin Pin) Equals(pin2 Pin) bool {
|
2019-02-27 17:04:35 +00:00
|
|
|
if !pin.Cid.Equals(pin2.Cid) {
|
2018-01-16 10:21:34 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-02-27 17:04:35 +00:00
|
|
|
if pin.Type != pin2.Type {
|
2018-03-18 19:29:02 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-02-27 17:04:35 +00:00
|
|
|
if pin.MaxDepth != pin2.MaxDepth {
|
2018-07-04 16:30:24 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-02-27 18:43:29 +00:00
|
|
|
if pin.Reference != nil && pin2.Reference == nil ||
|
|
|
|
pin.Reference == nil && pin2.Reference != nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if pin.Reference != nil && pin2.Reference != nil &&
|
|
|
|
!pin.Reference.Equals(*pin2.Reference) {
|
2018-03-01 19:52:10 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-02-27 17:04:35 +00:00
|
|
|
allocs1 := PeersToStrings(pin.Allocations)
|
|
|
|
sort.Strings(allocs1)
|
|
|
|
allocs2 := PeersToStrings(pin2.Allocations)
|
|
|
|
sort.Strings(allocs2)
|
2018-01-16 10:21:34 +00:00
|
|
|
|
2019-02-27 17:04:35 +00:00
|
|
|
if strings.Join(allocs1, ",") != strings.Join(allocs2, ",") {
|
2018-01-16 10:21:34 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2022-03-19 01:52:46 +00:00
|
|
|
return pin.PinOptions.Equals(pin2.PinOptions)
|
2018-01-16 10:21:34 +00:00
|
|
|
}
|
|
|
|
|
2018-06-07 02:19:15 +00:00
|
|
|
// IsRemotePin determines whether a Pin's ReplicationFactor has
|
|
|
|
// been met, so as to either pin or unpin it from the peer.
|
2022-03-19 01:52:46 +00:00
|
|
|
func (pin Pin) IsRemotePin(pid peer.ID) bool {
|
2021-03-23 23:47:15 +00:00
|
|
|
if pin.IsPinEverywhere() {
|
2018-06-07 02:19:15 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, p := range pin.Allocations {
|
|
|
|
if p == pid {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2019-09-18 16:05:55 +00:00
|
|
|
// ExpiredAt returns whether the pin has expired at the given time.
|
2022-03-19 01:52:46 +00:00
|
|
|
func (pin Pin) ExpiredAt(t time.Time) bool {
|
2019-11-05 09:11:50 +00:00
|
|
|
if pin.ExpireAt.IsZero() || pin.ExpireAt.Equal(unixZero) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
return pin.ExpireAt.Before(t)
|
2019-09-18 16:05:55 +00:00
|
|
|
}
|
|
|
|
|
2022-03-19 01:52:46 +00:00
|
|
|
// Defined returns true if this is not a zero-object pin (the CID must be set).
|
|
|
|
func (pin Pin) Defined() bool {
|
|
|
|
return pin.Cid.Defined()
|
|
|
|
}
|
|
|
|
|
2018-03-05 20:20:33 +00:00
|
|
|
// NodeWithMeta specifies a block of data and a set of optional metadata fields
|
|
|
|
// carrying information about the encoded ipld node
|
|
|
|
type NodeWithMeta struct {
|
2022-04-07 11:53:30 +00:00
|
|
|
Data []byte `codec:"d,omitempty"`
|
|
|
|
Cid Cid `codec:"c,omitempty"`
|
|
|
|
CumSize uint64 `codec:"s,omitempty"` // Cumulative size
|
2018-07-19 13:17:27 +00:00
|
|
|
}
|
|
|
|
|
2018-07-24 12:21:29 +00:00
|
|
|
// Size returns how big is the block. It is different from CumSize, which
|
|
|
|
// records the size of the underlying tree.
|
2018-07-19 13:17:27 +00:00
|
|
|
func (n *NodeWithMeta) Size() uint64 {
|
|
|
|
return uint64(len(n.Data))
|
2018-02-16 21:11:34 +00:00
|
|
|
}
|
|
|
|
|
2021-10-05 12:04:28 +00:00
|
|
|
// MetricsSet is a map to carry slices of metrics indexed by type.
|
2022-03-19 01:52:46 +00:00
|
|
|
type MetricsSet map[string][]Metric
|
2021-09-13 09:23:30 +00:00
|
|
|
|
2017-02-13 15:46:53 +00:00
|
|
|
// Metric transports information about a peer.ID. It is used to decide
|
|
|
|
// pin allocations by a PinAllocator. IPFS cluster is agnostic to
|
|
|
|
// the Value, which should be interpreted by the PinAllocator.
|
2019-03-21 01:51:03 +00:00
|
|
|
// The ReceivedAt value is a timestamp representing when a peer has received
|
2019-03-08 02:10:51 +00:00
|
|
|
// the metric value.
|
2017-02-13 15:46:53 +00:00
|
|
|
type Metric struct {
|
2021-10-06 12:10:06 +00:00
|
|
|
Name string `json:"name" codec:"n,omitempty"`
|
|
|
|
Peer peer.ID `json:"peer" codec:"p,omitempty"`
|
|
|
|
Value string `json:"value" codec:"v,omitempty"`
|
|
|
|
Expire int64 `json:"expire" codec:"e,omitempty"`
|
|
|
|
Valid bool `json:"valid" codec:"d,omitempty"`
|
|
|
|
Weight int64 `json:"weight" codec:"w,omitempty"`
|
|
|
|
Partitionable bool `json:"partitionable" codec:"o,omitempty"`
|
|
|
|
ReceivedAt int64 `json:"received_at" codec:"t,omitempty"` // ReceivedAt contains a UnixNano timestamp
|
2017-02-13 15:46:53 +00:00
|
|
|
}
|
|
|
|
|
2022-03-19 01:52:46 +00:00
|
|
|
func (m Metric) String() string {
|
|
|
|
return fmt.Sprintf("%s | %s | %s | Recv: %d | Exp: %d | W: %d | Part: %t | Valid: %t",
|
|
|
|
m.Name,
|
|
|
|
m.Peer,
|
|
|
|
m.Value,
|
|
|
|
m.ReceivedAt,
|
|
|
|
m.Expire,
|
|
|
|
m.Weight,
|
|
|
|
m.Partitionable,
|
|
|
|
m.Valid,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Defined returns true if the metric name is set.
|
|
|
|
func (m Metric) Defined() bool {
|
|
|
|
return m.Name != ""
|
|
|
|
}
|
|
|
|
|
2018-05-07 06:50:03 +00:00
|
|
|
// SetTTL sets Metric to expire after the given time.Duration
|
|
|
|
func (m *Metric) SetTTL(d time.Duration) {
|
Issue #162: Rework configuration format
The following commit reimplements ipfs-cluster configuration under
the following premises:
* Each component is initialized with a configuration object
defined by its module
* Each component decides how the JSON representation of its
configuration looks like
* Each component parses and validates its own configuration
* Each component exposes its own defaults
* Component configurations are make the sections of a
central JSON configuration file (which replaces the current
JSON format)
* Component configurations implement a common interface
(config.ComponentConfig) with a set of common operations
* The central configuration file is managed by a
config.ConfigManager which:
* Registers ComponentConfigs
* Assigns the correspondent sections from the JSON file to each
component and delegates the parsing
* Delegates the JSON generation for each section
* Can be notified when the configuration is updated and must be
saved to disk
The new service.json would then look as follows:
```json
{
"cluster": {
"id": "QmTVW8NoRxC5wBhV7WtAYtRn7itipEESfozWN5KmXUQnk2",
"private_key": "<...>",
"secret": "00224102ae6aaf94f2606abf69a0e278251ecc1d64815b617ff19d6d2841f786",
"peers": [],
"bootstrap": [],
"leave_on_shutdown": false,
"listen_multiaddress": "/ip4/0.0.0.0/tcp/9096",
"state_sync_interval": "1m0s",
"ipfs_sync_interval": "2m10s",
"replication_factor": -1,
"monitor_ping_interval": "15s"
},
"consensus": {
"raft": {
"heartbeat_timeout": "1s",
"election_timeout": "1s",
"commit_timeout": "50ms",
"max_append_entries": 64,
"trailing_logs": 10240,
"snapshot_interval": "2m0s",
"snapshot_threshold": 8192,
"leader_lease_timeout": "500ms"
}
},
"api": {
"restapi": {
"listen_multiaddress": "/ip4/127.0.0.1/tcp/9094",
"read_timeout": "30s",
"read_header_timeout": "5s",
"write_timeout": "1m0s",
"idle_timeout": "2m0s"
}
},
"ipfs_connector": {
"ipfshttp": {
"proxy_listen_multiaddress": "/ip4/127.0.0.1/tcp/9095",
"node_multiaddress": "/ip4/127.0.0.1/tcp/5001",
"connect_swarms_delay": "7s",
"proxy_read_timeout": "10m0s",
"proxy_read_header_timeout": "5s",
"proxy_write_timeout": "10m0s",
"proxy_idle_timeout": "1m0s"
}
},
"monitor": {
"monbasic": {
"check_interval": "15s"
}
},
"informer": {
"disk": {
"metric_ttl": "30s",
"metric_type": "freespace"
},
"numpin": {
"metric_ttl": "10s"
}
}
}
```
This new format aims to be easily extensible per component. As such,
it already surfaces quite a few new options which were hardcoded
before.
Additionally, since Go API have changed, some redundant methods have been
removed and small refactoring has happened to take advantage of the new
way.
License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
2017-10-11 18:23:03 +00:00
|
|
|
exp := time.Now().Add(d)
|
2018-04-05 14:09:41 +00:00
|
|
|
m.Expire = exp.UnixNano()
|
2017-02-13 15:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetTTL returns the time left before the Metric expires
|
2022-03-19 01:52:46 +00:00
|
|
|
func (m Metric) GetTTL() time.Duration {
|
2018-04-05 14:09:41 +00:00
|
|
|
expDate := time.Unix(0, m.Expire)
|
2021-10-05 12:04:28 +00:00
|
|
|
ttl := time.Until(expDate)
|
|
|
|
if ttl < 0 {
|
|
|
|
ttl = 0
|
|
|
|
}
|
|
|
|
return ttl
|
2017-02-13 15:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Expired returns if the Metric has expired
|
2022-03-19 01:52:46 +00:00
|
|
|
func (m Metric) Expired() bool {
|
2018-04-05 14:09:41 +00:00
|
|
|
expDate := time.Unix(0, m.Expire)
|
|
|
|
return time.Now().After(expDate)
|
2017-02-13 15:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Discard returns if the metric not valid or has expired
|
2022-03-19 01:52:46 +00:00
|
|
|
func (m Metric) Discard() bool {
|
2017-02-13 15:46:53 +00:00
|
|
|
return !m.Valid || m.Expired()
|
|
|
|
}
|
|
|
|
|
2022-05-05 09:19:57 +00:00
|
|
|
// GetWeight returns the weight of the metric.
|
2022-06-15 10:16:05 +00:00
|
|
|
// This is for compatibility.
|
2022-03-19 01:52:46 +00:00
|
|
|
func (m Metric) GetWeight() int64 {
|
2022-05-05 09:19:57 +00:00
|
|
|
return m.Weight
|
2021-10-06 12:10:06 +00:00
|
|
|
}
|
|
|
|
|
2019-10-24 14:37:26 +00:00
|
|
|
// MetricSlice is a sortable Metric array.
|
2022-03-19 01:52:46 +00:00
|
|
|
type MetricSlice []Metric
|
2019-10-24 14:37:26 +00:00
|
|
|
|
|
|
|
func (es MetricSlice) Len() int { return len(es) }
|
|
|
|
func (es MetricSlice) Swap(i, j int) { es[i], es[j] = es[j], es[i] }
|
|
|
|
func (es MetricSlice) Less(i, j int) bool {
|
|
|
|
if es[i].Peer == es[j].Peer {
|
|
|
|
return es[i].Expire < es[j].Expire
|
|
|
|
}
|
|
|
|
return es[i].Peer < es[j].Peer
|
|
|
|
}
|
|
|
|
|
2021-01-13 21:09:21 +00:00
|
|
|
// Alert carries alerting information about a peer.
|
2017-02-13 15:46:53 +00:00
|
|
|
type Alert struct {
|
2021-01-13 21:09:21 +00:00
|
|
|
Metric
|
|
|
|
TriggeredAt time.Time `json:"triggered_at" codec:"r,omitempty"`
|
2017-02-13 15:46:53 +00:00
|
|
|
}
|
2017-03-28 15:48:26 +00:00
|
|
|
|
|
|
|
// Error can be used by APIs to return errors.
|
|
|
|
type Error struct {
|
2019-02-27 17:04:35 +00:00
|
|
|
Code int `json:"code" codec:"o,omitempty"`
|
|
|
|
Message string `json:"message" codec:"m,omitempty"`
|
2017-03-28 15:48:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Error implements the error interface and returns the error's message.
|
2022-03-11 15:18:08 +00:00
|
|
|
func (e Error) Error() string {
|
2017-12-08 14:39:30 +00:00
|
|
|
return fmt.Sprintf("%s (%d)", e.Message, e.Code)
|
2017-03-28 15:48:26 +00:00
|
|
|
}
|
2018-08-20 18:43:27 +00:00
|
|
|
|
|
|
|
// IPFSRepoStat wraps information about the IPFS repository.
|
|
|
|
type IPFSRepoStat struct {
|
2019-02-27 17:04:35 +00:00
|
|
|
RepoSize uint64 `codec:"r,omitempty"`
|
|
|
|
StorageMax uint64 `codec:"s, omitempty"`
|
2018-08-20 18:43:27 +00:00
|
|
|
}
|
2019-10-22 05:40:32 +00:00
|
|
|
|
|
|
|
// IPFSRepoGC represents the streaming response sent from repo gc API of IPFS.
|
|
|
|
type IPFSRepoGC struct {
|
2022-04-07 11:53:30 +00:00
|
|
|
Key Cid `json:"key,omitempty" codec:"k,omitempty"`
|
|
|
|
Error string `json:"error,omitempty" codec:"e,omitempty"`
|
2019-10-22 05:40:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// RepoGC contains garbage collected CIDs from a cluster peer's IPFS daemon.
|
|
|
|
type RepoGC struct {
|
|
|
|
Peer peer.ID `json:"peer" codec:"p,omitempty"` // the Cluster peer ID
|
|
|
|
Peername string `json:"peername" codec:"pn,omitempty"`
|
|
|
|
Keys []IPFSRepoGC `json:"keys" codec:"k"`
|
|
|
|
Error string `json:"error,omitempty" codec:"e,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// GlobalRepoGC contains cluster-wide information about garbage collected CIDs
|
|
|
|
// from IPFS.
|
|
|
|
type GlobalRepoGC struct {
|
2022-03-19 01:52:46 +00:00
|
|
|
PeerMap map[string]RepoGC `json:"peer_map" codec:"pm,omitempty"`
|
2019-10-22 05:40:32 +00:00
|
|
|
}
|