golint util/, thirdparty/
and exchange/bitswap/testutils.go License: MIT Signed-off-by: rht <rhtbot@gmail.com>
rht committed
Jun 14, 2015 at 21:44 UTC
18f5fcea28259002dae96227ccae6324bb685cd7
11 files changed
+36
-38
exchange/bitswap/testutils.go
+3
-3
@@ -50,7 +50,7 @@ func (g *SessionGenerator) Next() Instance {
50
}
51
52
func (g *SessionGenerator) Instances(n int) []Instance {
53
- instances := make([]Instance, 0)
53
+ var instances []Instance
54
for j := 0; j < n; j++ {
55
inst := g.Next()
56
instances = append(instances, inst)
@@ -87,12 +87,12 @@ func (i *Instance) SetBlockstoreLatency(t time.Duration) time.Duration {
87
// just a much better idea.
88
func session(ctx context.Context, net tn.Network, p testutil.Identity) Instance {
89
bsdelay := delay.Fixed(0)
90
- const kWriteCacheElems = 100
90
+ const writeCacheElems = 100
91
92
adapter := net.Adapter(p)
93
dstore := ds_sync.MutexWrap(datastore2.WithDelay(ds.NewMapDatastore(), bsdelay))
94
95
- bstore, err := blockstore.WriteCached(blockstore.NewBlockstore(ds_sync.MutexWrap(dstore)), kWriteCacheElems)
95
+ bstore, err := blockstore.WriteCached(blockstore.NewBlockstore(ds_sync.MutexWrap(dstore)), writeCacheElems)
96
if err != nil {
97
panic(err.Error()) // FIXME perhaps change signature and return error.
98
}
test/integration/addcat_test.go
+1
-1
@@ -61,7 +61,7 @@ func TestDegenerateSlowRouting(t *testing.T) {
61
62
func Test100MBMacbookCoastToCoast(t *testing.T) {
63
SkipUnlessEpic(t)
64
- conf := testutil.LatencyConfig{}.Network_NYtoSF().Blockstore_SlowSSD2014().Routing_Slow()
64
+ conf := testutil.LatencyConfig{}.NetworkNYtoSF().BlockstoreSlowSSD2014().RoutingSlow()
65
if err := DirectAddCat(RandomBytes(100*1024*1024), conf); err != nil {
66
t.Fatal(err)
67
}
test/integration/bench_test.go
+5
-5
@@ -21,7 +21,7 @@ func benchmarkAddCat(numBytes int64, conf testutil.LatencyConfig, b *testing.B)
21
}
22
}
23
24
-var instant = testutil.LatencyConfig{}.All_Instantaneous()
24
+var instant = testutil.LatencyConfig{}.AllInstantaneous()
25
26
func BenchmarkInstantaneousAddCat1KB(b *testing.B) { benchmarkAddCat(1*unit.KB, instant, b) }
27
func BenchmarkInstantaneousAddCat1MB(b *testing.B) { benchmarkAddCat(1*unit.MB, instant, b) }
@@ -34,7 +34,7 @@ func BenchmarkInstantaneousAddCat64MB(b *testing.B) { benchmarkAddCat(64*unit.M
34
func BenchmarkInstantaneousAddCat128MB(b *testing.B) { benchmarkAddCat(128*unit.MB, instant, b) }
35
func BenchmarkInstantaneousAddCat256MB(b *testing.B) { benchmarkAddCat(256*unit.MB, instant, b) }
36
37
-var routing = testutil.LatencyConfig{}.Routing_Slow()
37
+var routing = testutil.LatencyConfig{}.RoutingSlow()
38
39
func BenchmarkRoutingSlowAddCat1MB(b *testing.B) { benchmarkAddCat(1*unit.MB, routing, b) }
40
func BenchmarkRoutingSlowAddCat2MB(b *testing.B) { benchmarkAddCat(2*unit.MB, routing, b) }
@@ -47,7 +47,7 @@ func BenchmarkRoutingSlowAddCat128MB(b *testing.B) { benchmarkAddCat(128*unit.MB
47
func BenchmarkRoutingSlowAddCat256MB(b *testing.B) { benchmarkAddCat(256*unit.MB, routing, b) }
48
func BenchmarkRoutingSlowAddCat512MB(b *testing.B) { benchmarkAddCat(512*unit.MB, routing, b) }
49
50
-var network = testutil.LatencyConfig{}.Network_NYtoSF()
50
+var network = testutil.LatencyConfig{}.NetworkNYtoSF()
51
52
func BenchmarkNetworkSlowAddCat1MB(b *testing.B) { benchmarkAddCat(1*unit.MB, network, b) }
53
func BenchmarkNetworkSlowAddCat2MB(b *testing.B) { benchmarkAddCat(2*unit.MB, network, b) }
@@ -59,7 +59,7 @@ func BenchmarkNetworkSlowAddCat64MB(b *testing.B) { benchmarkAddCat(64*unit.MB,
59
func BenchmarkNetworkSlowAddCat128MB(b *testing.B) { benchmarkAddCat(128*unit.MB, network, b) }
60
func BenchmarkNetworkSlowAddCat256MB(b *testing.B) { benchmarkAddCat(256*unit.MB, network, b) }
61
62
-var hdd = testutil.LatencyConfig{}.Blockstore_7200RPM()
62
+var hdd = testutil.LatencyConfig{}.Blockstore7200RPM()
63
64
func BenchmarkBlockstoreSlowAddCat1MB(b *testing.B) { benchmarkAddCat(1*unit.MB, hdd, b) }
65
func BenchmarkBlockstoreSlowAddCat2MB(b *testing.B) { benchmarkAddCat(2*unit.MB, hdd, b) }
@@ -71,7 +71,7 @@ func BenchmarkBlockstoreSlowAddCat64MB(b *testing.B) { benchmarkAddCat(64*unit.
71
func BenchmarkBlockstoreSlowAddCat128MB(b *testing.B) { benchmarkAddCat(128*unit.MB, hdd, b) }
72
func BenchmarkBlockstoreSlowAddCat256MB(b *testing.B) { benchmarkAddCat(256*unit.MB, hdd, b) }
73
74
-var mixed = testutil.LatencyConfig{}.Network_NYtoSF().Blockstore_SlowSSD2014().Routing_Slow()
74
+var mixed = testutil.LatencyConfig{}.NetworkNYtoSF().BlockstoreSlowSSD2014().RoutingSlow()
75
76
func BenchmarkMixedAddCat1MBXX(b *testing.B) { benchmarkAddCat(1*unit.MB, mixed, b) }
77
func BenchmarkMixedAddCat2MBXX(b *testing.B) { benchmarkAddCat(2*unit.MB, mixed, b) }
test/integration/three_legged_cat_test.go
+1
-1
@@ -55,7 +55,7 @@ func TestThreeLeggedCatDegenerateSlowRouting(t *testing.T) {
55
56
func TestThreeLeggedCat100MBMacbookCoastToCoast(t *testing.T) {
57
SkipUnlessEpic(t)
58
- conf := testutil.LatencyConfig{}.Network_NYtoSF().Blockstore_SlowSSD2014().Routing_Slow()
58
+ conf := testutil.LatencyConfig{}.NetworkNYtoSF().BlockstoreSlowSSD2014().RoutingSlow()
59
if err := RunThreeLeggedCat(RandomBytes(100*unit.MB), conf); err != nil {
60
t.Fatal(err)
61
}
thirdparty/eventlog/loggable.go
+1
-1
@@ -11,7 +11,7 @@ func (l LoggableMap) Loggable() map[string]interface{} {
11
return l
12
}
13
14
-// Loggable converts a func into a Loggable
14
+// LoggableF converts a func into a Loggable
15
type LoggableF func() map[string]interface{}
16
17
func (l LoggableF) Loggable() map[string]interface{} {
thirdparty/notifier/notifier.go
+1
-1
@@ -71,7 +71,7 @@ func (n *Notifier) Notify(e Notifiee) {
71
n.mu.Unlock()
72
}
73
74
-// StopNotifying stops notifying Notifiee e. This function
74
+// StopNotify stops notifying Notifiee e. This function
75
// is meant to be called behind your own type-safe function(s):
76
//
77
// // generic function for pattern-following
thirdparty/redis-datastore/datastore.go
+11
-11
@@ -11,31 +11,31 @@ import (
11
query "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
12
)
13
14
-var _ datastore.Datastore = &RedisDatastore{}
15
-var _ datastore.ThreadSafeDatastore = &RedisDatastore{}
14
+var _ datastore.Datastore = &Datastore{}
15
+var _ datastore.ThreadSafeDatastore = &Datastore{}
16
17
var ErrInvalidType = errors.New("redis datastore: invalid type error. this datastore only supports []byte values")
18
19
func NewExpiringDatastore(client *redis.Client, ttl time.Duration) (datastore.ThreadSafeDatastore, error) {
20
- return &RedisDatastore{
20
+ return &Datastore{
21
client: client,
22
ttl: ttl,
23
}, nil
24
}
25
26
func NewDatastore(client *redis.Client) (datastore.ThreadSafeDatastore, error) {
27
- return &RedisDatastore{
27
+ return &Datastore{
28
client: client,
29
}, nil
30
}
31
32
-type RedisDatastore struct {
32
+type Datastore struct {
33
mu sync.Mutex
34
client *redis.Client
35
ttl time.Duration
36
}
37
38
-func (ds *RedisDatastore) Put(key datastore.Key, value interface{}) error {
38
+func (ds *Datastore) Put(key datastore.Key, value interface{}) error {
39
ds.mu.Lock()
40
defer ds.mu.Unlock()
41
@@ -59,26 +59,26 @@ func (ds *RedisDatastore) Put(key datastore.Key, value interface{}) error {
59
return nil
60
}
61
62
-func (ds *RedisDatastore) Get(key datastore.Key) (value interface{}, err error) {
62
+func (ds *Datastore) Get(key datastore.Key) (value interface{}, err error) {
63
ds.mu.Lock()
64
defer ds.mu.Unlock()
65
return ds.client.Cmd("GET", key.String()).Bytes()
66
}
67
68
-func (ds *RedisDatastore) Has(key datastore.Key) (exists bool, err error) {
68
+func (ds *Datastore) Has(key datastore.Key) (exists bool, err error) {
69
ds.mu.Lock()
70
defer ds.mu.Unlock()
71
return ds.client.Cmd("EXISTS", key.String()).Bool()
72
}
73
74
-func (ds *RedisDatastore) Delete(key datastore.Key) (err error) {
74
+func (ds *Datastore) Delete(key datastore.Key) (err error) {
75
ds.mu.Lock()
76
defer ds.mu.Unlock()
77
return ds.client.Cmd("DEL", key.String()).Err
78
}
79
80
-func (ds *RedisDatastore) Query(q query.Query) (query.Results, error) {
80
+func (ds *Datastore) Query(q query.Query) (query.Results, error) {
81
return nil, errors.New("TODO implement query for redis datastore?")
82
}
83
84
-func (ds *RedisDatastore) IsThreadSafe() {}
84
+func (ds *Datastore) IsThreadSafe() {}
thirdparty/unit/unit.go
+1
-1
@@ -19,7 +19,7 @@ func (i Information) String() string {
19
tmp := int64(i)
20
21
// default
22
- var d int64 = tmp
22
+ var d = tmp
23
symbol := "B"
24
25
switch {
util/testutil/gen.go
+1
-1
@@ -122,7 +122,7 @@ func (p *PeerNetParams) checkKeys() error {
122
return fmt.Errorf("sig verify failed: %s", err)
123
}
124
if !sigok {
125
- return fmt.Errorf("sig verify failed: sig invalid!")
125
+ return fmt.Errorf("sig verify failed: sig invalid")
126
}
127
128
return nil // ok. move along.
util/testutil/latency_config.go
+7
-7
@@ -8,7 +8,7 @@ type LatencyConfig struct {
8
RoutingLatency time.Duration
9
}
10
11
-func (c LatencyConfig) All_Instantaneous() LatencyConfig {
11
+func (c LatencyConfig) AllInstantaneous() LatencyConfig {
12
// Could use a zero value but whatever. Consistency of interface
13
c.NetworkLatency = 0
14
c.RoutingLatency = 0
@@ -16,33 +16,33 @@ func (c LatencyConfig) All_Instantaneous() LatencyConfig {
16
return c
17
}
18
19
-func (c LatencyConfig) Network_NYtoSF() LatencyConfig {
19
+func (c LatencyConfig) NetworkNYtoSF() LatencyConfig {
20
c.NetworkLatency = 20 * time.Millisecond
21
return c
22
}
23
24
-func (c LatencyConfig) Network_IntraDatacenter2014() LatencyConfig {
24
+func (c LatencyConfig) NetworkIntraDatacenter2014() LatencyConfig {
25
c.NetworkLatency = 250 * time.Microsecond
26
return c
27
}
28
29
-func (c LatencyConfig) Blockstore_FastSSD2014() LatencyConfig {
29
+func (c LatencyConfig) BlockstoreFastSSD2014() LatencyConfig {
30
const iops = 100000
31
c.BlockstoreLatency = (1 / iops) * time.Second
32
return c
33
}
34
35
-func (c LatencyConfig) Blockstore_SlowSSD2014() LatencyConfig {
35
+func (c LatencyConfig) BlockstoreSlowSSD2014() LatencyConfig {
36
c.BlockstoreLatency = 150 * time.Microsecond
37
return c
38
}
39
40
-func (c LatencyConfig) Blockstore_7200RPM() LatencyConfig {
40
+func (c LatencyConfig) Blockstore7200RPM() LatencyConfig {
41
c.BlockstoreLatency = 8 * time.Millisecond
42
return c
43
}
44
45
-func (c LatencyConfig) Routing_Slow() LatencyConfig {
45
+func (c LatencyConfig) RoutingSlow() LatencyConfig {
46
c.RoutingLatency = 200 * time.Millisecond
47
return c
48
}
util/util.go
+4
-6
@@ -1,4 +1,4 @@
1
-// package util implements various utility functions used within ipfs
1
+// Package util implements various utility functions used within ipfs
2
// that do not currently have a better place to live.
3
package util
4
@@ -95,7 +95,7 @@ func GetenvBool(name string) bool {
95
return v == "true" || v == "t" || v == "1"
96
}
97
98
-// multiErr is a util to return multiple errors
98
+// MultiErr is a util to return multiple errors
99
type MultiErr []error
100
101
func (m MultiErr) Error() string {
@@ -116,17 +116,15 @@ func (m MultiErr) Error() string {
116
func Partition(subject string, sep string) (string, string, string) {
117
if i := strings.Index(subject, sep); i != -1 {
118
return subject[:i], subject[i : i+len(sep)], subject[i+len(sep):]
119
- } else {
120
- return subject, "", ""
119
}
120
+ return subject, "", ""
121
}
122
123
func RPartition(subject string, sep string) (string, string, string) {
124
if i := strings.LastIndex(subject, sep); i != -1 {
125
return subject[:i], subject[i : i+len(sep)], subject[i+len(sep):]
127
- } else {
128
- return subject, "", ""
126
}
127
+ return subject, "", ""
128
}
129
130
// Hash is the global IPFS hash function. uses multihash SHA2_256, 256 bits