@cryptotaxi247 / kubo / commits / b5b18e23e

fix: remove old unused buggy coredag code

Jorropo committed Nov 2, 2022 at 16:10 UTC b5b18e23e78081811355085c0c206cc056065525
5 files changed +7 -228
core/coredag/cbor.go deleted
-31
@@ -1,31 +0,0 @@
1 -package coredag
2 -
3 -import (
4 - "io"
5 -
6 - ipldcbor "github.com/ipfs/go-ipld-cbor"
7 - ipld "github.com/ipfs/go-ipld-format"
8 -)
9 -
10 -func cborJSONParser(r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
11 - nd, err := ipldcbor.FromJSON(r, mhType, mhLen)
12 - if err != nil {
13 - return nil, err
14 - }
15 -
16 - return []ipld.Node{nd}, nil
17 -}
18 -
19 -func cborRawParser(r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
20 - data, err := io.ReadAll(r)
21 - if err != nil {
22 - return nil, err
23 - }
24 -
25 - nd, err := ipldcbor.Decode(data, mhType, mhLen)
26 - if err != nil {
27 - return nil, err
28 - }
29 -
30 - return []ipld.Node{nd}, nil
31 -}
core/coredag/dagpb.go deleted
-65
@@ -1,65 +0,0 @@
1 -package coredag
2 -
3 -import (
4 - "io"
5 - "math"
6 -
7 - "github.com/ipfs/go-merkledag"
8 -
9 - cid "github.com/ipfs/go-cid"
10 - ipld "github.com/ipfs/go-ipld-format"
11 - mh "github.com/multiformats/go-multihash"
12 -)
13 -
14 -func dagpbJSONParser(r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
15 - data, err := io.ReadAll(r)
16 - if err != nil {
17 - return nil, err
18 - }
19 -
20 - nd := &merkledag.ProtoNode{}
21 -
22 - err = nd.UnmarshalJSON(data)
23 - if err != nil {
24 - return nil, err
25 - }
26 -
27 - nd.SetCidBuilder(cidPrefix(mhType, mhLen))
28 -
29 - return []ipld.Node{nd}, nil
30 -}
31 -
32 -func dagpbRawParser(r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
33 - data, err := io.ReadAll(r)
34 - if err != nil {
35 - return nil, err
36 - }
37 -
38 - nd, err := merkledag.DecodeProtobuf(data)
39 - if err != nil {
40 - return nil, err
41 - }
42 -
43 - nd.SetCidBuilder(cidPrefix(mhType, mhLen))
44 -
45 - return []ipld.Node{nd}, nil
46 -}
47 -
48 -func cidPrefix(mhType uint64, mhLen int) *cid.Prefix {
49 - if mhType == math.MaxUint64 {
50 - mhType = mh.SHA2_256
51 - }
52 -
53 - prefix := &cid.Prefix{
54 - MhType: mhType,
55 - MhLength: mhLen,
56 - Version: 1,
57 - Codec: cid.DagProtobuf,
58 - }
59 -
60 - if mhType == mh.SHA2_256 {
61 - prefix.Version = 0
62 - }
63 -
64 - return prefix
65 -}
core/coredag/dagtransl.go deleted
-86
@@ -1,86 +0,0 @@
1 -package coredag
2 -
3 -import (
4 - "fmt"
5 - "io"
6 -
7 - ipld "github.com/ipfs/go-ipld-format"
8 -)
9 -
10 -// DagParser is function used for parsing stream into Node
11 -type DagParser func(r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error)
12 -
13 -// FormatParsers is used for mapping format descriptors to DagParsers
14 -type FormatParsers map[string]DagParser
15 -
16 -// InputEncParsers is used for mapping input encodings to FormatParsers
17 -type InputEncParsers map[string]FormatParsers
18 -
19 -// DefaultInputEncParsers is InputEncParser that is used everywhere
20 -var DefaultInputEncParsers = InputEncParsers{
21 - "json": defaultJSONParsers,
22 - "raw": defaultRawParsers,
23 - "cbor": defaultCborParsers,
24 - "protobuf": defaultProtobufParsers,
25 -}
26 -
27 -var defaultJSONParsers = FormatParsers{
28 - "cbor": cborJSONParser,
29 - "dag-cbor": cborJSONParser,
30 -
31 - "protobuf": dagpbJSONParser,
32 - "dag-pb": dagpbJSONParser,
33 -}
34 -
35 -var defaultRawParsers = FormatParsers{
36 - "cbor": cborRawParser,
37 - "dag-cbor": cborRawParser,
38 -
39 - "protobuf": dagpbRawParser,
40 - "dag-pb": dagpbRawParser,
41 -
42 - "raw": rawRawParser,
43 -}
44 -
45 -var defaultCborParsers = FormatParsers{
46 - "cbor": cborRawParser,
47 - "dag-cbor": cborRawParser,
48 -}
49 -
50 -var defaultProtobufParsers = FormatParsers{
51 - "protobuf": dagpbRawParser,
52 - "dag-pb": dagpbRawParser,
53 -}
54 -
55 -// ParseInputs uses DefaultInputEncParsers to parse io.Reader described by
56 -// input encoding and format to an instance of ipld Node
57 -func ParseInputs(ienc, format string, r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
58 - return DefaultInputEncParsers.ParseInputs(ienc, format, r, mhType, mhLen)
59 -}
60 -
61 -// AddParser adds DagParser under give input encoding and format
62 -func (iep InputEncParsers) AddParser(ienc, format string, f DagParser) {
63 - m, ok := iep[ienc]
64 - if !ok {
65 - m = make(FormatParsers)
66 - iep[ienc] = m
67 - }
68 -
69 - m[format] = f
70 -}
71 -
72 -// ParseInputs parses io.Reader described by input encoding and format to
73 -// an instance of ipld Node
74 -func (iep InputEncParsers) ParseInputs(ienc, format string, r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
75 - parsers, ok := iep[ienc]
76 - if !ok {
77 - return nil, fmt.Errorf("no input parser for %q", ienc)
78 - }
79 -
80 - parser, ok := parsers[format]
81 - if !ok {
82 - return nil, fmt.Errorf("no parser for format %q using input type %q", format, ienc)
83 - }
84 -
85 - return parser(r, mhType, mhLen)
86 -}
core/coredag/raw.go deleted
-36
@@ -1,36 +0,0 @@
1 -package coredag
2 -
3 -import (
4 - "io"
5 - "math"
6 -
7 - "github.com/ipfs/go-merkledag"
8 -
9 - block "github.com/ipfs/go-block-format"
10 - cid "github.com/ipfs/go-cid"
11 - ipld "github.com/ipfs/go-ipld-format"
12 - mh "github.com/multiformats/go-multihash"
13 -)
14 -
15 -func rawRawParser(r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
16 - if mhType == math.MaxUint64 {
17 - mhType = mh.SHA2_256
18 - }
19 -
20 - data, err := io.ReadAll(r)
21 - if err != nil {
22 - return nil, err
23 - }
24 -
25 - h, err := mh.Sum(data, mhType, mhLen)
26 - if err != nil {
27 - return nil, err
28 - }
29 - c := cid.NewCidV1(cid.Raw, h)
30 - blk, err := block.NewBlockWithCid(data, c)
31 - if err != nil {
32 - return nil, err
33 - }
34 - nd := &merkledag.RawNode{Block: blk}
35 - return []ipld.Node{nd}, nil
36 -}
go.mod
+7 -10
@@ -3,6 +3,7 @@ module github.com/ipfs/kubo
3 require (
4 bazil.org/fuse v0.0.0-20200117225306-7b5117fecadc
5 contrib.go.opencensus.io/exporter/prometheus v0.4.0
6 + github.com/benbjohnson/clock v1.3.0
7 github.com/blang/semver/v4 v4.0.0
8 github.com/cenkalti/backoff/v4 v4.1.3
9 github.com/ceramicnetwork/go-dag-jose v0.1.0
@@ -21,6 +22,7 @@ require (
22 github.com/ipfs/go-cid v0.3.2
23 github.com/ipfs/go-cidutil v0.1.0
24 github.com/ipfs/go-datastore v0.6.0
25 + github.com/ipfs/go-delegated-routing v0.7.0
26 github.com/ipfs/go-detect-race v0.0.1
27 github.com/ipfs/go-ds-badger v0.3.0
28 github.com/ipfs/go-ds-flatfs v0.5.1
@@ -40,14 +42,15 @@ require (
42 github.com/ipfs/go-ipfs-pinner v0.2.1
43 github.com/ipfs/go-ipfs-posinfo v0.0.1
44 github.com/ipfs/go-ipfs-provider v0.7.1
45 + github.com/ipfs/go-ipfs-redirects-file v0.1.1
46 github.com/ipfs/go-ipfs-routing v0.2.1
47 github.com/ipfs/go-ipfs-util v0.0.2
45 - github.com/ipfs/go-ipld-cbor v0.0.5
48 github.com/ipfs/go-ipld-format v0.4.0
49 github.com/ipfs/go-ipld-git v0.1.1
50 github.com/ipfs/go-ipld-legacy v0.1.1
51 github.com/ipfs/go-ipns v0.3.0
52 github.com/ipfs/go-log v1.0.5
53 + github.com/ipfs/go-log/v2 v2.5.1
54 github.com/ipfs/go-merkledag v0.6.0
55 github.com/ipfs/go-metrics-interface v0.0.1
56 github.com/ipfs/go-metrics-prometheus v0.0.2
@@ -69,7 +72,6 @@ require (
72 github.com/jbenet/goprocess v0.1.4
73 github.com/libp2p/go-doh-resolver v0.4.0
74 github.com/libp2p/go-libp2p v0.23.2
72 - github.com/libp2p/go-libp2p-core v0.20.1 // indirect
75 github.com/libp2p/go-libp2p-http v0.2.1
76 github.com/libp2p/go-libp2p-kad-dht v0.18.0
77 github.com/libp2p/go-libp2p-kbucket v0.4.7
@@ -90,7 +92,6 @@ require (
92 github.com/opentracing/opentracing-go v1.2.0
93 github.com/pkg/errors v0.9.1
94 github.com/prometheus/client_golang v1.13.0
93 - github.com/prometheus/common v0.37.0 // indirect
95 github.com/stretchr/testify v1.8.0
96 github.com/syndtr/goleveldb v1.0.0
97 github.com/wI2L/jsondiff v0.2.0
@@ -114,13 +115,6 @@ require (
115 golang.org/x/sys v0.0.0-20220915200043-7b5979e65e41
116 )
117
117 -require (
118 - github.com/benbjohnson/clock v1.3.0
119 - github.com/ipfs/go-delegated-routing v0.7.0
120 - github.com/ipfs/go-ipfs-redirects-file v0.1.1
121 - github.com/ipfs/go-log/v2 v2.5.1
122 -)
123 -
118 require (
119 github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 // indirect
120 github.com/Kubuxu/go-os-helper v0.0.1 // indirect
@@ -167,6 +161,7 @@ require (
161 github.com/ipfs/go-ipfs-delay v0.0.1 // indirect
162 github.com/ipfs/go-ipfs-ds-help v1.1.0 // indirect
163 github.com/ipfs/go-ipfs-pq v0.0.2 // indirect
164 + github.com/ipfs/go-ipld-cbor v0.0.5 // indirect
165 github.com/ipfs/go-peertaskqueue v0.7.1 // indirect
166 github.com/ipld/edelweiss v0.2.0 // indirect
167 github.com/jackpal/go-nat-pmp v1.0.2 // indirect
@@ -177,6 +172,7 @@ require (
172 github.com/libp2p/go-cidranger v1.1.0 // indirect
173 github.com/libp2p/go-flow-metrics v0.1.0 // indirect
174 github.com/libp2p/go-libp2p-asn-util v0.2.0 // indirect
175 + github.com/libp2p/go-libp2p-core v0.20.1 // indirect
176 github.com/libp2p/go-libp2p-discovery v0.7.0 // indirect
177 github.com/libp2p/go-libp2p-gostream v0.3.0 // indirect
178 github.com/libp2p/go-libp2p-swarm v0.11.0 // indirect
@@ -218,6 +214,7 @@ require (
214 github.com/pmezard/go-difflib v1.0.0 // indirect
215 github.com/polydawn/refmt v0.0.0-20201211092308-30ac6d18308e // indirect
216 github.com/prometheus/client_model v0.2.0 // indirect
217 + github.com/prometheus/common v0.37.0 // indirect
218 github.com/prometheus/procfs v0.8.0 // indirect
219 github.com/prometheus/statsd_exporter v0.21.0 // indirect
220 github.com/raulk/go-watchdog v1.3.0 // indirect