Help us shape the future of Go! Take the 2026 Go Developer Survey

core

package
v0.0.29 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EvtTxPushProcessed = "tx_push_added"
	EvtNewEpoch        = "new_epoch"
)

Events

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountKeeper

type AccountKeeper interface {
	// Get returns an account by address.
	//  ARGS:
	//  - address: The address of the account
	//  - blockNum: The target block to query (Optional. Default: latest)
	//  CONTRACT: It returns an empty Account if no account is found.
	Get(address identifier.Address, blockNum ...uint64) *state.Account

	// Update sets a new object at the given address.
	//  ARGS:
	//  - address: The address of the account to update
	//  - udp: The updated account object to replace the existing object.
	Update(address identifier.Address, upd *state.Account)
}

AccountKeeper describes an interface for accessing account data

type AnnounceListEntry

type AnnounceListEntry struct {
	Type     int    `json:"type" msgpack:"type"`
	Repo     string `json:"repo" msgpack:"repo"`
	NextTime int64  `json:"nextTime" msgpack:"nextTime"`
}

AnnounceListEntry contains information about a key scheduled for announcement.

type AtomicLogic

type AtomicLogic interface {
	Logic

	// GetDBTx returns the db transaction used by the logic and keepers
	GetDBTx() storagetypes.Tx

	// Commit the state tree, database transaction and other
	// processes that needs to be finalized after a new tree
	// version is saved.
	// NOTE: The operations are not all atomic.
	Commit() error

	// Discard the underlying transaction
	// Panics if called when no active transaction.
	Discard()
}

AtomicLogic is like Logic but allows all operations performed to be atomically committed. The implementer must maintain a tx that all logical operations use and allow the tx to be committed or discarded

type BalanceAccount

type BalanceAccount interface {
	GetBalance() util.String
	SetBalance(bal string)
	Clean(chainHeight uint64)
}

BalanceAccount represents an account that maintains currency balance

type BlockGetter

type BlockGetter interface {
	// GetBlock returns a tendermint block with the given height.
	GetBlock(height int64) *types.Block

	// GetChainHeight returns the current chain height
	GetChainHeight() int64
}

BlockGetter describes a structure for getting blocks

type BlockValidators

type BlockValidators map[util.Bytes32]*Validator

BlockValidators contains validators of a block

type DHTKeeper

type DHTKeeper interface {
	// AddToAnnounceList adds a key that will be announced at a later time.
	// key is the unique object key.
	// repo is the name of the repo where the object exist in.
	// objType is the object type.
	// announceTime is the unix time when the key should be announced.
	AddToAnnounceList(key []byte, repo string, objType int, announceTime int64) error

	// RemoveFromAnnounceList removes a scheduled key announcement
	RemoveFromAnnounceList(key []byte) error

	// IterateAnnounceList iterates over all scheduled announcements, passing
	// each of them to the provided callback function.
	IterateAnnounceList(it func(key []byte, entry *AnnounceListEntry))
}

DHTKeeper describes an interface for accessing and managing DHT state.

type EndingProposals

type EndingProposals struct {
	RepoName   string
	ProposalID string
	EndHeight  uint64
}

EndingProposals describes a proposal ending height

type ExecArgs

type ExecArgs struct {
	Tx             types.BaseTx
	ChainHeight    uint64
	ValidateTx     ValidateTxFunc
	SystemContract []SystemContract
}

type Keepers

type Keepers interface {

	// SysKeeper provides access to system or operation information.
	SysKeeper() SystemKeeper

	// RepoSyncInfoKeeper returns the track list keeper
	RepoSyncInfoKeeper() RepoSyncInfoKeeper

	// AccountKeeper manages and provides access to network accounts
	AccountKeeper() AccountKeeper

	// ValidatorKeeper manages and provides access to validators information
	ValidatorKeeper() ValidatorKeeper

	// RepoKeeper manages and provides access to repository information
	RepoKeeper() RepoKeeper

	// PushKeyKeeper manages and provides access to registered push keys
	PushKeyKeeper() PushKeyKeeper

	// GetTicketManager manages and provides access to ticket information
	GetTicketManager() tickettypes.TicketManager

	// NamespaceKeeper manages and provides access to namespace information
	NamespaceKeeper() NamespaceKeeper

	// DHTKeeper returns the DHT keeper
	DHTKeeper() DHTKeeper
}

Keepers describes modules for accessing the state and storage of various application components

type Logic

type Logic interface {
	Keepers

	// Validator returns the validator logic
	Validator() ValidatorLogic

	// DB returns the application's database
	DB() storagetypes.Engine

	// StateTree manages the app state tree
	StateTree() tree.Tree

	// ApplyGenesisState WriteGenesisState initializes the app state with initial data
	ApplyGenesisState(state json.RawMessage) error

	// SetTicketManager sets the ticket manager
	SetTicketManager(tm tickettypes.TicketManager)

	// SetRemoteServer sets the repository server manager
	SetRemoteServer(m RemoteServer)

	// GetRemoteServer returns the repository server manager
	GetRemoteServer() RemoteServer

	// DrySend checks whether the given sender can execute the transaction
	//
	//  - sender can be an address, identifier.Address or *crypto.PubKey.
	//  - value is the amount to transfer out of the sender account.
	//  - fee is the amount of coins to pay for network fee.
	//  - nonce is the sending account next nonce
	//  - allowNonceGap allows current nonce and next nonce to have a difference > 1
	//  - chainHeight is the block height to query the account from.
	DrySend(sender interface{}, value, fee util.String, nonce uint64, allowNonceGap bool, chainHeight uint64) error

	// ExecTx executes a transaction.
	// chainHeight: The height of the block chain
	ExecTx(args *ExecArgs) abcitypes.ResponseDeliverTx

	// Cfg returns the application config
	Config() *config.AppConfig

	// GetMempoolReactor returns the mempool reactor
	GetMempoolReactor() MempoolReactor

	// SetMempoolReactor sets the mempool reactor
	SetMempoolReactor(mr MempoolReactor)

	// OnEndBlock is called within the ABCI EndBlock method;
	// Do things that need to happen after each block transactions are processed.
	OnEndBlock(block *state.BlockInfo) error

	// ApplyProposals applies proposals ending at the given block.
	ApplyProposals(block *state.BlockInfo) error
}

Logic provides an interface that allows access and modification to the state of the blockchain.

type LogicCommon

type LogicCommon interface{}

LogicCommon describes a common functionalities for all logic providers

type Mempool

type Mempool interface {

	// CheckTx executes a new transaction against the application to determine
	// its validity and whether it should be added to the mempool.
	CheckTx(tx tmtypes.Tx, callback func(*abci.Response), txInfo mempool.TxInfo) error

	// ReapMaxBytesMaxGas reaps transactions from the mempool up to maxBytes
	// bytes total with the condition that the total gasWanted must be less than
	// maxGas.
	// If both maxes are negative, there is no cap on the size of all returned
	// transactions (~ all available transactions).
	ReapMaxBytesMaxGas(maxBytes, maxGas int64) tmtypes.Txs

	// ReapMaxTxs reaps up to max transactions from the mempool.
	// If max is negative, there is no cap on the size of all returned
	// transactions (~ all available transactions).
	ReapMaxTxs(max int) tmtypes.Txs

	// Lock locks the mempool. The consensus must be able to hold lock to safely update.
	Lock()

	// Unlock unlocks the mempool.
	Unlock()

	// Update informs the mempool that the given txs were committed and can be discarded.
	// NOTE: this should be called *after* block is committed by consensus.
	// NOTE: unsafe; Lock/Unlock must be managed by caller
	Update(
		blockHeight int64,
		blockTxs tmtypes.Txs,
		deliverTxResponses []*abci.ResponseDeliverTx,
		newPreFn mempool.PreCheckFunc,
		newPostFn mempool.PostCheckFunc,
	) error

	// FlushAppConn flushes the mempool connection to ensure async reqResCb calls are
	// done. E.g. from CheckTx.
	FlushAppConn() error

	// Flush removes all transactions from the mempool and cache
	Flush()

	// TxsAvailable returns a channel which fires once for every height,
	// and only when transactions are available in the mempool.
	// NOTE: the returned channel may be nil if EnableTxsAvailable was not called.
	TxsAvailable() <-chan struct{}

	// EnableTxsAvailable initializes the TxsAvailable channel, ensuring it will
	// trigger once every height when transactions are available.
	EnableTxsAvailable()

	// Size returns the number of transactions in the mempool.
	Size() int

	// TxsBytes returns the total size of all txs in the mempool.
	TxsBytes() int64

	// InitWAL creates a directory for the WAL file and opens a file itself.
	InitWAL() error

	// CloseWAL closes and discards the underlying WAL file.
	// Any further writes will not be relayed to disk.
	CloseWAL()

	// Register attempts to add a transaction to the pool
	Add(tx types.BaseTx) (bool, error)
}

Mempool describes a transaction pool for ordering transactions that will be added to a future block.

type MempoolReactor

type MempoolReactor interface {
	GetPoolSize() *PoolSizeInfo
	GetTop(n int) []types.BaseTx
	AddTx(tx types.BaseTx) (hash util.HexBytes, err error)
	GetTx(hash string) types.BaseTx
}

MempoolReactor provides access to mempool operations

type NamespaceKeeper

type NamespaceKeeper interface {
	// Get finds a namespace by name.
	//  ARGS:
	//  - name: The name of the namespace to find.
	//  - blockNum: The target block to query (Optional. Default: latest)
	//  CONTRACT: It returns an empty Namespace if no matching namespace is found.
	Get(name string, blockNum ...uint64) *state.Namespace

	// GetTarget looks up the target of a full namespace path
	//  ARGS:
	//  - path: The path to look up.
	//  - blockNum: The target block to query (Optional. Default: latest)
	GetTarget(path string, blockNum ...uint64) (string, error)

	// Update sets a new object at the given name.
	//  ARGS:
	//  - name: The name of the namespace to update
	//  - udp: The updated namespace object to replace the existing object.
	Update(name string, upd *state.Namespace)
}

NamespaceKeeper describes an interface for accessing namespace data

type NodeWork added in v0.0.29

type NodeWork struct {
	Nonce uint64 `json:"nonce"`
	Epoch int64  `json:"epoch"`
}

type PoolGetter

type PoolGetter interface {

	// GetPushPool returns the push pool
	GetPushPool() pushtypes.PushPool

	// GetMempool returns the transaction pool
	GetMempool() Mempool
}

PoolGetter returns various pools

type PoolSizeInfo

type PoolSizeInfo struct {
	TotalTxSize int64 `json:"size"`
	TxCount     int   `json:"count"`
	CacheSize   int   `json:"cache"`
}

PoolSizeInfo describes the transaction byte size an count of the tx pool

type ProposalApplyArgs

type ProposalApplyArgs struct {
	Proposal    state.Proposal
	Repo        *state.Repository
	Keepers     Keepers
	ChainHeight uint64
}

ProposalApplyArgs contains arguments passed to a proposal contract Apply function

type ProposalContract

type ProposalContract interface {
	SystemContract

	// Apply is called when the proposal needs to be applied to the state.
	Apply(args *ProposalApplyArgs) error
}

ProposalContract represents a system contract that is able to execute proposal transactions and apply proposal changes to the world state.

type PushKeyGetter

type PushKeyGetter func(pushKeyID string) (ed25519.PublicKey, error)

PushKeyGetter represents a function used for fetching a push key

type PushKeyKeeper

type PushKeyKeeper interface {

	// Update sets a new value for the given public key id
	//  ARGS:
	//  - pushKeyID: The public key unique ID
	//  - udp: The updated object to replace the existing object.
	Update(pushKeyID string, upd *state.PushKey) error

	// Get finds and returns a push key
	//  ARGS:
	//  - pushKeyID: The unique ID of the public key
	//  - blockNum: The target block to query (Optional. Default: latest)
	//  CONTRACT: It returns an empty Account if no account is found.
	Get(pushKeyID string, blockNum ...uint64) *state.PushKey

	// GetByAddress returns all public keys associated with the given address
	//  ARGS:
	//  - address: The target address
	GetByAddress(address string) (pushKeys []string)

	// Remove removes a push key by id
	//  ARGS:
	//  - pushKeyID: The public key unique ID
	Remove(pushKeyID string) bool
}

PushKeyKeeper describes an interface for accessing push public key information

type RemoteServer

type RemoteServer interface {
	PoolGetter

	// Log returns the logger
	Log() logger.Logger

	// Cfg returns the application config
	Cfg() *config.AppConfig

	// GetRepoState returns the state of the repository at the given path
	// options: Allows the caller to configure how and what state are gathered
	GetRepoState(target remotetypes.LocalRepo, options ...remotetypes.KVOption) (remotetypes.RepoRefsState, error)

	// GetPushKeyGetter returns getter function for fetching a push key
	GetPushKeyGetter() PushKeyGetter

	// GetLogic returns the application logic provider
	GetLogic() Logic

	// GetRepo get a local repository
	GetRepo(name string) (remotetypes.LocalRepo, error)

	// GetPrivateValidatorKey returns the node's private key
	GetPrivateValidatorKey() *ed25519.Key

	// Start starts the server
	Start() error

	// GetRPCHandler returns the RPC handler
	GetRPCHandler() *rpc.Handler

	// Wait can be used by the caller to wait till the server terminates
	Wait()

	// InitRepository creates a local git repository
	InitRepository(name string) error

	// BroadcastMsg broadcast messages to peers
	BroadcastMsg(ch byte, msg []byte)

	// BroadcastNoteAndEndorsement broadcasts repo push note and push endorsement
	BroadcastNoteAndEndorsement(note pushtypes.PushNote) error

	// Announce announces a key on the DHT network.
	// Returns true if object was successfully queued.
	Announce(objType int, repo string, hash []byte, doneCB func(error)) bool

	// GetFetcher returns the fetcher service
	GetFetcher() fetcher.ObjectFetcher

	// CheckNote validates a push note
	CheckNote(note pushtypes.PushNote) error

	// TryScheduleReSync may schedule a local reference for resynchronization if the pushed
	// reference old state does not match the current network state of the reference
	TryScheduleReSync(note pushtypes.PushNote, ref string, fromBeginning bool) error

	// GetDHT returns the dht service
	GetDHT() dht2.DHT

	// Shutdown shuts down the server
	Shutdown(ctx context.Context)

	// Stop implements Reactor
	Stop() error
}

RemoteServer provides functionality for manipulating repositories.

type RepoKeeper

type RepoKeeper interface {
	// Get finds a repository by name.
	//
	// It will populate the proposals in the repo with their correct config
	// source from the version the repo that they where first appeared in.
	//
	// ARGS:
	// name: The name of the repository to find.
	// blockNum: The target block to query (Optional. Default: latest)
	//
	// CONTRACT: It returns an empty Repository if no repo is found.
	Get(name string, blockNum ...uint64) *state.Repository

	// GetNoPopulate fetches a repository by the given name without making additional
	// queries to populate the repo with associated objects.
	//
	// ARGS:
	// name: The name of the repository to find.
	// blockNum: The target block to query (Optional. Default: latest)
	//
	// CONTRACT: It returns an empty Repository if no repo is found.
	GetNoPopulate(name string, blockNum ...uint64) *state.Repository

	// Update sets a new object at the given name.
	//
	// ARGS:
	// name: The name of the repository to update
	// udp: The updated repository object to replace the existing object.
	Update(name string, upd *state.Repository)

	// IndexProposalVote indexes a proposal vote.
	//
	// ARGS:
	// name: The name of the repository
	// propID: The target proposal
	// voterAddr: The address of the voter
	// vote: Indicates the vote choice
	IndexProposalVote(name, propID, voterAddr string, vote int) error

	// GetProposalVote returns the vote choice of the
	// given voter for the given proposal
	//
	// ARGS:
	// name: The name of the repository
	// propID: The target proposal
	// voterAddr: The address of the voter
	GetProposalVote(name, propID, voterAddr string) (vote int, found bool, err error)

	// IndexProposalEnd indexes a proposal by its end height so it can be
	// tracked and finalized at the given height
	//
	// ARGS:
	// name: The name of the repository
	// propID: The target proposal
	// endHeight: The chain height when the proposal will stop accepting votes.
	IndexProposalEnd(name, propID string, endHeight uint64) error

	// GetProposalsEndingAt finds repo proposals ending at the given height
	//
	// ARGS:
	// height: The chain height when the proposal will stop accepting votes.
	GetProposalsEndingAt(height uint64) []*EndingProposals

	// MarkProposalAsClosed makes a proposal as "closed"
	//
	// ARGS:
	// name: The name of the repository
	// propID: The target proposal
	MarkProposalAsClosed(name, propID string) error

	// IsProposalClosed checks whether a proposal has been marked "closed"
	//
	// ARGS:
	// name: The name of the repository
	// propID: The target proposal
	IsProposalClosed(name, propID string) (bool, error)
}

RepoKeeper describes an interface for accessing repository data

type RepoSyncInfoKeeper

type RepoSyncInfoKeeper interface {
	Track(repos string, height ...uint64) error
	Tracked() (res map[string]*TrackedRepo)
	GetTracked(name string) *TrackedRepo
	UnTrack(repos string) error
	UpdateRefLastSyncHeight(repo, ref string, height uint64) error
	GetRefLastSyncHeight(repo, ref string) (uint64, error)
}

RepoSyncInfoKeeper describes an interface for managing tracking and synchronization state of repositories.

type SystemContract

type SystemContract interface {

	// Init initializes the contract
	// logic is the logic manager
	// tx is the transaction to execute.
	// curChainHeight is the current height of the chain
	Init(Keepers, types.BaseTx, uint64) SystemContract

	// CanExec checks whether the given tx type can be executed by the contract.
	CanExec(tx types.TxCode) bool

	// Exec executes the transaction
	Exec() error
}

SystemContract represents a system contract

type SystemKeeper

type SystemKeeper interface {

	// SaveBlockInfo saves a committed block information
	SaveBlockInfo(info *state.BlockInfo) error

	// GetLastBlockInfo returns information about the last committed block
	GetLastBlockInfo() (*state.BlockInfo, error)

	// GetBlockInfo returns block information at a given height
	GetBlockInfo(height int64) (*state.BlockInfo, error)

	// SetHelmRepo sets the governing repository of the network
	SetHelmRepo(name string) error

	// GetHelmRepo gets the governing repository of the network
	GetHelmRepo() (string, error)

	// GetCurrentEpoch returns the current epoch
	GetCurrentEpoch() (int64, error)

	// GetEpochAt returns the epoch of a given height
	GetEpochAt(height int64) int64

	// GetCurrentEpochStartBlock GetEpochStartBlock returns the block info of the first block of an epoch
	GetCurrentEpochStartBlock() (*state.BlockInfo, error)
}

SystemKeeper describes an interface for accessing system data

type TrackedRepo

type TrackedRepo struct {
	UpdatedAt util.UInt64 `json:"updatedAt" msgpack:"updatedAt"`
}

TrackedRepo stores status info about a tracked repository or

type ValidateTxFunc

type ValidateTxFunc func(tx types.BaseTx, i int, logic Logic) error

ValidateTxFunc represents a function for validating a transaction

type Validator

type Validator struct {
	PubKey   util.Bytes32  `json:"publicKey,omitempty" mapstructure:"pubkey"`
	TicketID util.HexBytes `json:"ticketID,omitempty" mapstructure:"ticketID"`
}

Validator represents a validator

type ValidatorKeeper

type ValidatorKeeper interface {

	// GetByHeight gets validators at the given height. If height is <= 0, the
	// validator set of the highest height is returned.
	Get(height int64) (BlockValidators, error)

	// Index adds a set of validators associated to the given height
	Index(height int64, validators []*Validator) error
}

ValidatorKeeper describes an interface for managing validator information

type ValidatorLogic

type ValidatorLogic interface {
	LogicCommon

	// Index indexes the validator set for the given height.
	Index(height int64, valUpdates []abcitypes.ValidatorUpdate) error
}

ValidatorLogic provides functionalities for managing and deriving validators.

Jump to

Keyboard shortcuts

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