Skip to content

Commit

Permalink
Rename unused parameters (for linter)
Browse files Browse the repository at this point in the history
Signed-off-by: Matej Pavlovic <matopavlovic@gmail.com>
  • Loading branch information
matejpavlovic committed Apr 3, 2024
1 parent 1ff4796 commit 7dc28ff
Show file tree
Hide file tree
Showing 18 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion cmd/bench/cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var (
clientCmd = &cobra.Command{
Use: "client",
Short: "Generate and submit transactions to a Mir cluster",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return runClient()
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/bench/cmd/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var (
nodeCmd = &cobra.Command{
Use: "node",
Short: "Start a Mir node",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
if err := runNode(); !es.Is(err, mir.ErrStopped) {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/bench/cmd/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var (
paramsCmd = &cobra.Command{
Use: "params",
Short: "generate parameters",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
return generateParams(args)
},
}
Expand Down
2 changes: 1 addition & 1 deletion codegen/generators/dsl-gen/generator/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func generateDslFunctionForHandlingSimpleEvent(eventNode *events.EventNode, upon

func GetDslOriginOption(origin *events.Origin) (*types.OneofOption, bool) {
return sliceutil.Any(
sliceutil.Filter(origin.TypeOneof.Options, func(i int, opt *types.OneofOption) bool {
sliceutil.Filter(origin.TypeOneof.Options, func(_ int, opt *types.OneofOption) bool {
return opt.Name() == "Dsl"
}),
)
Expand Down
6 changes: 3 additions & 3 deletions codegen/model/types/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ type Fields []*Field

// FuncParamsPbTypes returns a list of field lowercase names followed by their pb types.
func (fs Fields) FuncParamsPbTypes() []jen.Code {
return sliceutil.Transform(fs, func(i int, f *Field) jen.Code { return f.FuncParamPbType() })
return sliceutil.Transform(fs, func(_ int, f *Field) jen.Code { return f.FuncParamPbType() })
}

// FuncParamsMirTypes returns a list of field lowercase names followed by their mir types.
func (fs Fields) FuncParamsMirTypes() []jen.Code {
return sliceutil.Transform(fs, func(i int, f *Field) jen.Code { return f.FuncParamMirType() })
return sliceutil.Transform(fs, func(_ int, f *Field) jen.Code { return f.FuncParamMirType() })
}

// FuncParamsIDs returns a list of fields lowercase names as identifiers, without the types.
func (fs Fields) FuncParamsIDs() []jen.Code {
return sliceutil.Transform(fs, func(i int, f *Field) jen.Code { return jen.Id(f.LowercaseName()) })
return sliceutil.Transform(fs, func(_ int, f *Field) jen.Code { return jen.Id(f.LowercaseName()) })
}

// ByName returns the field with the given name (or nil if there is no such field).
Expand Down
2 changes: 1 addition & 1 deletion node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func (c *consumer) ImplementsModule() {}
// ApplyEvents increments a counter and sleeps for a given duration (set at module instantiation)
// for each event in the given list.
func (c *consumer) ApplyEvents(evts *stdtypes.EventList) (*stdtypes.EventList, error) {
evtsOut, err := modules.ApplyEventsSequentially(evts, func(event stdtypes.Event) (*stdtypes.EventList, error) {
evtsOut, err := modules.ApplyEventsSequentially(evts, func(_ stdtypes.Event) (*stdtypes.EventList, error) {
atomic.AddUint64(&c.numProcessed, 1)
time.Sleep(c.delay)
return stdtypes.EmptyList(), nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func IncludeVerificationOfCertificates(
})

// When the signatures in a certificate are verified, output the result of certificate verification.
cryptopbdsl.UponSigsVerified(m, func(nodeIDs []t.NodeID, errs []error, allOK bool, context *verifySigsInCertContext) error {
cryptopbdsl.UponSigsVerified(m, func(_ []t.NodeID, _ []error, allOK bool, context *verifySigsInCertContext) error {
reqID := context.reqID

if _, ok := state.RequestState[reqID]; !ok {
Expand Down
2 changes: 1 addition & 1 deletion pkg/batchfetcher/batchfetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func NewModule(mc ModuleConfig, epochNr tt.EpochNr, clientProgress *clientprogre

// The DeliverCert handler requests the transactions referenced by the received availability certificate
// from the availability layer.
isspbdsl.UponDeliverCert(m, func(sn tt.SeqNr, cert *apbtypes.Cert, empty bool) error {
isspbdsl.UponDeliverCert(m, func(_ tt.SeqNr, cert *apbtypes.Cert, empty bool) error {
// Create an empty output item and enqueue it immediately.
// Actual output will be delayed until the transactions have been received.
// This is necessary to preserve the order of incoming and outgoing events.
Expand Down
4 changes: 2 additions & 2 deletions pkg/bcb/bcbmodule.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func NewModule(mc ModuleConfig, params *ModuleParams, nodeID stdtypes.NodeID) mo
return nil
})

cryptopbdsl.UponSignResult(m, func(signature []byte, context *signStartMessageContext) error {
cryptopbdsl.UponSignResult(m, func(signature []byte, _ *signStartMessageContext) error {
if !state.sentEcho {
state.sentEcho = true
transportpbdsl.SendMessage(m, mc.Net, bcbpbmsgs.EchoMessage(mc.Self, signature), []stdtypes.NodeID{params.Leader})
Expand Down Expand Up @@ -133,7 +133,7 @@ func NewModule(mc ModuleConfig, params *ModuleParams, nodeID stdtypes.NodeID) mo
})

// upon event <al, Deliver | p, [FINAL, m, Σ]> do
bcbpbdsl.UponFinalMessageReceived(m, func(from stdtypes.NodeID, data []byte, signers []stdtypes.NodeID, signatures [][]byte) error {
bcbpbdsl.UponFinalMessageReceived(m, func(_ stdtypes.NodeID, data []byte, signers []stdtypes.NodeID, signatures [][]byte) error {
// if #({p ∈ Π | Σ[p] != ⊥ ∧ verifysig(p, bcb||p||ECHO||m, Σ[p])}) > (N+f)/2 and delivered = FALSE do
if len(signers) == len(signatures) && len(signers) > (params.GetN()+params.GetF())/2 && !state.delivered {
signedMessage := [][]byte{params.InstanceUID, []byte("ECHO"), data}
Expand Down
4 changes: 2 additions & 2 deletions pkg/checkpoint/serializing_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import (
func FuzzCheckpointForSig(f *testing.F) {
f.Add(uint64(0), uint64(0), []byte("13242342342342"))

f.Fuzz(func(t *testing.T, s, n uint64, data []byte) {
f.Fuzz(func(_ *testing.T, s, n uint64, data []byte) {
serializeCheckpointForSig(tt.EpochNr(s), tt.SeqNr(n), data)
})
}

func FuzzSnapshotForHash(f *testing.F) {
f.Add(100, uint64(0), "/ip4/7.7.7.7/tcp/1234/p2p/QmYyQSo1c1Ym7orWxLYvCrM2EmxFTANf8wXmmE7DWjhx5N", "127.0.0.1:3333", []byte("13242342342342"))

f.Fuzz(func(t *testing.T, n int, e uint64, k, v string, data []byte) {
f.Fuzz(func(_ *testing.T, n int, e uint64, k, v string, data []byte) {
n = n % 5000
membership := trantorpbtypes.Membership{make(map[stdtypes.NodeID]*trantorpbtypes.NodeIdentity)} // nolint:govet

Expand Down
2 changes: 1 addition & 1 deletion pkg/deploytest/localtransport.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type LocalTransportLayer interface {
func NewLocalTransportLayer(sim *Simulation, transportType string, nodeIDsWeight map[t.NodeID]types.VoteWeight, logger logging.Logger) (LocalTransportLayer, error) {
switch transportType {
case "sim":
messageDelayFn := func(from, to t.NodeID) time.Duration {
messageDelayFn := func(_, _ t.NodeID) time.Duration {
// TODO: Make min and max message delay configurable
return testsim.RandDuration(sim.Rand, 0, 10*time.Millisecond)
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/dsl/test/dslmodule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func newContextTestingModule(mc *contextTestingModuleModuleConfig) dsl.Module {
return nil
})

cryptopbdsl.UponSigsVerified(m, func(nodeIDs []stdtypes.NodeID, errs []error, allOK bool, context *uint64) error {
cryptopbdsl.UponSigsVerified(m, func(nodeIDs []stdtypes.NodeID, _ []error, allOK bool, context *uint64) error {
if allOK {
for _, nodeID := range nodeIDs {
EmitTestingString(m, mc.Verified, fmt.Sprintf("%v: %v verified", *context, nodeID))
Expand All @@ -292,7 +292,7 @@ func newContextTestingModule(mc *contextTestingModuleModuleConfig) dsl.Module {
return nil
})

cryptopbdsl.UponSigsVerified(m, func(nodeIDs []stdtypes.NodeID, errs []error, allOK bool, context *uint64) error {
cryptopbdsl.UponSigsVerified(m, func(_ []stdtypes.NodeID, _ []error, allOK bool, context *uint64) error {
if allOK {
EmitTestingUint(m, mc.Verified, *context)
}
Expand All @@ -304,7 +304,7 @@ func newContextTestingModule(mc *contextTestingModuleModuleConfig) dsl.Module {

func TestDslModule_ContextRecoveryAndCleanup(t *testing.T) {
testCases := map[string]func(mc *contextTestingModuleModuleConfig, m dsl.Module){
"empty": func(mc *contextTestingModuleModuleConfig, m dsl.Module) {},
"empty": func(_ *contextTestingModuleModuleConfig, _ dsl.Module) {},

"request response": func(mc *contextTestingModuleModuleConfig, m dsl.Module) {
eventsOut, err := m.ApplyEvents(stdtypes.ListOf(stdevents.NewTestString(mc.Self, "hello")))
Expand Down Expand Up @@ -404,7 +404,7 @@ func TestDslModule_ContextRecoveryAndCleanup(t *testing.T) {

for testName, tc := range testCases {
tc := tc
t.Run(testName, func(t *testing.T) {
t.Run(testName, func(_ *testing.T) {
mc := defaultContextTestingModuleConfig()
m := newContextTestingModule(mc)
tc(mc, m)
Expand Down
2 changes: 1 addition & 1 deletion pkg/eventlog/recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func NewRecorder(
fileCount: 1,
newDests: OneFileLogger(),
path: path,
filter: func(event stdtypes.Event) bool {
filter: func(_ stdtypes.Event) bool {
// Record all events by default.
return true
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/iss/iss.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ func New(
})

chkppbdsl.UponStableCheckpointReceived(iss.m,
func(sender stdtypes.NodeID, sn tt.SeqNr, snapshot *trantorpbtypes.StateSnapshot, cert map[stdtypes.NodeID][]byte) error {
func(_ stdtypes.NodeID, sn tt.SeqNr, snapshot *trantorpbtypes.StateSnapshot, cert map[stdtypes.NodeID][]byte) error {
chkp := &checkpointpbtypes.StableCheckpoint{
Sn: sn,
Snapshot: snapshot,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func IncludeBatchCreation( // nolint:gocognit
batchSize := 0
txCount := 0

txIDs, txs, _ := state.Iterator.NextWhile(func(txID tt.TxID, tx *trantorpbtypes.Transaction) bool {
txIDs, txs, _ := state.Iterator.NextWhile(func(_ tt.TxID, tx *trantorpbtypes.Transaction) bool {
if txCount < params.MaxTransactionsInBatch && batchSize+len(tx.Data) <= params.MaxPayloadInBatch {
txCount++
state.NumUnproposed--
Expand Down Expand Up @@ -176,7 +176,7 @@ func IncludeBatchCreation( // nolint:gocognit
// ClientProgress - for each client, list of pending transactions sorted by TxNo - that
// would make pruning significantly more efficient.
state.ClientProgress.LoadPb(clientProgress.Pb())
_, removedTXs := state.Transactions.RemoveSelected(func(txID tt.TxID, tx *trantorpbtypes.Transaction) bool {
_, removedTXs := state.Transactions.RemoveSelected(func(_ tt.TxID, tx *trantorpbtypes.Transaction) bool {
return state.ClientProgress.Contains(tx.ClientId, tx.TxNo)
})
for _, tx := range removedTXs {
Expand Down
2 changes: 1 addition & 1 deletion pkg/orderers/internal/parts/catchup/catchup.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func SendDoneMessages(

// Collect the preprepare digests of all committed certificates.
digests := make([][]byte, 0, state.Segment.Len())
maputil.IterateSorted(state.Slots[state.View], func(sn tt.SeqNr, slot *common.PbftSlot) bool {
maputil.IterateSorted(state.Slots[state.View], func(_ tt.SeqNr, slot *common.PbftSlot) bool {
digests = append(digests, slot.Digest)
return true
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/trantor/testing/smr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ func newDeployment(conf *TestConfig) (*deploytest.Deployment, error) {
var simulation *deploytest.Simulation
if conf.Transport == simTransportName {
r := rand.New(rand.NewSource(conf.RandomSeed)) // nolint: gosec
eventDelayFn := func(e stdtypes.Event) time.Duration {
eventDelayFn := func(_ stdtypes.Event) time.Duration {
// TODO: Make min and max event processing delay configurable
return testsim.RandDuration(r, 0, time.Microsecond)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/util/indexedlist/indexedlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestIndexedList_RemoveSelected(t *testing.T) {
il.Append([]string{"a", "b", "c"}, []int{0, 1, 2})
assert.Equal(t, 3, il.Len())

keys, vals := il.RemoveSelected(func(key string, val int) bool {
keys, vals := il.RemoveSelected(func(key string, _ int) bool {
return key == "b" || key == "c"
})
assert.Equal(t, []string{"b", "c"}, keys)
Expand Down Expand Up @@ -149,7 +149,7 @@ func TestIterator_NextWhile(t *testing.T) {
// Condition allowing all elements to be traversed.
iter := il.Iterator(0)
sum := 0
keys, vals, ok := iter.NextWhile(func(key string, val int) bool {
keys, vals, ok := iter.NextWhile(func(_ string, val int) bool {
if sum+val <= 10 {
sum += val
return true
Expand All @@ -171,7 +171,7 @@ func TestIterator_NextWhile(t *testing.T) {
// Condition allowing only part of the elements to be traversed.
iter = il.Iterator(0)
sum = 0
keys, vals, ok = iter.NextWhile(func(key string, val int) bool {
keys, vals, ok = iter.NextWhile(func(_ string, val int) bool {
if sum+val <= 1 {
sum += val
return true
Expand Down

0 comments on commit 7dc28ff

Please sign in to comment.