dev

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultFee = std.NewFee(50000, std.MustParseCoin(ugnot.ValueString(1000000)))
View Source
var ErrEmptyState = errors.New("empty state")

Functions

This section is empty.

Types

type Node

type Node struct {
	*node.Node
	// contains filtered or unexported fields
}

Node is not thread safe

func NewDevNode

func NewDevNode(ctx context.Context, cfg *NodeConfig, pkgpaths ...string) (*Node, error)

func (*Node) AddPackagePaths

func (n *Node) AddPackagePaths(paths ...string)

AddPackagePaths to load

func (*Node) Client

func (n *Node) Client() client.Client

func (*Node) Close

func (n *Node) Close() error

func (*Node) ExportCurrentState

func (n *Node) ExportCurrentState(ctx context.Context) ([]gnoland.TxWithMetadata, error)

Export the current state as list of txs

func (*Node) ExportStateAsGenesis

func (n *Node) ExportStateAsGenesis(ctx context.Context) (*bft.GenesisDoc, error)

Export the current state as genesis doc

func (*Node) GetBlockTransactions

func (n *Node) GetBlockTransactions(blockNum uint64) ([]gnoland.TxWithMetadata, error)

GetBlockTransactions returns the transactions contained within the specified block, if any.

func (*Node) GetLatestBlockNumber

func (n *Node) GetLatestBlockNumber() (uint64, error)

GetBlockTransactions returns the transactions contained within the specified block, if any. GetLatestBlockNumber returns the latest block height from the chain.

func (*Node) GetRemoteAddress

func (n *Node) GetRemoteAddress() string

func (*Node) HasPackageLoaded

func (n *Node) HasPackageLoaded(path string) bool

HasPackageLoaded returns true if the specified package has already been loaded. NOTE: This only checks if the package was loaded at the genesis level.

func (*Node) ListPkgs

func (n *Node) ListPkgs() []packages.Package

func (*Node) MoveBy

func (n *Node) MoveBy(ctx context.Context, x int) error

MoveBy adjusts the current state of the node by `x` transactions. `x` can be negative to move backward or positive to move forward, however, index boundaries are respected with a lower limit of 0 and upper limit equaling the total number of states. If a move is successful, node is reloaded.

func (*Node) MoveToNextTX

func (n *Node) MoveToNextTX(ctx context.Context) error

func (*Node) MoveToPreviousTX

func (n *Node) MoveToPreviousTX(ctx context.Context) error

func (*Node) Reload

func (n *Node) Reload(ctx context.Context) error

Reload saves the current state, stops the node if running, starts a new node, and re-apply previously saved state along with packages updated by `UpdatePackages`. If any transaction, including 'addpkg', fails, it will be ignored. Use 'Reset' to completely reset the node's state in case of persistent errors.

func (*Node) ReloadAll

func (n *Node) ReloadAll(ctx context.Context) error

ReloadAll updates all currently known packages and then reloads the node. It's actually a simple combination between `UpdatePackage` and `Reload` method.

func (*Node) Reset

func (n *Node) Reset(ctx context.Context) error

Reset stops the node, if running, and reloads it with a new genesis state, effectively ignoring the current state.

func (*Node) SaveCurrentState

func (n *Node) SaveCurrentState(ctx context.Context) error

Save the current state as initialState

func (*Node) SendTransaction

func (n *Node) SendTransaction(tx *std.Tx) error

SendTransaction executes a broadcast commit send of the specified transaction to the chain

func (*Node) SetPackagePaths

func (n *Node) SetPackagePaths(paths ...string)

type NodeConfig

type NodeConfig struct {
	// Logger is used for logging node activities. It can be set to a custom logger or a noop logger for
	// silent operation.
	Logger *slog.Logger

	// Loader is responsible for loading packages. It abstracts the mechanism for retrieving and managing
	// package data.
	Loader packages.Loader

	// DefaultCreator specifies the default address used for creating packages and transactions.
	DefaultCreator crypto.Address

	// DefaultDeposit is the default amount of coins deposited when creating a package.
	DefaultDeposit std.Coins

	// BalancesList defines the initial balance of accounts in the genesis state.
	BalancesList []gnoland.Balance

	// PackagesModifier allows modifications to be applied to packages during initialization.
	PackagesModifier []QueryPath

	// Emitter is used to emit events for various node operations. It can be set to a noop emitter if no
	// event emission is required.
	Emitter emitter.Emitter

	// InitialTxs contains the transactions that are included in the genesis state.
	InitialTxs []gnoland.TxWithMetadata

	// TMConfig holds the Tendermint configuration settings.
	TMConfig *tmcfg.Config

	// SkipFailingGenesisTxs indicates whether to skip failing transactions during the genesis
	// initialization.
	SkipFailingGenesisTxs bool

	// NoReplay, if set to true, prevents replaying of transactions from the block store during node
	// initialization.
	NoReplay bool

	// MaxGasPerBlock sets the maximum amount of gas that can be used in a single block.
	MaxGasPerBlock int64

	// ChainID is the unique identifier for the blockchain.
	ChainID string

	// ChainDomain specifies the domain name associated with the blockchain network.
	ChainDomain string
}

func DefaultNodeConfig

func DefaultNodeConfig(rootdir, domain string) *NodeConfig

type QueryPath

type QueryPath struct {
	Path    string
	Creator crypto.Address
	Deposit std.Coins
}

func ResolveQueryPath

func ResolveQueryPath(bk *address.Book, query string) (QueryPath, error)

Jump to

Keyboard shortcuts

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