Documentation ¶
Index ¶
- func DumpRecording(rd ioutil.SectionReader) error
- func EmptySnapshots(partition string, _ *accumulated.NetworkInit, _ log.Logger) (ioutil2.SectionReader, error)
- func LocalNetwork(name string, bvnCount, nodeCount int, baseIP net.IP, basePort uint64) *accumulated.NetworkInit
- func MemoryDatabase(string, int, log.Logger) keyvalue.Beginner
- func SimpleNetwork(name string, bvnCount, nodeCount int) *accumulated.NetworkInit
- type BlockHookFunc
- type CommitConsensusError
- type CommitHookFunc
- type ListenOptions
- type Node
- type NodeBlockHookFunc
- type OpenDatabaseFunc
- type Partition
- func (p *Partition) Begin(writable bool) *database.Batch
- func (p *Partition) SetBlockHook(fn BlockHookFunc)
- func (p *Partition) SetCommitHook(fn CommitHookFunc)
- func (p *Partition) SetNodeBlockHook(fn NodeBlockHookFunc)
- func (p *Partition) SetObserver(observer database.Observer)
- func (p *Partition) SetSubmitHook(fn SubmitHookFunc)
- func (p *Partition) Submit(envelope *messaging.Envelope, pretend bool) ([]*protocol.TransactionStatus, error)
- func (p *Partition) Update(fn func(*database.Batch) error) error
- func (p *Partition) View(fn func(*database.Batch) error) error
- type RecordingFunc
- type ResponseSubmit
- type Router
- func (r *Router) RequestAPIv2(ctx context.Context, partition, method string, params, result interface{}) error
- func (r *Router) Route(envs ...*messaging.Envelope) (string, error)
- func (r *Router) RouteAccount(account *url.URL) (string, error)
- func (r *Router) SetRoute(account *url.URL, partition string)
- func (r *Router) Submit(ctx context.Context, partition string, envelope *messaging.Envelope, ...) (*ResponseSubmit, error)
- type Simulator
- func (s *Simulator) BlockIndex(partition string) uint64
- func (s *Simulator) BlockIndexFor(account *url.URL) uint64
- func (s *Simulator) ClientV2(part string) *client.Client
- func (s *Simulator) Collect(partition string, file io.WriteSeeker, opts *database.CollectOptions) error
- func (s *Simulator) Database(partition string) database.Beginner
- func (s *Simulator) DatabaseFor(account *url.URL) database.Updater
- func (s *Simulator) EventBus(partition string) *events.Bus
- func (s *Simulator) ListenAndServe(ctx context.Context, opts ListenOptions) (err error)
- func (s *Simulator) NewDirectClientWithHook(hook func(http.Handler) http.Handler) *client.Client
- func (s *Simulator) Partition(partition string) *Partition
- func (s *Simulator) Partitions() []*protocol.PartitionInfo
- func (s *Simulator) Router() *Router
- func (s *Simulator) Services() *simService
- func (s *Simulator) SetBlockHook(partition string, fn BlockHookFunc)
- func (s *Simulator) SetBlockHookFor(account *url.URL, fn BlockHookFunc)
- func (s *Simulator) SetCommitHook(partition string, fn CommitHookFunc)
- func (s *Simulator) SetCommitHookFor(account *url.URL, fn CommitHookFunc)
- func (s *Simulator) SetNodeBlockHook(partition string, fn NodeBlockHookFunc)
- func (s *Simulator) SetNodeBlockHookFor(account *url.URL, fn NodeBlockHookFunc)
- func (s *Simulator) SetRoute(account *url.URL, partition string)
- func (s *Simulator) SetSubmitHook(partition string, fn SubmitHookFunc)
- func (s *Simulator) SetSubmitHookFor(account *url.URL, fn SubmitHookFunc)
- func (s *Simulator) SignWithNode(partition string, i int) nodeSigner
- func (s *Simulator) Step() error
- func (s *Simulator) Submit(envelope *messaging.Envelope) ([]*protocol.TransactionStatus, error)
- func (s *Simulator) SubmitTo(partition string, envelope *messaging.Envelope) ([]*protocol.TransactionStatus, error)
- func (s *Simulator) ViewAll(fn func(batch *database.Batch) error) error
- type SnapshotFunc
- func Genesis(time time.Time) SnapshotFunc
- func GenesisWith(time time.Time, values *core.GlobalValues) SnapshotFunc
- func GenesisWithVersion(time time.Time, version protocol.ExecutorVersion) SnapshotFunc
- func SnapshotFromDirectory(dir string) SnapshotFunc
- func SnapshotMap(snapshots map[string][]byte) SnapshotFunc
- type SubmitHookFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DumpRecording ¶ added in v1.2.0
func DumpRecording(rd ioutil.SectionReader) error
func EmptySnapshots ¶ added in v1.1.0
func EmptySnapshots(partition string, _ *accumulated.NetworkInit, _ log.Logger) (ioutil2.SectionReader, error)
func LocalNetwork ¶ added in v1.1.0
func LocalNetwork(name string, bvnCount, nodeCount int, baseIP net.IP, basePort uint64) *accumulated.NetworkInit
LocalNetwork returns a SimpleNetwork with sequential IPs starting from the base IP with the given base port.
func SimpleNetwork ¶
func SimpleNetwork(name string, bvnCount, nodeCount int) *accumulated.NetworkInit
SimpleNetwork creates a basic network with the given name, number of BVNs, and number of nodes per BVN.
Types ¶
type BlockHookFunc ¶ added in v1.1.0
type CommitConsensusError ¶ added in v1.1.1
type CommitConsensusError [][]byte
func (CommitConsensusError) Error ¶ added in v1.1.1
func (CommitConsensusError) Error() string
type CommitHookFunc ¶ added in v1.1.0
type CommitHookFunc = func(*protocol.PartitionInfo, execute.BlockState)
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) SetObserver ¶ added in v1.1.0
type NodeBlockHookFunc ¶ added in v1.1.1
type OpenDatabaseFunc ¶
func BadgerDatabaseFromDirectory ¶
func BadgerDatabaseFromDirectory(dir string, onErr func(error)) OpenDatabaseFunc
type Partition ¶
type Partition struct { protocol.PartitionInfo // contains filtered or unexported fields }
func (*Partition) Begin ¶ added in v1.1.0
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)
func (*Partition) SetCommitHook ¶ added in v1.1.0
func (p *Partition) SetCommitHook(fn CommitHookFunc)
func (*Partition) SetNodeBlockHook ¶ added in v1.1.1
func (p *Partition) SetNodeBlockHook(fn NodeBlockHookFunc)
func (*Partition) SetObserver ¶ added in v1.1.0
func (*Partition) SetSubmitHook ¶
func (p *Partition) SetSubmitHook(fn SubmitHookFunc)
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) RequestAPIv2 ¶
type Simulator ¶
type Simulator struct { // Deterministic attempts to run the simulator in a fully deterministic, // repeatable way. Deterministic bool // DropDispatchedMessages drops all internally dispatched messages. DropDispatchedMessages bool // IgnoreDeliverResults ignores inconsistencies in the result of DeliverTx // (the results of transactions and signatures). IgnoreDeliverResults bool // IgnoreCommitResults ignores inconsistencies in the result of Commit (the // root hash of the BPT). IgnoreCommitResults bool // Recordings is a function that returns files to write node recordings to. // TODO Make this an option once #3314 is merged. Recordings RecordingFunc // contains filtered or unexported fields }
func New ¶
func New(logger log.Logger, database OpenDatabaseFunc, network *accumulated.NetworkInit, snapshot SnapshotFunc) (*Simulator, error)
func New2 ¶ added in v1.2.0
func New2(logger log.Logger, database OpenDatabaseFunc, network *accumulated.NetworkInit, snapshot SnapshotFunc, recordings RecordingFunc) (*Simulator, error)
New2 is a hack to avoid changing everything - this needs to be handled with options.
func (*Simulator) BlockIndex ¶ added in v1.1.0
func (*Simulator) BlockIndexFor ¶ added in v1.1.0
func (*Simulator) ClientV2 ¶ added in v1.1.0
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) 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
NewDirectClientWithHook creates a direct HTTP client and applies the given hook.
func (*Simulator) Partitions ¶
func (s *Simulator) Partitions() []*protocol.PartitionInfo
func (*Simulator) Services ¶ added in v1.1.0
func (s *Simulator) Services() *simService
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) SetCommitHook ¶ added in v1.1.0
func (s *Simulator) SetCommitHook(partition string, fn CommitHookFunc)
func (*Simulator) SetCommitHookFor ¶ added in v1.1.0
func (s *Simulator) SetCommitHookFor(account *url.URL, fn CommitHookFunc)
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) 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 ¶
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 GenesisWithVersion ¶ added in v1.1.0
func GenesisWithVersion(time time.Time, version protocol.ExecutorVersion) SnapshotFunc
func SnapshotFromDirectory ¶
func SnapshotFromDirectory(dir string) SnapshotFunc
func SnapshotMap ¶ added in v1.1.0
func SnapshotMap(snapshots map[string][]byte) SnapshotFunc