Skip to content

Commit 64b5aa8

Browse files
authored
Merge pull request #64 from multiformats/feat/fast-b58
use a faster base58 library
2 parents 11a0a5f + cc384a5 commit 64b5aa8

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

multihash.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"fmt"
1111
"math"
1212

13-
b58 "github.com/jbenet/go-base58"
13+
b58 "github.com/mr-tron/base58/base58"
1414
)
1515

1616
// errors
@@ -197,17 +197,8 @@ func (m Multihash) B58String() string {
197197

198198
// FromB58String parses a B58-encoded multihash.
199199
func FromB58String(s string) (m Multihash, err error) {
200-
// panic handler, in case we try accessing bytes incorrectly.
201-
defer func() {
202-
if e := recover(); e != nil {
203-
m = Multihash{}
204-
err = e.(error)
205-
}
206-
}()
207-
208-
//b58 smells like it can panic...
209-
b := b58.Decode(s)
210-
if len(b) == 0 {
200+
b, err := b58.Decode(s)
201+
if err != nil {
211202
return Multihash{}, ErrInvalidMultihash
212203
}
213204

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
"version": "0.0.0"
1515
},
1616
{
17-
"author": "whyrusleeping",
18-
"hash": "QmT8rehPR3F6bmwL6zjUN8XpiDBFFpMP2myPdC6ApsWfJf",
19-
"name": "go-base58",
20-
"version": "0.0.0"
17+
"author": "mr-tron",
18+
"hash": "QmWFAMPqsEyUX7gDUsRVmMWz59FxSpJ1b2v6bJ1yYzo7jY",
19+
"name": "go-base58-fast",
20+
"version": "0.1.1"
2121
},
2222
{
2323
"author": "whyrusleeping",

0 commit comments

Comments
 (0)