simulator

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 69 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deterministic added in v1.2.10

func Deterministic(opts *simFactory) error

Deterministic attempts to run the simulator in a fully deterministic, repeatable way.

func DisableAnchorHealing added in v1.2.10

func DisableAnchorHealing(opts *simFactory) error

DisableAnchorHealing disables healing of anchors after they are initially submitted.

func DropDispatchedMessages added in v1.2.10

func DropDispatchedMessages(opts *simFactory) error

DropDispatchedMessages drops all internally dispatched messages.

func DropInitialAnchor added in v1.2.10

func DropInitialAnchor(opts *simFactory) error

DropInitialAnchor drops anchors when they are initially submitted.

func DumpRecording added in v1.2.0

func DumpRecording(rd ioutil.SectionReader) error

func IgnoreCommitResults added in v1.2.10

func IgnoreCommitResults(opts *simFactory) error

IgnoreCommitResults ignores inconsistencies in the result of Commit.

func IgnoreDeliverResults added in v1.2.10

func IgnoreDeliverResults(opts *simFactory) error

IgnoreDeliverResults ignores inconsistencies in the result of DeliverTx.

func MemoryDatabase deprecated

func MemoryDatabase(*simFactory) error

MemoryDatabase configures the simulator to use in-memory databases.

Deprecated: This is a no-op

func NewLocalNetwork added in v1.1.1

func NewLocalNetwork(name string, bvnCount, nodeCount int, baseIP net.IP, basePort uint64) *accumulated.NetworkInit

NewLocalNetwork returns a SimpleNetwork with sequential IPs starting from the base IP with the given base port.

func NewSimpleNetwork added in v1.1.1

func NewSimpleNetwork(name string, bvnCount, nodeCount int) *accumulated.NetworkInit

NewSimpleNetwork creates a basic network with the given name, number of BVNs, and number of nodes per BVN.

func SkipProposalCheck added in v1.2.10

func SkipProposalCheck(opts *simFactory) error

SkipProposalCheck skips checking if each non-leader node agrees with the leader's proposed block.

Types

type BlockHookFunc added in v1.1.0

type BlockHookFunc = func(execute.BlockParams, []*messaging.Envelope) (_ []*messaging.Envelope, keepHook bool)

type ListenOptions added in v1.1.0

type ListenOptions struct {
	// ListenHTTPv2 enables API v2 over HTTP.
	ListenHTTPv2 bool

	// ListenHTTPv3 enables API v3 over HTTP.
	ListenHTTPv3 bool

	// ListenWSv3 enables API v3 over WebSockets.
	ListenWSv3 bool

	// ListenP2Pv3 enables API v3 over libp2p.
	ListenP2Pv3 bool

	// HookHTTP hooks into HTTP calls.
	HookHTTP func(http.Handler, http.ResponseWriter, *http.Request)

	// ServeError handles errors produced by http.Server.Serve. If Error is nil,
	// ListenAndServe will panic if http.Server.Serve returns an error.
	ServeError func(error)
}

ListenOptions are options for Simulator.ListenAndServe.

type Node

type Node struct {
	// contains filtered or unexported fields
}

func (*Node) ConsensusStatus added in v1.2.10

func (n *Node) ConsensusStatus(ctx context.Context, opts api.ConsensusStatusOptions) (*api.ConsensusStatus, error)

ConsensusStatus implements api.ConsensusService.

func (*Node) Submit added in v1.2.10

func (n *Node) Submit(ctx context.Context, envelope *messaging.Envelope, opts api.SubmitOptions) ([]*api.Submission, error)

func (*Node) Validate added in v1.2.10

func (n *Node) Validate(ctx context.Context, envelope *messaging.Envelope, opts api.ValidateOptions) ([]*api.Submission, error)

type NodeBlockHookFunc added in v1.1.1

type NodeBlockHookFunc = func(int, execute.BlockParams, []*messaging.Envelope) (_ []*messaging.Envelope, keepHook bool)

type OpenDatabaseFunc

type OpenDatabaseFunc = func(partition *protocol.PartitionInfo, node int, logger log.Logger) keyvalue.Beginner

type Option added in v1.1.1

type Option func(*simFactory) error

func BadgerDatabaseFromDirectory

func BadgerDatabaseFromDirectory(dir string, onErr func(error)) Option

func CaptureDispatchedMessages added in v1.2.10

func CaptureDispatchedMessages(fn dispatchInterceptor) Option

CaptureDispatchedMessages allows the caller to capture internally dispatched messages.

func Genesis

func Genesis(time time.Time) Option

func GenesisWith

func GenesisWith(time time.Time, values *core.GlobalValues) Option

func GenesisWithVersion added in v1.1.0

func GenesisWithVersion(time time.Time, version protocol.ExecutorVersion) Option

func InitialAcmeSupply added in v1.2.10

func InitialAcmeSupply(v *big.Int) Option

InitialAcmeSupply overrides the default initial ACME supply. A value of nil will disable setting the initial supply.

func LocalNetwork added in v1.1.0

func LocalNetwork(name string, bvnCount, nodeCount int, baseIP net.IP, basePort uint64) Option

func SimpleNetwork

func SimpleNetwork(name string, bvnCount, nodeCount int) Option

func SnapshotFromDirectory

func SnapshotFromDirectory(dir string) Option

func SnapshotMap added in v1.1.0

func SnapshotMap(snapshots map[string][]byte) Option

func WithDatabase added in v1.1.1

func WithDatabase(fn OpenDatabaseFunc) Option

func WithLogger added in v1.2.10

func WithLogger(logger log.Logger) Option

func WithNetwork added in v1.1.1

func WithNetwork(net *accumulated.NetworkInit) Option

func WithRecordings added in v1.2.10

func WithRecordings(fn RecordingFunc) Option

WithRecordings takes a function that returns files to write node recordings to.

func WithSnapshot added in v1.1.1

func WithSnapshot(fn SnapshotFunc) Option

type Partition

type Partition struct {
	protocol.PartitionInfo
	// contains filtered or unexported fields
}

func (*Partition) Begin added in v1.1.0

func (p *Partition) Begin(writable bool) *database.Batch

Begin will panic if called to create a writable batch if the partition has more than one node.

func (*Partition) SetBlockHook added in v1.1.0

func (p *Partition) SetBlockHook(fn BlockHookFunc)

SetBlockHook sets a general block hook. SetBlockHook is mutually exclusive with SetNodeBlockHook.

func (*Partition) SetNodeBlockHook added in v1.1.1

func (p *Partition) SetNodeBlockHook(fn NodeBlockHookFunc)

SetNodeBlockHook sets a node-specific block hook. SetNodeBlockHook is mutually exclusive with SetBlockHook.

func (*Partition) SetObserver added in v1.1.0

func (p *Partition) SetObserver(observer database.Observer)

func (*Partition) SetSubmitHook

func (p *Partition) SetSubmitHook(fn SubmitHookFunc)

func (*Partition) Submit

func (p *Partition) Submit(envelope *messaging.Envelope, pretend bool) ([]*protocol.TransactionStatus, error)

func (*Partition) Update

func (p *Partition) Update(fn func(*database.Batch) error) error

func (*Partition) View

func (p *Partition) View(fn func(*database.Batch) error) error

type RecordingFunc added in v1.2.0

type RecordingFunc = func(partition string, node int) (io.WriteSeeker, error)

type ResponseSubmit added in v1.1.1

type ResponseSubmit struct {
	Code         uint32
	Data         []byte
	Log          string
	Info         string
	Codespace    string
	MempoolError string
}

ResponseSubmit is the response from a call to Submit.

type Router

type Router struct {
	// contains filtered or unexported fields
}

func (*Router) Route

func (r *Router) Route(envs ...*messaging.Envelope) (string, error)

func (*Router) RouteAccount

func (r *Router) RouteAccount(account *url.URL) (string, error)

func (*Router) SetRoute

func (r *Router) SetRoute(account *url.URL, partition string)

type Simulator

type Simulator struct {
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) (*Simulator, error)

func (*Simulator) BlockIndex added in v1.1.0

func (s *Simulator) BlockIndex(partition string) uint64

func (*Simulator) BlockIndexFor added in v1.1.0

func (s *Simulator) BlockIndexFor(account *url.URL) uint64

func (*Simulator) ClientV2 added in v1.1.0

func (s *Simulator) ClientV2(part string) *client.Client

ClientV2 returns an API V2 client for the given partition.

func (*Simulator) Collect added in v1.1.1

func (s *Simulator) Collect(partition string, file io.WriteSeeker, opts *database.CollectOptions) error

func (*Simulator) Database

func (s *Simulator) Database(partition string) database.Beginner

func (*Simulator) DatabaseFor

func (s *Simulator) DatabaseFor(account *url.URL) database.Updater

func (*Simulator) EventBus added in v1.1.0

func (s *Simulator) EventBus(partition string) *events.Bus

func (*Simulator) ListenAndServe

func (s *Simulator) ListenAndServe(ctx context.Context, opts ListenOptions) (err error)

ListenAndServe serves the Accumulate API. The simulator must have been initialized with a network configuration that includes addresses. At least one of the Listen options of opts must be true.

func (*Simulator) NewDirectClientWithHook added in v1.1.0

func (s *Simulator) NewDirectClientWithHook(hook func(http.Handler) http.Handler) *client.Client

NewDirectClientWithHook creates a direct HTTP client and applies the given hook.

func (*Simulator) Partition added in v1.1.1

func (s *Simulator) Partition(partition string) *Partition

func (*Simulator) Partitions

func (s *Simulator) Partitions() []*protocol.PartitionInfo

func (*Simulator) Router

func (s *Simulator) Router() *Router

func (*Simulator) Services added in v1.1.0

func (s *Simulator) Services() *message.Client

Services returns the simulator's API v3 implementation.

func (*Simulator) SetBlockHook added in v1.1.0

func (s *Simulator) SetBlockHook(partition string, fn BlockHookFunc)

func (*Simulator) SetBlockHookFor added in v1.1.0

func (s *Simulator) SetBlockHookFor(account *url.URL, fn BlockHookFunc)

func (*Simulator) SetNodeBlockHook added in v1.1.1

func (s *Simulator) SetNodeBlockHook(partition string, fn NodeBlockHookFunc)

func (*Simulator) SetNodeBlockHookFor added in v1.1.1

func (s *Simulator) SetNodeBlockHookFor(account *url.URL, fn NodeBlockHookFunc)

func (*Simulator) SetRoute

func (s *Simulator) SetRoute(account *url.URL, partition string)

func (*Simulator) SetSubmitHook

func (s *Simulator) SetSubmitHook(partition string, fn SubmitHookFunc)

func (*Simulator) SetSubmitHookFor added in v1.1.0

func (s *Simulator) SetSubmitHookFor(account *url.URL, fn SubmitHookFunc)

func (*Simulator) SignWithNode

func (s *Simulator) SignWithNode(partition string, i int) nodeSigner

func (*Simulator) Step

func (s *Simulator) Step() error

Step executes a single simulator step

func (*Simulator) Submit

func (s *Simulator) Submit(envelope *messaging.Envelope) ([]*protocol.TransactionStatus, error)

func (*Simulator) SubmitTo added in v1.1.0

func (s *Simulator) SubmitTo(partition string, envelope *messaging.Envelope) ([]*protocol.TransactionStatus, error)

func (*Simulator) ViewAll

func (s *Simulator) ViewAll(fn func(batch *database.Batch) error) error

type SnapshotFunc

type SnapshotFunc = func(partition string, network *accumulated.NetworkInit, logger log.Logger) (ioutil2.SectionReader, error)

type SubmitHookFunc

type SubmitHookFunc = func([]messaging.Message) (drop, keepHook bool)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL