Skip to content

Commit a103fac

Browse files
Remove useless interface comments + minor cleanup (ava-labs#1196)
1 parent 365ae17 commit a103fac

File tree

97 files changed

+229
-572
lines changed

Some content is hidden

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

97 files changed

+229
-572
lines changed

api/keystore/keystore.go

-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ type user struct {
9090
Data []kvPair `serialize:"true"`
9191
}
9292

93-
// keystore implements keystore management logic
9493
type keystore struct {
9594
lock sync.Mutex
9695
log logging.Logger

app/plugin/plugin.go

+18-23
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,36 @@ import (
1414
"github.com/ava-labs/avalanchego/app"
1515
)
1616

17-
const (
18-
Name = "nodeProcess"
19-
)
17+
const Name = "nodeProcess"
2018

21-
var Handshake = plugin.HandshakeConfig{
22-
ProtocolVersion: 2,
23-
MagicCookieKey: "NODE_PROCESS_PLUGIN",
24-
MagicCookieValue: "dynamic",
25-
}
19+
var (
20+
Handshake = plugin.HandshakeConfig{
21+
ProtocolVersion: 2,
22+
MagicCookieKey: "NODE_PROCESS_PLUGIN",
23+
MagicCookieValue: "dynamic",
24+
}
2625

27-
// PluginMap is the map of plugins we can dispense.
28-
var PluginMap = map[string]plugin.Plugin{
29-
Name: &AppPlugin{},
30-
}
26+
// PluginMap is the map of plugins we can dispense.
27+
PluginMap = map[string]plugin.Plugin{
28+
Name: &appPlugin{},
29+
}
3130

32-
// AppPlugin is can be served/consumed with the hashicorp plugin library.
33-
// Plugin implements plugin.GRPCPlugin
34-
type AppPlugin struct {
31+
_ plugin.Plugin = &appPlugin{}
32+
_ plugin.GRPCPlugin = &appPlugin{}
33+
)
34+
35+
type appPlugin struct {
3536
plugin.NetRPCUnsupportedPlugin
3637
app app.App
3738
}
3839

39-
func New(app app.App) *AppPlugin {
40-
return &AppPlugin{
41-
app: app,
42-
}
43-
}
44-
4540
// GRPCServer registers a new GRPC server.
46-
func (p *AppPlugin) GRPCServer(_ *plugin.GRPCBroker, s *grpc.Server) error {
41+
func (p *appPlugin) GRPCServer(_ *plugin.GRPCBroker, s *grpc.Server) error {
4742
pluginproto.RegisterNodeServer(s, NewServer(p.app))
4843
return nil
4944
}
5045

5146
// GRPCClient returns a new GRPC client
52-
func (p *AppPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) {
47+
func (p *appPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) {
5348
return NewClient(pluginproto.NewNodeClient(c)), nil
5449
}

app/runner/runner.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ func Run(config Config, nodeConfig node.Config) {
2525
if config.PluginMode { // Serve as a plugin
2626
plugin.Serve(&plugin.ServeConfig{
2727
HandshakeConfig: appplugin.Handshake,
28-
Plugins: map[string]plugin.Plugin{
29-
appplugin.Name: appplugin.New(nodeApp),
30-
},
31-
GRPCServer: plugin.DefaultGRPCServer, // A non-nil value here enables gRPC serving for this plugin
28+
Plugins: appplugin.PluginMap,
29+
GRPCServer: plugin.DefaultGRPCServer, // A non-nil value here enables gRPC serving for this plugin
3230
Logger: hclog.New(&hclog.LoggerOptions{
3331
Level: hclog.Error,
3432
}),

cache/lru_cache.go

+1-7
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ import (
88
"sync"
99
)
1010

11-
const (
12-
minCacheSize = 32
13-
)
11+
const minCacheSize = 32
1412

1513
var _ Cacher = &LRU{}
1614

@@ -29,31 +27,27 @@ type LRU struct {
2927
Size int
3028
}
3129

32-
// Put implements the cache interface
3330
func (c *LRU) Put(key, value interface{}) {
3431
c.lock.Lock()
3532
defer c.lock.Unlock()
3633

3734
c.put(key, value)
3835
}
3936

40-
// Get implements the cache interface
4137
func (c *LRU) Get(key interface{}) (interface{}, bool) {
4238
c.lock.Lock()
4339
defer c.lock.Unlock()
4440

4541
return c.get(key)
4642
}
4743

48-
// Evict implements the cache interface
4944
func (c *LRU) Evict(key interface{}) {
5045
c.lock.Lock()
5146
defer c.lock.Unlock()
5247

5348
c.evict(key)
5449
}
5550

56-
// Flush implements the cache interface
5751
func (c *LRU) Flush() {
5852
c.lock.Lock()
5953
defer c.lock.Unlock()

cache/unique_cache.go

-2
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ type EvictableLRU struct {
1818
Size int
1919
}
2020

21-
// Deduplicate implements the Deduplicator interface
2221
func (c *EvictableLRU) Deduplicate(value Evictable) Evictable {
2322
c.lock.Lock()
2423
defer c.lock.Unlock()
2524

2625
return c.deduplicate(value)
2726
}
2827

29-
// Flush implements the Deduplicator interface
3028
func (c *EvictableLRU) Flush() {
3129
c.lock.Lock()
3230
defer c.lock.Unlock()

codec/test_codec.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,15 @@ var Tests = []func(c GeneralCodec, t testing.TB){
4242
// The below structs and interfaces exist
4343
// for the sake of testing
4444

45+
var (
46+
_ Foo = &MyInnerStruct{}
47+
_ Foo = &MyInnerStruct2{}
48+
)
49+
4550
type Foo interface {
4651
Foo() int
4752
}
4853

49-
// *MyInnerStruct implements Foo
5054
type MyInnerStruct struct {
5155
Str string `serialize:"true"`
5256
}
@@ -55,7 +59,6 @@ func (m *MyInnerStruct) Foo() int {
5559
return 1
5660
}
5761

58-
// *MyInnerStruct2 implements Foo
5962
type MyInnerStruct2 struct {
6063
Bool bool `serialize:"true"`
6164
}

database/encdb/db.go

-12
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ func New(password []byte, db database.Database) (*Database, error) {
5252
}, manager.RegisterCodec(codecVersion, c)
5353
}
5454

55-
// Has implements the Database interface
5655
func (db *Database) Has(key []byte) (bool, error) {
5756
db.lock.RLock()
5857
defer db.lock.RUnlock()
@@ -63,7 +62,6 @@ func (db *Database) Has(key []byte) (bool, error) {
6362
return db.db.Has(key)
6463
}
6564

66-
// Get implements the Database interface
6765
func (db *Database) Get(key []byte) ([]byte, error) {
6866
db.lock.RLock()
6967
defer db.lock.RUnlock()
@@ -78,7 +76,6 @@ func (db *Database) Get(key []byte) ([]byte, error) {
7876
return db.decrypt(encVal)
7977
}
8078

81-
// Put implements the Database interface
8279
func (db *Database) Put(key, value []byte) error {
8380
db.lock.Lock()
8481
defer db.lock.Unlock()
@@ -94,7 +91,6 @@ func (db *Database) Put(key, value []byte) error {
9491
return db.db.Put(key, encValue)
9592
}
9693

97-
// Delete implements the Database interface
9894
func (db *Database) Delete(key []byte) error {
9995
db.lock.Lock()
10096
defer db.lock.Unlock()
@@ -105,30 +101,25 @@ func (db *Database) Delete(key []byte) error {
105101
return db.db.Delete(key)
106102
}
107103

108-
// NewBatch implements the Database interface
109104
func (db *Database) NewBatch() database.Batch {
110105
return &batch{
111106
Batch: db.db.NewBatch(),
112107
db: db,
113108
}
114109
}
115110

116-
// NewIterator implements the Database interface
117111
func (db *Database) NewIterator() database.Iterator {
118112
return db.NewIteratorWithStartAndPrefix(nil, nil)
119113
}
120114

121-
// NewIteratorWithStart implements the Database interface
122115
func (db *Database) NewIteratorWithStart(start []byte) database.Iterator {
123116
return db.NewIteratorWithStartAndPrefix(start, nil)
124117
}
125118

126-
// NewIteratorWithPrefix implements the Database interface
127119
func (db *Database) NewIteratorWithPrefix(prefix []byte) database.Iterator {
128120
return db.NewIteratorWithStartAndPrefix(nil, prefix)
129121
}
130122

131-
// NewIteratorWithStartAndPrefix implements the Database interface
132123
func (db *Database) NewIteratorWithStartAndPrefix(start, prefix []byte) database.Iterator {
133124
db.lock.RLock()
134125
defer db.lock.RUnlock()
@@ -142,7 +133,6 @@ func (db *Database) NewIteratorWithStartAndPrefix(start, prefix []byte) database
142133
}
143134
}
144135

145-
// Stat implements the Database interface
146136
func (db *Database) Stat(stat string) (string, error) {
147137
db.lock.RLock()
148138
defer db.lock.RUnlock()
@@ -153,7 +143,6 @@ func (db *Database) Stat(stat string) (string, error) {
153143
return db.db.Stat(stat)
154144
}
155145

156-
// Compact implements the Database interface
157146
func (db *Database) Compact(start, limit []byte) error {
158147
db.lock.Lock()
159148
defer db.lock.Unlock()
@@ -164,7 +153,6 @@ func (db *Database) Compact(start, limit []byte) error {
164153
return db.db.Compact(start, limit)
165154
}
166155

167-
// Close implements the Database interface
168156
func (db *Database) Close() error {
169157
db.lock.Lock()
170158
defer db.lock.Unlock()

database/leveldb/db.go

-4
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ func (db *Database) Compact(start []byte, limit []byte) error {
264264
return updateError(db.DB.CompactRange(util.Range{Start: start, Limit: limit}))
265265
}
266266

267-
// Close implements the Database interface
268267
func (db *Database) Close() error {
269268
db.closed.SetValue(true)
270269
return updateError(db.DB.Close())
@@ -365,18 +364,15 @@ func (it *iter) Next() bool {
365364
return hasNext
366365
}
367366

368-
// Error implements the Iterator interface
369367
func (it *iter) Error() error {
370368
if it.err != nil {
371369
return it.err
372370
}
373371
return updateError(it.Iterator.Error())
374372
}
375373

376-
// Key implements the Iterator interface
377374
func (it *iter) Key() []byte { return it.key }
378375

379-
// Value implements the Iterator interface
380376
func (it *iter) Value() []byte { return it.val }
381377

382378
func updateError(err error) error {

database/linkeddb/linkeddb.go

-1
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,6 @@ type iterator struct {
363363
err error
364364
}
365365

366-
// Next implements the Iterator interface
367366
func (it *iterator) Next() bool {
368367
// If the iterator has been exhausted, there is no next value.
369368
if it.exhausted {

0 commit comments

Comments
 (0)