Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package simplex

import (
"context"
"errors"
"fmt"
"math"
"sync"
Expand All @@ -19,6 +20,8 @@ import (
"go.uber.org/zap"
)

var errAlreadyStarted = errors.New("instance already started")

const (
// tickInterval is the interval at which the instance will call AdvanceTime on the current epoch or non-validator.
tickInterval = time.Millisecond * 100
Expand All @@ -34,14 +37,15 @@ type Config struct {
PlatformChain PlatformChain
// Broadcaster is the interface to broadcast messages to other nodes in the network.
Broadcaster Broadcaster
// Sender is an interface to send messages to a specific node in the network
Sender Sender
// CryptoOps is the interface to the cryptographic operations needed by the simplex instance.
CryptoOps CryptoOps
// WalCreator is the interface to create new write-ahead logs for the simplex instance.
WalCreator wal.Creator
// Storage is the interface to the block storage layer for the simplex instance.
Storage Storage
Logger common.Logger
Sender Sender
WALs []wal.DeletableWAL
VM VM
ICMETransition metadata.ICMEpochTransition
Expand Down Expand Up @@ -94,7 +98,7 @@ func (i *Instance) Start(ctx context.Context) error {
defer i.lock.Unlock()

if i.started {
return fmt.Errorf("instance already started")
return errAlreadyStarted
}

i.started = true
Expand Down
2 changes: 1 addition & 1 deletion instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ func TestInstanceDoubleStartFails(t *testing.T) {
require.NoError(t, inst.Start(t.Context()))
t.Cleanup(inst.Stop)

require.ErrorContains(t, inst.Start(t.Context()), "instance already started")
require.ErrorIs(t, inst.Start(t.Context()), errAlreadyStarted)
}

func TestNonValidatorSkipsMSMVerification(t *testing.T) {
Expand Down
Loading