Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bffa0300df | ||
|
|
691f8625be | ||
|
|
177ab398cc | ||
|
|
02ce4e9b23 | ||
|
|
460554fb6e | ||
|
|
5d17ab8c70 |
@@ -1 +1 @@
|
||||
0.7.0: QmbTGYCo96Z9hiG37D9zeErFo5GjrEPcqdh7PJX1HTM73E
|
||||
0.7.5: QmcEcrBAMrwMyhSjXt4yfyPpzgSuV8HLHavnfmiKCSRqZU
|
||||
|
||||
9
cid.go
9
cid.go
@@ -19,7 +19,10 @@ const (
|
||||
|
||||
EthereumBlock = 0x90
|
||||
EthereumTx = 0x91
|
||||
Bitcoin = 0xb0
|
||||
BitcoinBlock = 0xb0
|
||||
BitcoinTx = 0xb1
|
||||
ZcashBlock = 0xc0
|
||||
ZcashTx = 0xc1
|
||||
)
|
||||
|
||||
func NewCidV0(h mh.Multihash) *Cid {
|
||||
@@ -45,6 +48,10 @@ type Cid struct {
|
||||
}
|
||||
|
||||
func Decode(v string) (*Cid, error) {
|
||||
if len(v) < 2 {
|
||||
return nil, fmt.Errorf("cid too short")
|
||||
}
|
||||
|
||||
if len(v) == 46 && v[:2] == "Qm" {
|
||||
hash, err := mh.FromB58String(v)
|
||||
if err != nil {
|
||||
|
||||
@@ -52,6 +52,13 @@ func TestBasicMarshaling(t *testing.T) {
|
||||
assertEqual(t, cid, out2)
|
||||
}
|
||||
|
||||
func TestEmptyString(t *testing.T) {
|
||||
_, err := Decode("")
|
||||
if err == nil {
|
||||
t.Fatal("shouldnt be able to parse an empty cid")
|
||||
}
|
||||
}
|
||||
|
||||
func TestV0Handling(t *testing.T) {
|
||||
old := "QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n"
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
},
|
||||
{
|
||||
"author": "whyrusleeping",
|
||||
"hash": "QmYiTi9mKBMjfiup7na7PhJK7QEZPdMTJenLdgFYVQ2NUv",
|
||||
"hash": "QmUq3H9YpcPphbRj6ct6rBgBE377A8wANP8zPMRqe1WYbf",
|
||||
"name": "go-multibase",
|
||||
"version": "0.2.0"
|
||||
"version": "0.2.1"
|
||||
}
|
||||
],
|
||||
"gxVersion": "0.8.0",
|
||||
@@ -25,6 +25,6 @@
|
||||
"license": "",
|
||||
"name": "go-cid",
|
||||
"releaseCmd": "git commit -a -m \"gx publish $VERSION\"",
|
||||
"version": "0.7.0"
|
||||
"version": "0.7.5"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user