1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-29 01:12:24 +08:00

remove randbo from godeps

License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
This commit is contained in:
Jeromy
2016-02-08 23:10:19 -08:00
parent 3faedb5208
commit bf7dd2bd2b
7 changed files with 6 additions and 91 deletions

View File

@ -1,2 +0,0 @@
*~

View File

@ -1,11 +0,0 @@
A fast random number `io.Reader` implementation.
![randbo](https://raw.github.com/dustin/randbo/master/randbo.png)
> 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)

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 242 KiB

View File

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

View File

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

View File

@ -21,6 +21,11 @@
"name": "goprocess",
"hash": "QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn",
"version": "0.0.0"
},
{
"name": "randbo",
"hash": "QmYvsG72GsfLgUeSojXArjnU6L4Wmwk7wuAxtNLuyXcc1T",
"version": "0.0.0"
}
],
"language": "go",