Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p
Commits
d4b42f8e
Commit
d4b42f8e
authored
Nov 15, 2015
by
Jeromy
Browse files
fixes for sha3
parent
8f79df77
Changes
127
Hide whitespace changes
Inline
Side-by-side
vendor/Qm
VdADza4QFVAR9xqAxRQjt9vTZJ6UrVLgBstKua1Xg7he
/multiaddr-filter/mask_test.go
→
vendor/Qm
YWqTn1i8yv9QRDzGPJ2yRudKzYCaC5Aqasbm8vwaG92E
/multiaddr-filter/mask_test.go
View file @
d4b42f8e
File moved
vendor/Qm
VdADza4QFVAR9xqAxRQjt9vTZJ6UrVLgBstKua1Xg7he
/multiaddr-filter/package.json
→
vendor/Qm
YWqTn1i8yv9QRDzGPJ2yRudKzYCaC5Aqasbm8vwaG92E
/multiaddr-filter/package.json
View file @
d4b42f8e
...
...
@@ -5,7 +5,7 @@
"gxDependencies"
:
[
{
"name"
:
"go-multiaddr-net"
,
"hash"
:
"Qm
anZCL6SXRfafiUEMCBLq2QR171uQSdXQ8YAdHXLd8Cwr
"
,
"hash"
:
"Qm
U5s159q8cZuM1f9Vqti4LHu6y8zyVc5dxv2py81sdp6Q
"
,
"version"
:
"1.0.0"
}
],
...
...
vendor/Qm
aA6aDzeHjZiuqBtgYRz8ZXb1qMCoyMHgyDjBEYQniUKF
/go-multiaddr/.travis.yml
→
vendor/Qm
bWxL1aXQhBjc1XGjGF1f2KGBMCBYSuT2ThA8YXnXJK83
/go-multiaddr/.travis.yml
View file @
d4b42f8e
File moved
vendor/Qm
anZCL6SXRfafiUEMCBLq2QR171uQSdXQ8YAdHXLd8Cwr
/go-multiaddr
-net
/LICENSE
→
vendor/Qm
bWxL1aXQhBjc1XGjGF1f2KGBMCBYSuT2ThA8YXnXJK83
/go-multiaddr/LICENSE
View file @
d4b42f8e
File moved
vendor/Qm
aA6aDzeHjZiuqBtgYRz8ZXb1qMCoyMHgyDjBEYQniUKF
/go-multiaddr/README.md
→
vendor/Qm
bWxL1aXQhBjc1XGjGF1f2KGBMCBYSuT2ThA8YXnXJK83
/go-multiaddr/README.md
View file @
d4b42f8e
File moved
vendor/Qm
aA6aDzeHjZiuqBtgYRz8ZXb1qMCoyMHgyDjBEYQniUKF
/go-multiaddr/codec.go
→
vendor/Qm
bWxL1aXQhBjc1XGjGF1f2KGBMCBYSuT2ThA8YXnXJK83
/go-multiaddr/codec.go
View file @
d4b42f8e
...
...
@@ -9,7 +9,7 @@ import (
"strconv"
"strings"
mh
"Qmd
eauTdyf38KDQB4Cc4CurPWRRb5pej27NCXPA7kbPTJ
y/go-multihash"
mh
"Qmd
sKjp5fcCT8PZ8JBMcdFsCbbmKwSLCU5xXbsnwb5DMx
y/go-multihash"
)
func
stringToBytes
(
s
string
)
([]
byte
,
error
)
{
...
...
vendor/Qm
aA6aDzeHjZiuqBtgYRz8ZXb1qMCoyMHgyDjBEYQniUKF
/go-multiaddr/doc.go
→
vendor/Qm
bWxL1aXQhBjc1XGjGF1f2KGBMCBYSuT2ThA8YXnXJK83
/go-multiaddr/doc.go
View file @
d4b42f8e
File moved
vendor/Qm
aA6aDzeHjZiuqBtgYRz8ZXb1qMCoyMHgyDjBEYQniUKF
/go-multiaddr/interface.go
→
vendor/Qm
bWxL1aXQhBjc1XGjGF1f2KGBMCBYSuT2ThA8YXnXJK83
/go-multiaddr/interface.go
View file @
d4b42f8e
File moved
vendor/Qm
aA6aDzeHjZiuqBtgYRz8ZXb1qMCoyMHgyDjBEYQniUKF
/go-multiaddr/multiaddr.go
→
vendor/Qm
bWxL1aXQhBjc1XGjGF1f2KGBMCBYSuT2ThA8YXnXJK83
/go-multiaddr/multiaddr.go
View file @
d4b42f8e
File moved
vendor/Qm
aA6aDzeHjZiuqBtgYRz8ZXb1qMCoyMHgyDjBEYQniUKF
/go-multiaddr/multiaddr_test.go
→
vendor/Qm
bWxL1aXQhBjc1XGjGF1f2KGBMCBYSuT2ThA8YXnXJK83
/go-multiaddr/multiaddr_test.go
View file @
d4b42f8e
File moved
vendor/Qm
aA6aDzeHjZiuqBtgYRz8ZXb1qMCoyMHgyDjBEYQniUKF
/go-multiaddr/package.json
→
vendor/Qm
bWxL1aXQhBjc1XGjGF1f2KGBMCBYSuT2ThA8YXnXJK83
/go-multiaddr/package.json
View file @
d4b42f8e
...
...
@@ -5,7 +5,7 @@
"gxDependencies"
:
[
{
"name"
:
"go-multihash"
,
"hash"
:
"Qmd
eauTdyf38KDQB4Cc4CurPWRRb5pej27NCXPA7kbPTJ
y"
,
"hash"
:
"Qmd
sKjp5fcCT8PZ8JBMcdFsCbbmKwSLCU5xXbsnwb5DMx
y"
,
"version"
:
"1.0.0"
}
],
...
...
vendor/Qm
aA6aDzeHjZiuqBtgYRz8ZXb1qMCoyMHgyDjBEYQniUKF
/go-multiaddr/protocols.csv
→
vendor/Qm
bWxL1aXQhBjc1XGjGF1f2KGBMCBYSuT2ThA8YXnXJK83
/go-multiaddr/protocols.csv
View file @
d4b42f8e
File moved
vendor/Qm
aA6aDzeHjZiuqBtgYRz8ZXb1qMCoyMHgyDjBEYQniUKF
/go-multiaddr/protocols.go
→
vendor/Qm
bWxL1aXQhBjc1XGjGF1f2KGBMCBYSuT2ThA8YXnXJK83
/go-multiaddr/protocols.go
View file @
d4b42f8e
File moved
vendor/Qm
aA6aDzeHjZiuqBtgYRz8ZXb1qMCoyMHgyDjBEYQniUKF
/go-multiaddr/util.go
→
vendor/Qm
bWxL1aXQhBjc1XGjGF1f2KGBMCBYSuT2ThA8YXnXJK83
/go-multiaddr/util.go
View file @
d4b42f8e
File moved
vendor/QmdsKjp5fcCT8PZ8JBMcdFsCbbmKwSLCU5xXbsnwb5DMxy/go-multihash/.travis.yml
0 → 100644
View file @
d4b42f8e
language
:
go
go
:
-
1.3
-
release
-
tip
script
:
-
make test
env
:
TEST_VERBOSE=1
vendor/QmdsKjp5fcCT8PZ8JBMcdFsCbbmKwSLCU5xXbsnwb5DMxy/go-multihash/LICENSE
0 → 100644
View file @
d4b42f8e
The MIT License (MIT)
Copyright (c) 2014 Juan Batiz-Benet
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
vendor/QmdsKjp5fcCT8PZ8JBMcdFsCbbmKwSLCU5xXbsnwb5DMxy/go-multihash/Makefile
0 → 100644
View file @
d4b42f8e
test
:
go_test other_tests
other_tests
:
cd test
&&
make
test
go_test
:
go_deps
go
test
-race
-cpu
=
5
-v
./...
go_deps
:
go get golang.org/x/crypto/sha3
go get github.com/jbenet/go-base58
vendor/QmdsKjp5fcCT8PZ8JBMcdFsCbbmKwSLCU5xXbsnwb5DMxy/go-multihash/README.md
0 → 100644
View file @
d4b42f8e
# go-multihash
![
travis
](
https://travis-ci.org/jbenet/go-multihash.svg
)
[
multihash
](
//github.com/jbenet/multihash
)
implementation in Go.
## Example
```
go
package
main
import
(
"encoding/hex"
"fmt"
"github.com/jbenet/go-multihash"
)
func
main
()
{
// ignores errors for simplicity.
// don't do that at home.
buf
,
_
:=
hex
.
DecodeString
(
"0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33"
)
mhbuf
,
_
:=
multihash
.
EncodeName
(
buf
,
"sha1"
);
mhhex
:=
hex
.
EncodeToString
(
mhbuf
)
fmt
.
Printf
(
"hex: %v
\n
"
,
mhhex
);
o
,
_
:=
multihash
.
Decode
(
mhbuf
);
mhhex
=
hex
.
EncodeToString
(
o
.
Digest
);
fmt
.
Printf
(
"obj: %v 0x%x %d %s
\n
"
,
o
.
Name
,
o
.
Code
,
o
.
Length
,
mhhex
);
}
```
Run
[
test/foo.go
](
test/foo.go
)
```
> cd test/
> go build
> ./test
hex: 11140beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33
obj: sha1 0x11 20 0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33
```
## License
MIT
vendor/QmdsKjp5fcCT8PZ8JBMcdFsCbbmKwSLCU5xXbsnwb5DMxy/go-multihash/io.go
0 → 100644
View file @
d4b42f8e
package
multihash
import
(
"fmt"
"io"
)
// Reader is an io.Reader wrapper that exposes a function
// to read a whole multihash, parse it, and return it.
type
Reader
interface
{
io
.
Reader
ReadMultihash
()
(
Multihash
,
error
)
}
// Writer is an io.Writer wrapper that exposes a function
// to write a whole multihash.
type
Writer
interface
{
io
.
Writer
WriteMultihash
(
Multihash
)
error
}
// NewReader wraps an io.Reader with a multihash.Reader
func
NewReader
(
r
io
.
Reader
)
Reader
{
return
&
mhReader
{
r
}
}
// NewWriter wraps an io.Writer with a multihash.Writer
func
NewWriter
(
w
io
.
Writer
)
Writer
{
return
&
mhWriter
{
w
}
}
type
mhReader
struct
{
r
io
.
Reader
}
func
(
r
*
mhReader
)
Read
(
buf
[]
byte
)
(
n
int
,
err
error
)
{
return
r
.
r
.
Read
(
buf
)
}
func
(
r
*
mhReader
)
ReadMultihash
()
(
Multihash
,
error
)
{
mhhdr
:=
make
([]
byte
,
2
)
if
_
,
err
:=
io
.
ReadFull
(
r
.
r
,
mhhdr
);
err
!=
nil
{
return
nil
,
err
}
// first byte is the algo, the second is the length.
// (varints someday...)
length
:=
uint
(
mhhdr
[
1
])
if
length
>
127
{
return
nil
,
fmt
.
Errorf
(
"varints not yet supported (length is %d)"
,
length
)
}
buf
:=
make
([]
byte
,
length
+
2
)
buf
[
0
]
=
mhhdr
[
0
]
buf
[
1
]
=
mhhdr
[
1
]
if
_
,
err
:=
io
.
ReadFull
(
r
.
r
,
buf
[
2
:
]);
err
!=
nil
{
return
nil
,
err
}
return
Cast
(
buf
)
}
type
mhWriter
struct
{
w
io
.
Writer
}
func
(
w
*
mhWriter
)
Write
(
buf
[]
byte
)
(
n
int
,
err
error
)
{
return
w
.
w
.
Write
(
buf
)
}
func
(
w
*
mhWriter
)
WriteMultihash
(
m
Multihash
)
error
{
_
,
err
:=
w
.
w
.
Write
([]
byte
(
m
))
return
err
}
vendor/QmdsKjp5fcCT8PZ8JBMcdFsCbbmKwSLCU5xXbsnwb5DMxy/go-multihash/io_test.go
0 → 100644
View file @
d4b42f8e
package
multihash
import
(
"bytes"
"io"
"testing"
)
func
TestReader
(
t
*
testing
.
T
)
{
var
buf
bytes
.
Buffer
for
_
,
tc
:=
range
testCases
{
m
,
err
:=
tc
.
Multihash
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
buf
.
Write
([]
byte
(
m
))
}
r
:=
NewReader
(
&
buf
)
for
_
,
tc
:=
range
testCases
{
h
,
err
:=
tc
.
Multihash
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
h2
,
err
:=
r
.
ReadMultihash
()
if
err
!=
nil
{
t
.
Error
(
err
)
continue
}
if
!
bytes
.
Equal
(
h
,
h2
)
{
t
.
Error
(
"h and h2 should be equal"
)
}
}
}
func
TestWriter
(
t
*
testing
.
T
)
{
var
buf
bytes
.
Buffer
w
:=
NewWriter
(
&
buf
)
for
_
,
tc
:=
range
testCases
{
m
,
err
:=
tc
.
Multihash
()
if
err
!=
nil
{
t
.
Error
(
err
)
continue
}
if
err
:=
w
.
WriteMultihash
(
m
);
err
!=
nil
{
t
.
Error
(
err
)
continue
}
buf2
:=
make
([]
byte
,
len
(
m
))
if
_
,
err
:=
io
.
ReadFull
(
&
buf
,
buf2
);
err
!=
nil
{
t
.
Error
(
err
)
continue
}
if
!
bytes
.
Equal
(
m
,
buf2
)
{
t
.
Error
(
"m and buf2 should be equal"
)
}
}
}
Prev
1
2
3
4
5
6
7
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment