338 Commits

Author SHA1 Message Date
dependabot[bot]
72c7f21dcd chore(deps): bump github.com/multiformats/go-multibase
Bumps [github.com/multiformats/go-multibase](https://github.com/multiformats/go-multibase) from 0.0.3 to 0.2.0.
- [Release notes](https://github.com/multiformats/go-multibase/releases)
- [Commits](https://github.com/multiformats/go-multibase/compare/v0.0.3...v0.2.0)

---
updated-dependencies:
- dependency-name: github.com/multiformats/go-multibase
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-05 12:50:34 +10:00
dependabot-preview[bot]
93a8da769f Upgrade to GitHub-native Dependabot 2023-04-04 14:13:57 +10:00
Rod Vagg
d46e7f2866 v0.4.1 v0.4.1 2023-04-04 14:08:15 +10:00
gammazero
83a0e939a4 Add unit test for unexpected eof 2023-04-04 14:08:15 +10:00
Andrew Gillis
0981f8566c Update cid.go
Co-authored-by: Rod Vagg <rod@vagg.org>
2023-04-04 14:08:15 +10:00
gammazero
166a3a6880 CidFromReader should not wrap valid EOF return.
When reading from an io.Reader that has no data, the io.EOF error should not be wrapped in ErrInvalidCid. This is not an invalid CID, and is not the same as a partial read which is indicated by io.ErrUnexpectedEOF.

This fix is needed because existing code that uses CidFromReader may check for the end of an input stream by `if err == io.EOF` instead of the preferred `if errors.Is(err, io.EOF)`, and that code break at runtime after upgrading to go-cid v0.4.0.
2023-04-04 14:08:15 +10:00
Henrique Dias
8098d66787 chore: version 0.4.0 v0.4.0 2023-03-20 09:29:34 +01:00
Henrique Dias
b98e249130 feat: wrap parsing errors into ErrInvalidCid 2023-03-20 09:29:34 +01:00
dependabot[bot]
85c423677c build(deps): bump golang.org/x/crypto
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.0.0-20210506145944-38f3c27a63bf to 0.1.0.
- [Release notes](https://github.com/golang/crypto/releases)
- [Commits](https://github.com/golang/crypto/commits/v0.1.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-27 17:42:17 +11:00
dependabot[bot]
197da0b712 build(deps): bump golang.org/x/sys
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.0.0-20210309074719-68d13333faf2 to 0.1.0.
- [Release notes](https://github.com/golang/sys/releases)
- [Commits](https://github.com/golang/sys/commits/v0.1.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-27 16:12:56 +11:00
Rod Vagg
06fe289a6a fix: use crypto/rand.Read 2023-02-09 15:30:24 +11:00
web3-bot
a1630a3bd9 update .github/workflows/release-check.yml 2023-02-09 15:30:24 +11:00
web3-bot
225f5db116 update .github/workflows/go-check.yml 2023-02-09 15:30:24 +11:00
web3-bot
c2c040dac7 update .github/workflows/go-test.yml 2023-02-09 15:30:24 +11:00
web3-bot
b729e38c6e bump go.mod to Go 1.19 and run go fix 2023-02-09 15:30:24 +11:00
Nikhilesh Susarla
823c6b8a59 Fix README.md example error (#146) 2022-10-19 17:17:54 +11:00
Jorropo
350d6afb62 chore: release v0.3.2 v0.3.2 2022-09-04 16:00:09 +02:00
Jorropo
68090a8273 Revert "fix: bring back, but deprecate CodecToStr and Codecs"
This reverts commit 548365f3a7.
2022-09-04 16:00:09 +02:00
Jorropo
69784e9dd7 chore: release v0.2.1 v0.3.1 2022-09-04 13:03:33 +02:00
Rod Vagg
548365f3a7 fix: bring back, but deprecate CodecToStr and Codecs
use go-multicodec as the source of truth
2022-09-04 13:03:33 +02:00
web3-bot
5da28005a9 update .github/workflows/go-check.yml 2022-08-25 15:55:13 +10:00
web3-bot
7f6771bc54 update .github/workflows/go-test.yml 2022-08-25 15:55:13 +10:00
web3-bot
5b6a9dce73 run gofmt -s 2022-08-25 15:55:13 +10:00
web3-bot
890f55d9f3 bump go.mod to Go 1.18 and run go fix 2022-08-25 15:55:13 +10:00
Jorropo
085afa84d0 chore: release v0.3.0 v0.3.0 2022-08-25 05:34:36 +02:00
Jorropo
0052a62190 fix: return nil Bytes() if the Cid in undef 2022-08-25 05:34:36 +02:00
GitHub
802b45594e chore: Update .github/workflows/stale.yml [skip ci] 2022-07-21 09:54:55 +00:00
Steven Allen
8f7d7ac18e Merge pull request #139 from mg98/feat/must-parse
Add MustParse
2022-06-27 08:55:37 -07:00
GitHub
b106e0883a Update .github/workflows/stale.yml 2022-06-27 10:45:49 +00:00
Marcel Gregoriadis
386c6cc18a Add MustParse 2022-06-24 17:35:23 +02:00
ipfs-mgmt-read-write[bot]
f4b3e66993 Add .github/workflows/stale.yml 2022-06-13 12:53:24 +00:00
Marcin Rataj
b2064d74a8 fix: remove invalid multicodec2string mappings (#137)
* refactor: remove Codecs table
* chore: go-cid 0.2.0

Codec table was missing dag-json and it had invalid code for dag-cbor.
It also had invalid string representation of dag-pb -- it was using
'protobuf' which is a totally different code.

This removes invalid mappings entirely.
https://github.com/multiformats/go-multicodec should be used instead.
v0.2.0
2022-04-21 22:39:31 +02:00
web3-bot
ddd9ef7248 update .github/workflows/go-check.yml 2022-04-05 09:32:38 +10:00
web3-bot
6be8b631d0 update .github/workflows/go-test.yml 2022-04-05 09:32:38 +10:00
web3-bot
395d392889 update .github/workflows/automerge.yml 2022-04-05 09:32:38 +10:00
web3-bot
1d11990417 bump go.mod to Go 1.17 and run go fix 2022-04-05 09:32:38 +10:00
web3-bot
dc3bb41324 sync: update CI config files (#136)
* add version.json file

* update .github/workflows/go-test.yml

* update .github/workflows/go-check.yml

* add .github/workflows/releaser.yml

* add .github/workflows/release-check.yml

* add .github/workflows/tagpush.yml

Co-authored-by: web3-bot <web3-bot@users.noreply.github.com>
2021-12-13 12:26:14 +01:00
Masih H. Derkani
28f4a5eab6 Benchmark existing ways to check for IDENTITY CIDs
Add benchmarks that compare two ways of checking for
`multihash.IDENTITY` code:
1. `Cid.Prefix().MhType`
2. Decode of `Cid.Hash()`

This benchmark illustrates that using Cid.Prefix is more efficient than
`multihash.Decode`. Users wishing to perform such a check should use
`Cid.Prefix`.

Consider that `Cid.Prefix` is already efficient enough and introducing a
dedicated API for performing this check will likely result in small
gains.

Relates to #133
2021-11-08 14:52:45 +00:00
Daniel Martí
5640b0169f avoid double alloc in NewCidV1
We allocate once via "make([]byte, len)",
and again when that buffer is converted to a string.

Thankfully, since Go 1.10 we have strings.Builder,
designed specifically for this use case.

In a downstream benchmark in go-car,
which needs to reconstruct many CID values,
we see small but nice gains:

    name           old time/op    new time/op    delta
    ReadBlocks-16    1.09ms ± 4%    1.06ms ± 5%   -3.33%  (p=0.007 n=11+11)

    name           old speed      new speed      delta
    ReadBlocks-16   478MB/s ± 4%   494MB/s ± 5%   +3.46%  (p=0.007 n=11+11)

    name           old alloc/op   new alloc/op   delta
    ReadBlocks-16    1.30MB ± 0%    1.25MB ± 0%   -3.86%  (p=0.000 n=12+12)

    name           old allocs/op  new allocs/op  delta
    ReadBlocks-16     9.50k ± 0%     8.45k ± 0%  -11.05%  (p=0.000 n=12+12)
2021-09-12 14:08:59 +02:00
Steven Allen
cf76220258 Merge pull request #131 from ipfs/web3-bot/sync
sync: update CI config files
2021-08-30 08:37:22 -07:00
web3-bot
9e2855d9ff update .github/workflows/go-check.yml 2021-08-17 13:32:06 +00:00
web3-bot
b8eba8ea35 update .github/workflows/go-test.yml 2021-08-17 13:32:06 +00:00
web3-bot
2628583977 update .github/workflows/automerge.yml 2021-08-17 13:32:06 +00:00
web3-bot
6e96c56557 run gofmt -s 2021-08-17 13:32:05 +00:00
web3-bot
44cccd62db bump go.mod to Go 1.16 and run go fix 2021-08-17 13:32:05 +00:00
Daniel Martí
de6c03deae amend the CidFromReader slice extension math
The append+make slice extension idiom works, but note that append uses
the slice's length as its base. We need to append the number of bytes
required for length to reach cidLength, not the capacity.

The added test case panicked before this change, and works now:

	--- FAIL: TestReadCidsFromBuffer (0.00s)
	panic: runtime error: slice bounds out of range [:73] with capacity 64 [recovered]
		panic: runtime error: slice bounds out of range [:73] with capacity 64

	goroutine 37 [running]:
	testing.tRunner.func1.2({0x570d60, 0xc000016438})
		testing/testing.go:1203 +0x24e
	testing.tRunner.func1()
		testing/testing.go:1206 +0x218
	panic({0x570d60, 0xc000016438})
		runtime/panic.go:1038 +0x215
	github.com/ipfs/go-cid.CidFromReader({0x5b0e20, 0xc000010900})
		github.com/ipfs/go-cid/cid.go:803 +0x75f
	github.com/ipfs/go-cid.TestReadCidsFromBuffer(0xc00014ba00)
		github.com/ipfs/go-cid/cid_test.go:710 +0x625
	testing.tRunner(0xc00014ba00, 0x58af38)
		testing/testing.go:1253 +0x102
	created by testing.(*T).Run
		testing/testing.go:1300 +0x35a
	exit status 2
	FAIL	github.com/ipfs/go-cid	0.004s
v0.1.0
2021-07-16 10:10:50 +01:00
Daniel Martí
c4c8760a80 implement CidFromReader
And reuse two CidFromBytes tests for it, which includes both CIDv0 and
CIDv1 cases as inputs, as well as some inputs that should error.

Fixes #126.
2021-07-15 01:01:22 +01:00
Steven Allen
8e9280df3d Merge pull request #118 from ipfs/multihash-update
Update go-multihash.  Now uses registry system.
2021-06-25 17:23:48 -07:00
Eric Myhre
b4bcfe45c9 Update go-multihash.
You can't see it from here, but go-mulithash now uses registry system,
so it's reasonably possible to introduce new hashers, and to use
(some parts of!) go-multihash without bringing in lots of transitive
dependencies.

The main package of go-multihash still brings in everything
transitively that it did before, so go-cid's transitives aren't
shrinking, and no code is changing here... but it's closer.
If we did cut over to the new go-mulithash/core, we could make
many transitive dependencies become optional.
2021-06-25 16:05:47 -07:00
Marten Seemann
979bf3fb85 Merge pull request #125 from ipfs/web3-bot/sync
sync: update CI config files
2021-06-01 12:40:31 -07:00