Commit 02deb3cc authored by Siraj Ravel's avatar Siraj Ravel

last golint

parent 61586864
...@@ -34,12 +34,13 @@ func SplitterBySize(n int) BlockSplitter { ...@@ -34,12 +34,13 @@ func SplitterBySize(n int) BlockSplitter {
} }
// TODO: this should take a reader, not a byte array. what if we're splitting a 3TB file? // TODO: this should take a reader, not a byte array. what if we're splitting a 3TB file?
//Rabin Fingerprinting for file chunking
func Rabin(b []byte) [][]byte { func Rabin(b []byte) [][]byte {
var out [][]byte var out [][]byte
windowsize := uint64(48) windowsize := uint64(48)
chunk_max := 1024 * 16 chunkMax := 1024 * 16
min_blk_size := 2048 minBlkSize := 2048
blk_beg_i := 0 blkBegI := 0
prime := uint64(61) prime := uint64(61)
var poly uint64 var poly uint64
...@@ -63,21 +64,21 @@ func Rabin(b []byte) [][]byte { ...@@ -63,21 +64,21 @@ func Rabin(b []byte) [][]byte {
poly = (poly * prime) + cur poly = (poly * prime) + cur
curchecksum -= (uint64(b[i-1]) * prime) curchecksum -= (uint64(b[i-1]) * prime)
if i-blk_beg_i >= chunk_max { if i-blkgBegI >= chunkMax {
// push block // push block
out = append(out, b[blk_beg_i:i]) out = append(out, b[blkgBegI:i])
blk_beg_i = i blkgBegI = i
} }
// first 13 bits of polynomial are 0 // first 13 bits of polynomial are 0
if poly%8192 == 0 && i-blk_beg_i >= min_blk_size { if poly%8192 == 0 && i-blkgBegI >= minBlkSize {
// push block // push block
out = append(out, b[blk_beg_i:i]) out = append(out, b[blkgBegI:i])
blk_beg_i = i blkgBegI = i
} }
} }
if i > blk_beg_i { if i > blkgBegI {
out = append(out, b[blk_beg_i:]) out = append(out, b[blkgBegI:])
} }
return out return out
} }
...@@ -9,7 +9,7 @@ import ( ...@@ -9,7 +9,7 @@ import (
u "github.com/jbenet/go-ipfs/util" u "github.com/jbenet/go-ipfs/util"
) )
var ErrIsDir = errors.New("this dag node is a directory.") var ErrIsDir = errors.New("this dag node is a directory")
// DagReader provides a way to easily read the data contained in a dag. // DagReader provides a way to easily read the data contained in a dag.
type DagReader struct { type DagReader struct {
......
...@@ -16,7 +16,7 @@ import ( ...@@ -16,7 +16,7 @@ import (
// ID is a byte slice representing the identity of a peer. // ID is a byte slice representing the identity of a peer.
type ID mh.Multihash type ID mh.Multihash
// Utililty function for comparing two peer ID's // Equal is utililty function for comparing two peer ID's
func (id ID) Equal(other ID) bool { func (id ID) Equal(other ID) bool {
return bytes.Equal(id, other) return bytes.Equal(id, other)
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment