mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-28 17:03:58 +08:00
remove randbo from godeps
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
This commit is contained in:
2
Godeps/_workspace/src/github.com/dustin/randbo/.gitignore
generated
vendored
2
Godeps/_workspace/src/github.com/dustin/randbo/.gitignore
generated
vendored
@ -1,2 +0,0 @@
|
||||
|
||||
*~
|
11
Godeps/_workspace/src/github.com/dustin/randbo/README.markdown
generated
vendored
11
Godeps/_workspace/src/github.com/dustin/randbo/README.markdown
generated
vendored
@ -1,11 +0,0 @@
|
||||
A fast random number `io.Reader` implementation.
|
||||
|
||||

|
||||
|
||||
> IN A WORLD where no integer sequence is certain ...
|
||||
>
|
||||
> ONE MAN must become statistically indistinguishable from noise
|
||||
>
|
||||
> THIS SUMMER, entropy has a new name: RANDBO
|
||||
|
||||
(thanks @snej)
|
40
Godeps/_workspace/src/github.com/dustin/randbo/randbo.go
generated
vendored
40
Godeps/_workspace/src/github.com/dustin/randbo/randbo.go
generated
vendored
@ -1,40 +0,0 @@
|
||||
package randbo
|
||||
|
||||
import (
|
||||
"io"
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Randbo creates a stream of non-crypto quality random bytes
|
||||
type randbo struct {
|
||||
rand.Source
|
||||
}
|
||||
|
||||
// New creates a new random reader with a time source.
|
||||
func New() io.Reader {
|
||||
return NewFrom(rand.NewSource(time.Now().UnixNano()))
|
||||
}
|
||||
|
||||
// NewFrom creates a new reader from your own rand.Source
|
||||
func NewFrom(src rand.Source) io.Reader {
|
||||
return &randbo{src}
|
||||
}
|
||||
|
||||
// Read satisfies io.Reader
|
||||
func (r *randbo) Read(p []byte) (n int, err error) {
|
||||
todo := len(p)
|
||||
offset := 0
|
||||
for {
|
||||
val := int64(r.Int63())
|
||||
for i := 0; i < 8; i++ {
|
||||
p[offset] = byte(val)
|
||||
todo--
|
||||
if todo == 0 {
|
||||
return len(p), nil
|
||||
}
|
||||
offset++
|
||||
val >>= 8
|
||||
}
|
||||
}
|
||||
}
|
BIN
Godeps/_workspace/src/github.com/dustin/randbo/randbo.png
generated
vendored
BIN
Godeps/_workspace/src/github.com/dustin/randbo/randbo.png
generated
vendored
Binary file not shown.
Before Width: | Height: | Size: 242 KiB |
37
Godeps/_workspace/src/github.com/dustin/randbo/randbo_test.go
generated
vendored
37
Godeps/_workspace/src/github.com/dustin/randbo/randbo_test.go
generated
vendored
@ -1,37 +0,0 @@
|
||||
package randbo
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRandbo(t *testing.T) {
|
||||
buf := make([]byte, 16)
|
||||
n, err := New().Read(buf)
|
||||
if err != nil {
|
||||
t.Fatalf("Error reading: %v", err)
|
||||
}
|
||||
if n != len(buf) {
|
||||
t.Fatalf("Short read: %v", n)
|
||||
}
|
||||
t.Logf("Read %x", buf)
|
||||
}
|
||||
|
||||
const toCopy = 1024 * 1024
|
||||
|
||||
func BenchmarkRandbo(b *testing.B) {
|
||||
b.SetBytes(toCopy)
|
||||
r := New()
|
||||
for i := 0; i < b.N; i++ {
|
||||
io.CopyN(ioutil.Discard, r, toCopy)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCrypto(b *testing.B) {
|
||||
b.SetBytes(toCopy)
|
||||
for i := 0; i < b.N; i++ {
|
||||
io.CopyN(ioutil.Discard, rand.Reader, toCopy)
|
||||
}
|
||||
}
|
@ -13,10 +13,10 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
randbo "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/dustin/randbo"
|
||||
ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
|
||||
dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
|
||||
"github.com/ipfs/go-ipfs/path"
|
||||
randbo "gx/ipfs/QmYvsG72GsfLgUeSojXArjnU6L4Wmwk7wuAxtNLuyXcc1T/randbo"
|
||||
"gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
|
||||
|
||||
bstore "github.com/ipfs/go-ipfs/blocks/blockstore"
|
||||
|
@ -21,6 +21,11 @@
|
||||
"name": "goprocess",
|
||||
"hash": "QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn",
|
||||
"version": "0.0.0"
|
||||
},
|
||||
{
|
||||
"name": "randbo",
|
||||
"hash": "QmYvsG72GsfLgUeSojXArjnU6L4Wmwk7wuAxtNLuyXcc1T",
|
||||
"version": "0.0.0"
|
||||
}
|
||||
],
|
||||
"language": "go",
|
||||
|
Reference in New Issue
Block a user