Compare commits

...

6 Commits

Author SHA1 Message Date
Jeromy
bffa0300df gx publish 0.7.5 2016-11-10 10:26:33 -08:00
Jeromy
691f8625be add zcash multicodecs to table 2016-11-10 10:26:18 -08:00
Jeromy
177ab398cc gx publish 0.7.3 2016-10-24 17:31:04 -07:00
Jeromy
02ce4e9b23 fix decoding of empty strings 2016-10-24 17:30:53 -07:00
Jeromy
460554fb6e gx publish 0.7.2 2016-10-24 09:16:05 -07:00
Jeromy
5d17ab8c70 add bitcoin tx value 2016-10-24 09:10:06 -07:00
4 changed files with 19 additions and 5 deletions

View File

@@ -1 +1 @@
0.7.0: QmbTGYCo96Z9hiG37D9zeErFo5GjrEPcqdh7PJX1HTM73E
0.7.5: QmcEcrBAMrwMyhSjXt4yfyPpzgSuV8HLHavnfmiKCSRqZU

9
cid.go
View File

@@ -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 {

View File

@@ -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"

View File

@@ -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"
}