last golint
Siraj Ravel committed
Sep 11, 2014 at 13:00 UTC
02deb3cccb37155a83080992b79306959d374499
3 files changed
+14
-13
importer/splitting.go
+12
-11
@@ -34,12 +34,13 @@ func SplitterBySize(n int) BlockSplitter {
34
}
35
36
// TODO: this should take a reader, not a byte array. what if we're splitting a 3TB file?
37
+//Rabin Fingerprinting for file chunking
38
func Rabin(b []byte) [][]byte {
39
var out [][]byte
40
windowsize := uint64(48)
40
- chunk_max := 1024 * 16
41
- min_blk_size := 2048
42
- blk_beg_i := 0
41
+ chunkMax := 1024 * 16
42
+ minBlkSize := 2048
43
+ blkBegI := 0
44
prime := uint64(61)
45
46
var poly uint64
@@ -63,21 +64,21 @@ func Rabin(b []byte) [][]byte {
64
poly = (poly * prime) + cur
65
curchecksum -= (uint64(b[i-1]) * prime)
66
66
- if i-blk_beg_i >= chunk_max {
67
+ if i-blkgBegI >= chunkMax {
68
// push block
68
- out = append(out, b[blk_beg_i:i])
69
- blk_beg_i = i
69
+ out = append(out, b[blkgBegI:i])
70
+ blkgBegI = i
71
}
72
73
// first 13 bits of polynomial are 0
73
- if poly%8192 == 0 && i-blk_beg_i >= min_blk_size {
74
+ if poly%8192 == 0 && i-blkgBegI >= minBlkSize {
75
// push block
75
- out = append(out, b[blk_beg_i:i])
76
- blk_beg_i = i
76
+ out = append(out, b[blkgBegI:i])
77
+ blkgBegI = i
78
}
79
}
79
- if i > blk_beg_i {
80
- out = append(out, b[blk_beg_i:])
80
+ if i > blkgBegI {
81
+ out = append(out, b[blkgBegI:])
82
}
83
return out
84
}
merkledag/dagreader.go
+1
-1
@@ -9,7 +9,7 @@ import (
9
u "github.com/jbenet/go-ipfs/util"
10
)
11
12
-var ErrIsDir = errors.New("this dag node is a directory.")
12
+var ErrIsDir = errors.New("this dag node is a directory")
13
14
// DagReader provides a way to easily read the data contained in a dag.
15
type DagReader struct {
peer/peer.go
+1
-1
@@ -16,7 +16,7 @@ import (
16
// ID is a byte slice representing the identity of a peer.
17
type ID mh.Multihash
18
19
-// Utililty function for comparing two peer ID's
19
+// Equal is utililty function for comparing two peer ID's
20
func (id ID) Equal(other ID) bool {
21
return bytes.Equal(id, other)
22
}