simulator

package
v1.0.0-rc3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2022 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MemoryDatabase

func MemoryDatabase(_ string, _ int, logger log.Logger) database.Beginner

func SimpleNetwork

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

Types

type Node

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

func (*Node) Begin

func (n *Node) Begin(writable bool) *database.Batch

func (*Node) Update

func (n *Node) Update(fn func(*database.Batch) error) error

func (*Node) View

func (n *Node) View(fn func(*database.Batch) error) error

type OpenDatabaseFunc

type OpenDatabaseFunc func(partition string, node int, logger log.Logger) database.Beginner

func BadgerDatabaseFromDirectory

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

type Partition

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

func (*Partition) SetSubmitHook

func (p *Partition) SetSubmitHook(fn SubmitHookFunc)

func (*Partition) Submit

func (p *Partition) Submit(delivery *chain.Delivery, 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 Router

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

func (*Router) RequestAPIv2

func (r *Router) RequestAPIv2(ctx context.Context, partition, method string, params, result interface{}) error

func (*Router) Route

func (r *Router) Route(envs ...*protocol.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)

func (*Router) Submit

func (r *Router) Submit(ctx context.Context, partition string, envelope *protocol.Envelope, pretend, async bool) (*routing.ResponseSubmit, error)

type Simulator

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

func New

func New(logger log.Logger, database OpenDatabaseFunc, network *accumulated.NetworkInit, snapshot SnapshotFunc) (*Simulator, error)

func (*Simulator) Database

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

func (*Simulator) DatabaseFor

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

func (*Simulator) ListenAndServe

func (s *Simulator) ListenAndServe(hook func(*Simulator, http.Handler) http.Handler) error

func (*Simulator) Partitions

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

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) Step

func (s *Simulator) Step() error

Step executes a single simulator step

func (*Simulator) Submit

func (s *Simulator) Submit(delivery *chain.Delivery) (*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)

func Genesis

func Genesis(time time.Time) SnapshotFunc

func GenesisWith

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

func SnapshotFromDirectory

func SnapshotFromDirectory(dir string) SnapshotFunc

type SubmitHookFunc

type SubmitHookFunc func(*chain.Delivery) (dropTx, keepHook bool)

Jump to

Keyboard shortcuts

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