Skip to content

Commit 3e308eb

Browse files
committed
all: add period for comments
Change-Id: Ibba1da1c0f430a144fc44dcbd82568825ba71966
1 parent cd9fcc3 commit 3e308eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+508
-509
lines changed

bloomfilter/filter.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ const (
2020
)
2121

2222
// rangeOffsets contains offsets for selecting subranges
23-
// that minimize overlap in the first hash functions
23+
// that minimize overlap in the first hash functions.
2424
var rangeOffsets = [...]byte{9, 13, 19, 23}
2525

26-
// Filter is a bloom filter implementation
26+
// Filter is a bloom filter implementation.
2727
type Filter struct {
2828
seed byte
2929
hashCount byte
@@ -47,7 +47,7 @@ func NewOptimal(expectedElements int, falsePositiveRate float64) *Filter {
4747
return newExplicit(seed, byte(hashCount), sizeInBytes)
4848
}
4949

50-
// NewOptimalMaxSize returns a filter based on expected element count and false positive rate, capped at a maximum size in bytes
50+
// NewOptimalMaxSize returns a filter based on expected element count and false positive rate, capped at a maximum size in bytes.
5151
func NewOptimalMaxSize(expectedElements int, falsePositiveRate float64, maxSize memory.Size) *Filter {
5252
hashCount, sizeInBytes := getHashCountAndSize(expectedElements, falsePositiveRate)
5353
seed := byte(rand.Intn(255))
@@ -77,7 +77,7 @@ func (filter *Filter) Parameters() (hashCount, size int) {
7777
return int(filter.hashCount), len(filter.table)
7878
}
7979

80-
// Add adds an element to the bloom filter
80+
// Add adds an element to the bloom filter.
8181
func (filter *Filter) Add(pieceID storj.PieceID) {
8282
offset, rangeOffset := initialConditions(filter.seed)
8383

@@ -94,7 +94,7 @@ func (filter *Filter) Add(pieceID storj.PieceID) {
9494
}
9595
}
9696

97-
// Contains return true if pieceID may be in the set
97+
// Contains return true if pieceID may be in the set.
9898
func (filter *Filter) Contains(pieceID storj.PieceID) bool {
9999
offset, rangeOffset := initialConditions(filter.seed)
100100

bloomfilter/filter_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func TestBytes_Failing(t *testing.T) {
6262
}
6363
}
6464

65-
// generateTestIDs generates n piece ids
65+
// generateTestIDs generates n piece ids.
6666
func generateTestIDs(n int) []storj.PieceID {
6767
ids := make([]storj.PieceID, n)
6868
for i := range ids {
@@ -128,7 +128,7 @@ type stats struct {
128128
avg, min, mean, max, mse float64
129129
}
130130

131-
// calculates average, minimum, maximum and mean squared error
131+
// summarize calculates average, minimum, maximum and mean squared error.
132132
func summarize(expected float64, values []float64) (r stats) {
133133
sort.Float64s(values)
134134

context2/nocancel.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (noCancelContext) Done() <-chan struct{} {
3131
return nil
3232
}
3333

34-
// Err always returns nil
34+
// Err always returns nil.
3535
func (noCancelContext) Err() error {
3636
return nil
3737
}

encryption/aesgcm.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (s *aesgcmDecrypter) Transform(out, in []byte, blockNum int64) ([]byte, err
130130
return plainData, nil
131131
}
132132

133-
// EncryptAESGCM encrypts byte data with a key and nonce. The cipher data is returned
133+
// EncryptAESGCM encrypts byte data with a key and nonce. It returns the cipher data.
134134
func EncryptAESGCM(data []byte, key *storj.Key, nonce *AESGCMNonce) (cipherData []byte, err error) {
135135
block, err := aes.NewCipher(key[:])
136136
if err != nil {
@@ -144,7 +144,7 @@ func EncryptAESGCM(data []byte, key *storj.Key, nonce *AESGCMNonce) (cipherData
144144
return cipherData, nil
145145
}
146146

147-
// DecryptAESGCM decrypts byte data with a key and nonce. The plain data is returned
147+
// DecryptAESGCM decrypts byte data with a key and nonce. It returns the plain data.
148148
func DecryptAESGCM(cipherData []byte, key *storj.Key, nonce *AESGCMNonce) (data []byte, err error) {
149149
if len(cipherData) == 0 {
150150
return []byte{}, Error.New("empty cipher data")

encryption/common.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import (
88
"github.com/zeebo/errs"
99
)
1010

11-
// Error is the default encryption errs class
11+
// Error is the default encryption errs class.
1212
var Error = errs.Class("encryption error")
1313

14-
// ErrDecryptFailed is the errs class when the decryption fails
14+
// ErrDecryptFailed is the errs class when the decryption fails.
1515
var ErrDecryptFailed = errs.Class("decryption failed, check encryption key")
1616

17-
// ErrInvalidConfig is the errs class for invalid configuration
17+
// ErrInvalidConfig is the errs class for invalid configuration.
1818
var ErrInvalidConfig = errs.Class("invalid encryption configuration")

encryption/encryption.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@ import (
1111
)
1212

1313
const (
14-
// AESGCMNonceSize is the size of an AES-GCM nonce
14+
// AESGCMNonceSize is the size of an AES-GCM nonce.
1515
AESGCMNonceSize = 12
16-
// unit32Size is the number of bytes in the uint32 type
16+
// unit32Size is the number of bytes in the uint32 type.
1717
uint32Size = 4
1818
)
1919

20-
// AESGCMNonce represents the nonce used by the AES-GCM protocol
20+
// AESGCMNonce represents the nonce used by the AES-GCM protocol.
2121
type AESGCMNonce [AESGCMNonceSize]byte
2222

23-
// ToAESGCMNonce returns the nonce as a AES-GCM nonce
23+
// ToAESGCMNonce returns the nonce as a AES-GCM nonce.
2424
func ToAESGCMNonce(nonce *storj.Nonce) *AESGCMNonce {
2525
aes := new(AESGCMNonce)
2626
copy((*aes)[:], nonce[:AESGCMNonceSize])
2727
return aes
2828
}
2929

30-
// Increment increments the nonce with the given amount
30+
// Increment increments the nonce with the given amount.
3131
func Increment(nonce *storj.Nonce, amount int64) (truncated bool, err error) {
3232
return incrementBytes(nonce[:], amount)
3333
}
3434

35-
// Encrypt encrypts data with the given cipher, key and nonce
35+
// Encrypt encrypts data with the given cipher, key and nonce.
3636
func Encrypt(data []byte, cipher storj.CipherSuite, key *storj.Key, nonce *storj.Nonce) (cipherData []byte, err error) {
3737
// Don't encrypt empty slice
3838
if len(data) == 0 {
@@ -53,7 +53,7 @@ func Encrypt(data []byte, cipher storj.CipherSuite, key *storj.Key, nonce *storj
5353
}
5454
}
5555

56-
// Decrypt decrypts cipherData with the given cipher, key and nonce
56+
// Decrypt decrypts cipherData with the given cipher, key and nonce.
5757
func Decrypt(cipherData []byte, cipher storj.CipherSuite, key *storj.Key, nonce *storj.Nonce) (data []byte, err error) {
5858
// Don't decrypt empty slice
5959
if len(cipherData) == 0 {
@@ -74,7 +74,7 @@ func Decrypt(cipherData []byte, cipher storj.CipherSuite, key *storj.Key, nonce
7474
}
7575
}
7676

77-
// NewEncrypter creates a Transformer using the given cipher, key and nonce to encrypt data passing through it
77+
// NewEncrypter creates a Transformer using the given cipher, key and nonce to encrypt data passing through it.
7878
func NewEncrypter(cipher storj.CipherSuite, key *storj.Key, startingNonce *storj.Nonce, encryptedBlockSize int) (Transformer, error) {
7979
switch cipher {
8080
case storj.EncNull:
@@ -90,7 +90,7 @@ func NewEncrypter(cipher storj.CipherSuite, key *storj.Key, startingNonce *storj
9090
}
9191
}
9292

93-
// NewDecrypter creates a Transformer using the given cipher, key and nonce to decrypt data passing through it
93+
// NewDecrypter creates a Transformer using the given cipher, key and nonce to decrypt data passing through it.
9494
func NewDecrypter(cipher storj.CipherSuite, key *storj.Key, startingNonce *storj.Nonce, encryptedBlockSize int) (Transformer, error) {
9595
switch cipher {
9696
case storj.EncNull:
@@ -106,12 +106,12 @@ func NewDecrypter(cipher storj.CipherSuite, key *storj.Key, startingNonce *storj
106106
}
107107
}
108108

109-
// EncryptKey encrypts keyToEncrypt with the given cipher, key and nonce
109+
// EncryptKey encrypts keyToEncrypt with the given cipher, key and nonce.
110110
func EncryptKey(keyToEncrypt *storj.Key, cipher storj.CipherSuite, key *storj.Key, nonce *storj.Nonce) (storj.EncryptedPrivateKey, error) {
111111
return Encrypt(keyToEncrypt[:], cipher, key, nonce)
112112
}
113113

114-
// DecryptKey decrypts keyToDecrypt with the given cipher, key and nonce
114+
// DecryptKey decrypts keyToDecrypt with the given cipher, key and nonce.
115115
func DecryptKey(keyToDecrypt storj.EncryptedPrivateKey, cipher storj.CipherSuite, key *storj.Key, nonce *storj.Nonce) (*storj.Key, error) {
116116
plainData, err := Decrypt(keyToDecrypt, cipher, key, nonce)
117117
if err != nil {
@@ -124,7 +124,7 @@ func DecryptKey(keyToDecrypt storj.EncryptedPrivateKey, cipher storj.CipherSuite
124124
return &decryptedKey, nil
125125
}
126126

127-
// DeriveKey derives new key from the given key and message using HMAC-SHA512
127+
// DeriveKey derives new key from the given key and message using HMAC-SHA512.
128128
func DeriveKey(key *storj.Key, message string) (*storj.Key, error) {
129129
mac := hmac.New(sha512.New, key[:])
130130
_, err := mac.Write([]byte(message))

encryption/path.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ func decryptPathComponent(comp string, cipher storj.CipherSuite, key *storj.Key)
397397
// `\xff` escapes to `\xfe\x02`
398398
// `\x00` escapes to `\x01\x01`
399399
// `\x01` escapes to `\x01\x02
400-
// for more details see docs/design/path-component-encoding.md
400+
// for more details see docs/design/path-component-encoding.md.
401401
func encodeSegment(segment []byte) []byte {
402402
if len(segment) == 0 {
403403
return emptyComponent

encryption/secretbox.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ func (s *secretboxDecrypter) Transform(out, in []byte, blockNum int64) ([]byte,
104104
return rv, nil
105105
}
106106

107-
// EncryptSecretBox encrypts byte data with a key and nonce. The cipher data is returned
107+
// EncryptSecretBox encrypts byte data with a key and nonce. The cipher data is returned.
108108
func EncryptSecretBox(data []byte, key *storj.Key, nonce *storj.Nonce) (cipherData []byte, err error) {
109109
return secretbox.Seal(nil, data, nonce.Raw(), key.Raw()), nil
110110
}
111111

112-
// DecryptSecretBox decrypts byte data with a key and nonce. The plain data is returned
112+
// DecryptSecretBox decrypts byte data with a key and nonce. The plain data is returned.
113113
func DecryptSecretBox(cipherData []byte, key *storj.Key, nonce *storj.Nonce) (data []byte, err error) {
114114
data, success := secretbox.Open(nil, cipherData, nonce.Raw(), key.Raw())
115115
if !success {

encryption/transform.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,20 @@ type transformedReader struct {
3535
bytesRead int
3636
}
3737

38-
// NoopTransformer is a dummy Transformer that passes data through without modifying it
38+
// NoopTransformer is a dummy Transformer that passes data through without modifying it.
3939
type NoopTransformer struct{}
4040

41-
// InBlockSize is 1
41+
// InBlockSize is 1.
4242
func (t *NoopTransformer) InBlockSize() int {
4343
return 1
4444
}
4545

46-
// OutBlockSize is 1
46+
// OutBlockSize is 1.
4747
func (t *NoopTransformer) OutBlockSize() int {
4848
return 1
4949
}
5050

51-
// Transform returns the input without modification
51+
// Transform returns the input without modification.
5252
func (t *NoopTransformer) Transform(out, in []byte, blockNum int64) ([]byte, error) {
5353
return append(out, in...), nil
5454
}
@@ -137,7 +137,7 @@ func (t *transformedRanger) Size() int64 {
137137

138138
// CalcEncompassingBlocks is a useful helper function that, given an offset,
139139
// length, and blockSize, will tell you which blocks contain the requested
140-
// offset and length
140+
// offset and length.
141141
func CalcEncompassingBlocks(offset, length int64, blockSize int) (
142142
firstBlock, blockCount int64) {
143143
firstBlock = offset / int64(blockSize)

errs2/collect.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/zeebo/errs"
1010
)
1111

12-
// Collect returns first error from channel and all errors that happen within duration
12+
// Collect returns first error from channel and all errors that happen within duration.
1313
func Collect(errch chan error, duration time.Duration) error {
1414
errch = discardNil(errch)
1515
errlist := []error{<-errch}
@@ -24,7 +24,7 @@ func Collect(errch chan error, duration time.Duration) error {
2424
}
2525
}
2626

27-
// discard nil errors that are returned from services
27+
// discard nil errors that are returned from services.
2828
func discardNil(ch chan error) chan error {
2929
r := make(chan error)
3030
go func() {

fpath/editor.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"strings"
1111
)
1212

13-
//EditFile opens the best OS-specific text editor we can find
13+
//EditFile opens the best OS-specific text editor we can find.
1414
func EditFile(fileToEdit string) error {
1515
editorPath := getEditorPath()
1616
if editorPath == "" {

fpath/os.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"github.com/zeebo/errs"
1616
)
1717

18-
// IsRoot returns whether path is the root directory
18+
// IsRoot returns whether path is the root directory.
1919
func IsRoot(path string) bool {
2020
abs, err := filepath.Abs(path)
2121
if err == nil {
@@ -25,7 +25,7 @@ func IsRoot(path string) bool {
2525
return filepath.Dir(path) == path
2626
}
2727

28-
// ApplicationDir returns best base directory for specific OS
28+
// ApplicationDir returns best base directory for specific OS.
2929
func ApplicationDir(subdir ...string) string {
3030
for i := range subdir {
3131
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
@@ -62,7 +62,7 @@ func ApplicationDir(subdir ...string) string {
6262
return filepath.Join(append([]string{appdir}, subdir...)...)
6363
}
6464

65-
// IsValidSetupDir checks if directory is valid for setup configuration
65+
// IsValidSetupDir checks if directory is valid for setup configuration.
6666
func IsValidSetupDir(name string) (ok bool, err error) {
6767
_, err = os.Stat(name)
6868
if err != nil {
@@ -100,7 +100,7 @@ func IsValidSetupDir(name string) (ok bool, err error) {
100100
}
101101
}
102102

103-
// IsWritable determines if a directory is writeable
103+
// IsWritable determines if a directory is writeable.
104104
func IsWritable(filepath string) (bool, error) {
105105
info, err := os.Stat(filepath)
106106
if err != nil {

fpath/path.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func parseBucket(o string) (bucket, rest string) {
5050
return "", o
5151
}
5252

53-
// New creates new FPath from the given URL
53+
// New creates new FPath from the given URL.
5454
func New(p string) (FPath, error) {
5555
fp := FPath{original: p}
5656

@@ -101,7 +101,7 @@ func New(p string) (FPath, error) {
101101
return fp, nil
102102
}
103103

104-
// Join is appends the given segment to the path
104+
// Join is appends the given segment to the path.
105105
func (p FPath) Join(segment string) FPath {
106106
if p.local {
107107
p.original = filepath.Join(p.original, segment)
@@ -113,7 +113,7 @@ func (p FPath) Join(segment string) FPath {
113113
return p
114114
}
115115

116-
// Base returns the last segment of the path
116+
// Base returns the last segment of the path.
117117
func (p FPath) Base() string {
118118
if p.local {
119119
return filepath.Base(p.original)
@@ -124,25 +124,25 @@ func (p FPath) Base() string {
124124
return path.Base(p.path)
125125
}
126126

127-
// Bucket returns the first segment of path
127+
// Bucket returns the first segment of path.
128128
func (p FPath) Bucket() string {
129129
return p.bucket
130130
}
131131

132-
// Path returns the URL path without the scheme
132+
// Path returns the URL path without the scheme.
133133
func (p FPath) Path() string {
134134
if p.local {
135135
return p.original
136136
}
137137
return p.path
138138
}
139139

140-
// IsLocal returns whether the path refers to local or remote location
140+
// IsLocal returns whether the path refers to local or remote location.
141141
func (p FPath) IsLocal() bool {
142142
return p.local
143143
}
144144

145-
// String returns the entire URL (untouched)
145+
// String returns the entire URL (untouched).
146146
func (p FPath) String() string {
147147
return p.original
148148
}

fpath/temp_data.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import "context"
1111
// other packages.
1212
type key int
1313

14-
// temp is the context key for temp struct
14+
// temp is the context key for temp struct.
1515
const tempKey key = 0
1616

1717
type temp struct {
1818
inmemory bool
1919
directory string
2020
}
2121

22-
// WithTempData creates context with information how store temporary data, in memory or on disk
22+
// WithTempData creates context with information how store temporary data, in memory or on disk.
2323
func WithTempData(ctx context.Context, directory string, inmemory bool) context.Context {
2424
temp := temp{
2525
inmemory: inmemory,
@@ -28,7 +28,7 @@ func WithTempData(ctx context.Context, directory string, inmemory bool) context.
2828
return context.WithValue(ctx, tempKey, temp)
2929
}
3030

31-
// GetTempData returns if temporary data should be stored in memory or on disk
31+
// GetTempData returns if temporary data should be stored in memory or on disk.
3232
func GetTempData(ctx context.Context) (string, bool, bool) {
3333
tempValue, ok := ctx.Value(tempKey).(temp)
3434
if !ok {

0 commit comments

Comments
 (0)