Skip to content

Commit

Permalink
fix: update and fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: D4ryl00 <d4ryl00@gmail.com>
  • Loading branch information
D4ryl00 committed Apr 12, 2024
1 parent b71659a commit c36f389
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
golang 1.21.8
golangci-lint 1.50.1
golangci-lint 1.57.2
6 changes: 3 additions & 3 deletions accesscontroller/ipfs/accesscontroller_ipfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (i *ipfsAccessController) Address() address.Address {
return nil
}

func (i *ipfsAccessController) CanAppend(entry logac.LogEntry, p identityprovider.Interface, additionalContext accesscontroller.CanAppendAdditionalContext) error {
func (i *ipfsAccessController) CanAppend(entry logac.LogEntry, p identityprovider.Interface, _ accesscontroller.CanAppendAdditionalContext) error {
i.muWriteAccess.RLock()
defer i.muWriteAccess.RUnlock()

Expand All @@ -63,11 +63,11 @@ func (i *ipfsAccessController) GetAuthorizedByRole(role string) ([]string, error
return nil, nil
}

func (i *ipfsAccessController) Grant(ctx context.Context, capability string, keyID string) error {
func (i *ipfsAccessController) Grant(ctx context.Context, capability string, keyID string) error { //nolint:all
return fmt.Errorf("not implemented - does not exist in JS version")
}

func (i *ipfsAccessController) Revoke(ctx context.Context, capability string, keyID string) error {
func (i *ipfsAccessController) Revoke(ctx context.Context, capability string, keyID string) error { //nolint:all
return fmt.Errorf("not implemented - does not exist in JS version")
}

Expand Down
6 changes: 3 additions & 3 deletions accesscontroller/orbitdb/accesscontroller_orbitdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (o *orbitDBAccessController) getAuthorizations() (map[string][]string, erro
return authorizationsLists, nil
}

func (o *orbitDBAccessController) CanAppend(entry logac.LogEntry, p identityprovider.Interface, additionalContext accesscontroller.CanAppendAdditionalContext) error {
func (o *orbitDBAccessController) CanAppend(entry logac.LogEntry, p identityprovider.Interface, _ accesscontroller.CanAppendAdditionalContext) error {
writeAccess, err := o.GetAuthorizedByRole("write")
if err != nil {
return fmt.Errorf("unable to get keys with write access: %w", err)
Expand Down Expand Up @@ -249,7 +249,7 @@ func (o *orbitDBAccessController) Load(ctx context.Context, address string) erro
return nil
}

func (o *orbitDBAccessController) Save(ctx context.Context) (accesscontroller.ManifestParams, error) {
func (o *orbitDBAccessController) Save(_ context.Context) (accesscontroller.ManifestParams, error) {
return accesscontroller.NewManifestParams(o.kvStore.Address().GetRoot(), false, "orbitdb"), nil
}

Expand All @@ -261,7 +261,7 @@ func (o *orbitDBAccessController) Close() error {
return nil
}

func (o *orbitDBAccessController) onUpdate(ctx context.Context) {
func (o *orbitDBAccessController) onUpdate(_ context.Context) {
if err := o.emitterEvtUpdated.Emit(&EventUpdated{}); err != nil {
o.logger.Warn("unable to emit event updated", zap.Error(err))
}
Expand Down
10 changes: 5 additions & 5 deletions accesscontroller/simple/accesscontroller_simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ func (o *simpleAccessController) Address() address.Address {
return nil
}

func (o *simpleAccessController) Grant(ctx context.Context, capability string, keyID string) error {
func (o *simpleAccessController) Grant(ctx context.Context, capability string, keyID string) error { //nolint:all
return nil
}

func (o *simpleAccessController) Revoke(ctx context.Context, capability string, keyID string) error {
func (o *simpleAccessController) Revoke(ctx context.Context, capability string, keyID string) error { //nolint:all
return nil
}

func (o *simpleAccessController) Load(ctx context.Context, address string) error {
func (o *simpleAccessController) Load(ctx context.Context, address string) error { //nolint:all
return nil
}

func (o *simpleAccessController) Save(ctx context.Context) (accesscontroller.ManifestParams, error) {
func (o *simpleAccessController) Save(_ context.Context) (accesscontroller.ManifestParams, error) {
return accesscontroller.NewManifestParams(cid.Cid{}, true, "simple"), nil
}

Expand All @@ -66,7 +66,7 @@ func (o *simpleAccessController) GetAuthorizedByRole(role string) ([]string, err
return o.allowedKeys[role], nil
}

func (o *simpleAccessController) CanAppend(e logac.LogEntry, p identityprovider.Interface, additionalContext accesscontroller.CanAppendAdditionalContext) error {
func (o *simpleAccessController) CanAppend(e logac.LogEntry, _ identityprovider.Interface, _ accesscontroller.CanAppendAdditionalContext) error {
for _, id := range o.allowedKeys["write"] {
if e.GetIdentity().ID == id || id == "*" {
return nil
Expand Down
3 changes: 2 additions & 1 deletion baseorbitdb/orbitdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
peer "github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/p2p/host/eventbus"
"go.opentelemetry.io/otel/trace"
tracenoop "go.opentelemetry.io/otel/trace/noop"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -334,7 +335,7 @@ func newOrbitDB(ctx context.Context, is coreiface.CoreAPI, identity *idp.Identit
}

if options.Tracer == nil {
options.Tracer = trace.NewNoopTracerProvider().Tracer("")
options.Tracer = tracenoop.NewTracerProvider().Tracer("")
}

if options.EventBus == nil {
Expand Down
2 changes: 1 addition & 1 deletion events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type eventBox struct {

// Deprecated: use event bus directly
// Emit Sends an event to the subscribed listeners
func (e *EventEmitter) Emit(ctx context.Context, evt Event) {
func (e *EventEmitter) Emit(_ context.Context, evt Event) {
e.muEmitters.Lock()

bus := e.getBus()
Expand Down
4 changes: 2 additions & 2 deletions pubsub/directchannel/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (d *directChannel) handleNewPeer(s network.Stream) {

// @NOTE(gfanton): we dont need this on direct channel
// Connect Waits for the other peer to be connected
func (d *directChannel) Connect(ctx context.Context, pid peer.ID) (err error) {
func (d *directChannel) Connect(ctx context.Context, pid peer.ID) (err error) { //nolint:all
return nil
}

Expand All @@ -92,7 +92,7 @@ type holderChannels struct {
logger *zap.Logger
}

func (c *holderChannels) NewChannel(ctx context.Context, emitter iface.DirectChannelEmitter, opts *iface.DirectChannelOptions) (iface.DirectChannel, error) {
func (c *holderChannels) NewChannel(_ context.Context, emitter iface.DirectChannelEmitter, opts *iface.DirectChannelOptions) (iface.DirectChannel, error) {
if opts == nil {
opts = &iface.DirectChannelOptions{}
}
Expand Down
3 changes: 2 additions & 1 deletion pubsub/pubsubcoreapi/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/ipfs/kubo/core/coreiface/options"
"github.com/libp2p/go-libp2p/core/peer"
"go.opentelemetry.io/otel/trace"
tracenoop "go.opentelemetry.io/otel/trace/noop"
"go.uber.org/zap"

"berty.tech/go-orbit-db/events"
Expand Down Expand Up @@ -172,7 +173,7 @@ func NewPubSub(api coreiface.CoreAPI, id peer.ID, pollInterval time.Duration, lo
}

if tracer == nil {
tracer = trace.NewNoopTracerProvider().Tracer("")
tracer = tracenoop.NewTracerProvider().Tracer("")
}

return &coreAPIPubSub{
Expand Down
3 changes: 2 additions & 1 deletion pubsub/pubsubraw/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
p2ppubsub "github.com/libp2p/go-libp2p-pubsub"
"github.com/libp2p/go-libp2p/core/peer"
"go.opentelemetry.io/otel/trace"
tracernoop "go.opentelemetry.io/otel/trace/noop"
"go.uber.org/zap"

"berty.tech/go-orbit-db/events"
Expand Down Expand Up @@ -141,7 +142,7 @@ func NewPubSub(ps *p2ppubsub.PubSub, id peer.ID, logger *zap.Logger, tracer trac
}

if tracer == nil {
tracer = trace.NewNoopTracerProvider().Tracer("")
tracer = tracernoop.NewTracerProvider().Tracer("")
}

return &rawPubSub{
Expand Down
2 changes: 1 addition & 1 deletion stores/basestore/base_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (b *baseIndex) Get(_ string) interface{} {
return b.index
}

func (b *baseIndex) UpdateIndex(log ipfslog.Log, entries []ipfslog.Entry) error {
func (b *baseIndex) UpdateIndex(log ipfslog.Log, _ []ipfslog.Entry) error {
b.mu.Lock()
defer b.mu.Unlock()
b.index = log.Values().Slice()
Expand Down
5 changes: 3 additions & 2 deletions stores/basestore/base_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/pkg/errors"
otkv "go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
tracenoop "go.opentelemetry.io/otel/trace/noop"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -180,7 +181,7 @@ func (b *BaseStore) InitBaseStore(ipfs coreiface.CoreAPI, identity *identityprov
b.messageMarshaler = options.MessageMarshaler

if options.Tracer == nil {
options.Tracer = trace.NewNoopTracerProvider().Tracer("")
options.Tracer = tracenoop.NewTracerProvider().Tracer("")
}

if identity == nil {
Expand Down Expand Up @@ -662,7 +663,7 @@ func (b *BaseStore) Sync(ctx context.Context, heads []ipfslog.Entry) error {
return nil
}

func (b *BaseStore) LoadMoreFrom(ctx context.Context, amount uint, entries []ipfslog.Entry) {
func (b *BaseStore) LoadMoreFrom(ctx context.Context, amount uint, entries []ipfslog.Entry) { //nolint:all
b.Replicator().Load(ctx, entries)
// TODO: can this return an error?
}
Expand Down
4 changes: 2 additions & 2 deletions stores/documentstore/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type orbitDBDocumentStore struct {
docOpts *iface.CreateDocumentDBOptions
}

func (o *orbitDBDocumentStore) Get(ctx context.Context, key string, opts *iface.DocumentStoreGetOptions) ([]interface{}, error) {
func (o *orbitDBDocumentStore) Get(_ context.Context, key string, opts *iface.DocumentStoreGetOptions) ([]interface{}, error) {
if opts == nil {
opts = &iface.DocumentStoreGetOptions{}
}
Expand Down Expand Up @@ -179,7 +179,7 @@ func (o *orbitDBDocumentStore) PutAll(ctx context.Context, values []interface{})
}

// Query Finds documents using a filter function
func (o *orbitDBDocumentStore) Query(ctx context.Context, filter func(doc interface{}) (bool, error)) ([]interface{}, error) {
func (o *orbitDBDocumentStore) Query(_ context.Context, filter func(doc interface{}) (bool, error)) ([]interface{}, error) {
docIndex, ok := o.Index().(*documentIndex)
if !ok {
return nil, fmt.Errorf("unable to cast index to documentIndex")
Expand Down
2 changes: 1 addition & 1 deletion stores/eventlogstore/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type eventIndex struct {
lock sync.RWMutex
}

func (i *eventIndex) Get(key string) interface{} {
func (i *eventIndex) Get(key string) interface{} { //nolint:all
i.lock.RLock()
defer i.lock.RUnlock()

Expand Down
2 changes: 1 addition & 1 deletion stores/eventlogstore/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (o *orbitDBEventLogStore) Get(ctx context.Context, cid cid.Cid) (operation.
}
}

func (o *orbitDBEventLogStore) Stream(ctx context.Context, resultChan chan operation.Operation, options *iface.StreamOptions) error {
func (o *orbitDBEventLogStore) Stream(_ context.Context, resultChan chan operation.Operation, options *iface.StreamOptions) error {
defer close(resultChan)
messages, err := o.query(options)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion stores/kvstore/keyvalue.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (o *orbitDBKeyValue) Delete(ctx context.Context, key string) (operation.Ope
return op, nil
}

func (o *orbitDBKeyValue) Get(ctx context.Context, key string) ([]byte, error) {
func (o *orbitDBKeyValue) Get(_ context.Context, key string) ([]byte, error) {
value, ok := o.Index().(*kvIndex).Get(key).([]byte)
if value == nil {
return nil, nil
Expand Down
5 changes: 3 additions & 2 deletions stores/replicator/replicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/libp2p/go-libp2p/p2p/host/eventbus"
otkv "go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
tracenoop "go.opentelemetry.io/otel/trace/noop"
"go.uber.org/zap"
"golang.org/x/sync/semaphore"
)
Expand Down Expand Up @@ -77,7 +78,7 @@ func NewReplicator(store storeInterface, concurrency uint, opts *Options) (Repli
}

if opts.Tracer == nil {
opts.Tracer = trace.NewNoopTracerProvider().Tracer("")
opts.Tracer = tracenoop.NewTracerProvider().Tracer("")
}

if concurrency == 0 {
Expand Down Expand Up @@ -178,7 +179,7 @@ func (r *replicator) Load(ctx context.Context, entries []ipfslog.Entry) {
wg.Add(1)

// add one process
go func(i int) {
go func(_ int) {
if err := r.processOne(ctx, &wg); err != nil {
r.logger.Warn("unable to process entry", zap.Error(err))
}
Expand Down

0 comments on commit c36f389

Please sign in to comment.