Documentation
¶
Overview ¶
Package node is the Algorand node itself, with functions exposed to the frontend
Index ¶
- type AlgorandFullNode
- func (node *AlgorandFullNode) AbortCatchup(catchpoint string) error
- func (node *AlgorandFullNode) AppendParticipationKeys(partKeyID account.ParticipationID, keys account.StateProofKeys) error
- func (node *AlgorandFullNode) AssembleBlock(round basics.Round) (agreement.ValidatedBlock, error)
- func (node *AlgorandFullNode) BroadcastInternalSignedTxGroup(txgroup []transactions.SignedTxn) (err error)
- func (node *AlgorandFullNode) BroadcastSignedTxGroup(txgroup []transactions.SignedTxn) (err error)
- func (node *AlgorandFullNode) Config() config.Local
- func (node *AlgorandFullNode) GenesisHash() crypto.Digest
- func (node *AlgorandFullNode) GenesisID() string
- func (node *AlgorandFullNode) GetParticipationKey(partKeyID account.ParticipationID) (account.ParticipationRecord, error)
- func (node *AlgorandFullNode) GetPendingTransaction(txID transactions.Txid) (res TxnWithStatus, found bool)
- func (node *AlgorandFullNode) GetPendingTxnsFromPool() ([]transactions.SignedTxn, error)
- func (node *AlgorandFullNode) GetPrioWeight(addr basics.Address) uint64
- func (node *AlgorandFullNode) GetTransaction(addr basics.Address, txID transactions.Txid, minRound basics.Round, ...) (TxnWithStatus, bool)
- func (node *AlgorandFullNode) GetTransactionByID(txid transactions.Txid, rnd basics.Round) (TxnWithStatus, error)
- func (node *AlgorandFullNode) Indexer() (*indexer.Indexer, error)
- func (node *AlgorandFullNode) InstallParticipationKey(partKeyBinary []byte) (account.ParticipationID, error)
- func (node *AlgorandFullNode) IsArchival() bool
- func (node *AlgorandFullNode) IsParticipating() bool
- func (node *AlgorandFullNode) Ledger() *data.Ledger
- func (node *AlgorandFullNode) ListParticipationKeys() (partKeys []account.ParticipationRecord, err error)
- func (node *AlgorandFullNode) ListTxns(addr basics.Address, minRound basics.Round, maxRound basics.Round) ([]TxnWithStatus, error)
- func (node *AlgorandFullNode) ListeningAddress() (string, bool)
- func (node *AlgorandFullNode) MakePrioResponse(challenge string) []byte
- func (node *AlgorandFullNode) NewPrioChallenge() string
- func (node *AlgorandFullNode) OnNewBlock(block bookkeeping.Block, delta ledgercore.StateDelta)
- func (node *AlgorandFullNode) PoolStats() PoolStats
- func (node *AlgorandFullNode) Record(account basics.Address, round basics.Round, ...)
- func (node *AlgorandFullNode) RemoveParticipationKey(partKeyID account.ParticipationID) error
- func (node *AlgorandFullNode) SetCatchpointCatchupMode(catchpointCatchupMode bool) (outCtxCh <-chan context.Context)
- func (node *AlgorandFullNode) Start()
- func (node *AlgorandFullNode) StartCatchup(catchpoint string) error
- func (node *AlgorandFullNode) Status() (s StatusReport, err error)
- func (node *AlgorandFullNode) Stop()
- func (node *AlgorandFullNode) SuggestedFee() basics.MicroNovas
- func (node *AlgorandFullNode) Uint64() uint64
- func (node *AlgorandFullNode) VerifyPrioResponse(challenge string, response []byte) (addr basics.Address, err error)
- func (node *AlgorandFullNode) VotingKeys(votingRound, keysRound basics.Round) []account.ParticipationRecordForRound
- type CatchpointAlreadyInProgressError
- type CatchpointUnableToStartError
- type PoolStats
- type StatusReport
- type TxnWithStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlgorandFullNode ¶
type AlgorandFullNode struct {
// contains filtered or unexported fields
}
AlgorandFullNode specifies and implements a full Algorand node.
func MakeFull ¶
func MakeFull(log logging.Logger, rootDir string, cfg config.Local, phonebookAddresses []string, genesis bookkeeping.Genesis) (*AlgorandFullNode, error)
MakeFull sets up an Algorand full node (i.e., it returns a node that participates in consensus)
func (*AlgorandFullNode) AbortCatchup ¶
func (node *AlgorandFullNode) AbortCatchup(catchpoint string) error
AbortCatchup aborts the given catchpoint this function is intended to be called externally via the REST api interface.
func (*AlgorandFullNode) AppendParticipationKeys ¶
func (node *AlgorandFullNode) AppendParticipationKeys(partKeyID account.ParticipationID, keys account.StateProofKeys) error
AppendParticipationKeys given a participation id, remove the records from the node
func (*AlgorandFullNode) AssembleBlock ¶
func (node *AlgorandFullNode) AssembleBlock(round basics.Round) (agreement.ValidatedBlock, error)
AssembleBlock implements Ledger.AssembleBlock.
func (*AlgorandFullNode) BroadcastInternalSignedTxGroup ¶
func (node *AlgorandFullNode) BroadcastInternalSignedTxGroup(txgroup []transactions.SignedTxn) (err error)
BroadcastInternalSignedTxGroup broadcasts a transaction group that has already been signed. It is originated internally, and in DevMode, it will not advance the round.
func (*AlgorandFullNode) BroadcastSignedTxGroup ¶
func (node *AlgorandFullNode) BroadcastSignedTxGroup(txgroup []transactions.SignedTxn) (err error)
BroadcastSignedTxGroup broadcasts a transaction group that has already been signed.
func (*AlgorandFullNode) Config ¶
func (node *AlgorandFullNode) Config() config.Local
Config returns a copy of the node's Local configuration
func (*AlgorandFullNode) GenesisHash ¶
func (node *AlgorandFullNode) GenesisHash() crypto.Digest
GenesisHash returns the hash of the genesis configuration.
func (*AlgorandFullNode) GenesisID ¶
func (node *AlgorandFullNode) GenesisID() string
GenesisID returns the ID of the genesis node.
func (*AlgorandFullNode) GetParticipationKey ¶
func (node *AlgorandFullNode) GetParticipationKey(partKeyID account.ParticipationID) (account.ParticipationRecord, error)
GetParticipationKey retries the information of a participation id from the node
func (*AlgorandFullNode) GetPendingTransaction ¶
func (node *AlgorandFullNode) GetPendingTransaction(txID transactions.Txid) (res TxnWithStatus, found bool)
GetPendingTransaction looks for the required txID in the recent ledger blocks, in the txpool, and in the txpool's status cache. It returns the SignedTxn (with status information), and a bool to indicate if the transaction was found.
func (*AlgorandFullNode) GetPendingTxnsFromPool ¶
func (node *AlgorandFullNode) GetPendingTxnsFromPool() ([]transactions.SignedTxn, error)
GetPendingTxnsFromPool returns a snapshot of every pending transactions from the node's transaction pool in a slice. Transactions are sorted in decreasing order. If no transactions, returns an empty slice.
func (*AlgorandFullNode) GetPrioWeight ¶
func (node *AlgorandFullNode) GetPrioWeight(addr basics.Address) uint64
GetPrioWeight implements the network.NetPrioScheme interface
func (*AlgorandFullNode) GetTransaction ¶
func (node *AlgorandFullNode) GetTransaction(addr basics.Address, txID transactions.Txid, minRound basics.Round, maxRound basics.Round) (TxnWithStatus, bool)
GetTransaction looks for the required txID within with a specific account within a range of rounds (inclusive) and returns the SignedTxn and true iff it finds the transaction.
func (*AlgorandFullNode) GetTransactionByID ¶
func (node *AlgorandFullNode) GetTransactionByID(txid transactions.Txid, rnd basics.Round) (TxnWithStatus, error)
GetTransactionByID gets transaction by ID this function is intended to be called externally via the REST api interface.
func (*AlgorandFullNode) Indexer ¶
func (node *AlgorandFullNode) Indexer() (*indexer.Indexer, error)
Indexer returns a pointer to nodes indexer
func (*AlgorandFullNode) InstallParticipationKey ¶
func (node *AlgorandFullNode) InstallParticipationKey(partKeyBinary []byte) (account.ParticipationID, error)
InstallParticipationKey Given a participation key binary stream install the participation key.
func (*AlgorandFullNode) IsArchival ¶
func (node *AlgorandFullNode) IsArchival() bool
IsArchival returns true the node is an archival node, false otherwise
func (*AlgorandFullNode) IsParticipating ¶
func (node *AlgorandFullNode) IsParticipating() bool
IsParticipating implements network.NodeInfo
This function is not fully precise. node.ledger and node.accountManager might move relative to each other and there is no synchronization. This is good-enough for current uses of IsParticipating() which is used in networking code to determine if the node should ask for transaction gossip (or skip it to save bandwidth). The current transaction pool size is about 3 rounds. Starting to receive transaction gossip 10 rounds in the future when we might propose or vote on blocks in that future is a little extra buffer but seems reasonable at this time. -- bolson 2022-05-18
func (*AlgorandFullNode) Ledger ¶
func (node *AlgorandFullNode) Ledger() *data.Ledger
Ledger exposes the node's ledger handle to the algod API code
func (*AlgorandFullNode) ListParticipationKeys ¶
func (node *AlgorandFullNode) ListParticipationKeys() (partKeys []account.ParticipationRecord, err error)
ListParticipationKeys returns all participation keys currently installed on the node
func (*AlgorandFullNode) ListTxns ¶
func (node *AlgorandFullNode) ListTxns(addr basics.Address, minRound basics.Round, maxRound basics.Round) ([]TxnWithStatus, error)
ListTxns returns SignedTxns associated with a specific account in a range of Rounds (inclusive). TxnWithStatus returns the round in which a particular transaction appeared, since that information is not part of the SignedTxn itself.
func (*AlgorandFullNode) ListeningAddress ¶
func (node *AlgorandFullNode) ListeningAddress() (string, bool)
ListeningAddress retrieves the node's current listening address, if any. Returns true if currently listening, false otherwise.
func (*AlgorandFullNode) MakePrioResponse ¶
func (node *AlgorandFullNode) MakePrioResponse(challenge string) []byte
MakePrioResponse implements the network.NetPrioScheme interface
func (*AlgorandFullNode) NewPrioChallenge ¶
func (node *AlgorandFullNode) NewPrioChallenge() string
NewPrioChallenge implements the network.NetPrioScheme interface
func (*AlgorandFullNode) OnNewBlock ¶
func (node *AlgorandFullNode) OnNewBlock(block bookkeeping.Block, delta ledgercore.StateDelta)
OnNewBlock implements the BlockListener interface so we're notified after each block is written to the ledger
func (*AlgorandFullNode) PoolStats ¶
func (node *AlgorandFullNode) PoolStats() PoolStats
PoolStats returns a PoolStatus structure reporting stats about the transaction pool
func (*AlgorandFullNode) Record ¶
func (node *AlgorandFullNode) Record(account basics.Address, round basics.Round, participationType account.ParticipationAction)
Record forwards participation record calls to the participation registry.
func (*AlgorandFullNode) RemoveParticipationKey ¶
func (node *AlgorandFullNode) RemoveParticipationKey(partKeyID account.ParticipationID) error
RemoveParticipationKey given a participation id, remove the records from the node
func (*AlgorandFullNode) SetCatchpointCatchupMode ¶
func (node *AlgorandFullNode) SetCatchpointCatchupMode(catchpointCatchupMode bool) (outCtxCh <-chan context.Context)
SetCatchpointCatchupMode change the node's operational mode from catchpoint catchup mode and back, it returns a channel which contains the updated node context. This function need to work asynchronously so that the caller could detect and handle the use case where the node is being shut down while we're switching to/from catchup mode without deadlocking on the shared node mutex.
func (*AlgorandFullNode) Start ¶
func (node *AlgorandFullNode) Start()
Start the node: connect to peers and run the agreement service while obtaining a lock. Doesn't wait for initial sync.
func (*AlgorandFullNode) StartCatchup ¶
func (node *AlgorandFullNode) StartCatchup(catchpoint string) error
StartCatchup starts the catchpoint mode and attempt to get to the provided catchpoint this function is intended to be called externally via the REST api interface.
func (*AlgorandFullNode) Status ¶
func (node *AlgorandFullNode) Status() (s StatusReport, err error)
Status returns a StatusReport structure reporting our status as Active and with our ledger's LastRound
func (*AlgorandFullNode) Stop ¶
func (node *AlgorandFullNode) Stop()
Stop stops running the node. Once a node is closed, it can never start again.
func (*AlgorandFullNode) SuggestedFee ¶
func (node *AlgorandFullNode) SuggestedFee() basics.MicroNovas
SuggestedFee returns the suggested fee per byte recommended to ensure a new transaction is processed in a timely fashion. Caller should set fee to max(MinTxnFee, SuggestedFee() * len(encoded SignedTxn))
func (*AlgorandFullNode) Uint64 ¶
func (node *AlgorandFullNode) Uint64() uint64
Uint64 implements the randomness by calling the crypto library.
func (*AlgorandFullNode) VerifyPrioResponse ¶
func (node *AlgorandFullNode) VerifyPrioResponse(challenge string, response []byte) (addr basics.Address, err error)
VerifyPrioResponse implements the network.NetPrioScheme interface
func (*AlgorandFullNode) VotingKeys ¶
func (node *AlgorandFullNode) VotingKeys(votingRound, keysRound basics.Round) []account.ParticipationRecordForRound
VotingKeys implements the key manager's VotingKeys method, and provides additional validation with the ledger. that allows us to load multiple overlapping keys for the same account, and filter these per-round basis.
type CatchpointAlreadyInProgressError ¶
type CatchpointAlreadyInProgressError struct {
// contains filtered or unexported fields
}
CatchpointAlreadyInProgressError indicates that the requested catchpoint is already running
func MakeCatchpointAlreadyInProgressError ¶
func MakeCatchpointAlreadyInProgressError(catchpoint string) *CatchpointAlreadyInProgressError
MakeCatchpointAlreadyInProgressError creates the error
func (*CatchpointAlreadyInProgressError) Error ¶
func (e *CatchpointAlreadyInProgressError) Error() string
Error satisfies builtin interface `error`
type CatchpointUnableToStartError ¶
type CatchpointUnableToStartError struct {
// contains filtered or unexported fields
}
CatchpointUnableToStartError indicates that the requested catchpoint cannot be started
func MakeCatchpointUnableToStartError ¶
func MakeCatchpointUnableToStartError(catchpointRunning, catchpointRequested string) *CatchpointUnableToStartError
MakeCatchpointUnableToStartError creates the error
func (*CatchpointUnableToStartError) Error ¶
func (e *CatchpointUnableToStartError) Error() string
Error satisfies builtin interface `error`
type StatusReport ¶
type StatusReport struct {
LastRound basics.Round
LastVersion protocol.ConsensusVersion
NextVersion protocol.ConsensusVersion
NextVersionRound basics.Round
NextVersionSupported bool
LastRoundTimestamp time.Time
SynchronizingTime time.Duration
CatchupTime time.Duration
HasSyncedSinceStartup bool
StoppedAtUnsupportedRound bool
LastCatchpoint string // the last catchpoint hit by the node. This would get updated regardless of whether the node is catching up using catchpoints or not.
Catchpoint string // the catchpoint where we're currently catching up to. If the node isn't in fast catchup mode, it will be empty.
CatchpointCatchupTotalAccounts uint64
CatchpointCatchupProcessedAccounts uint64
CatchpointCatchupVerifiedAccounts uint64
CatchpointCatchupTotalBlocks uint64
CatchpointCatchupAcquiredBlocks uint64
}
StatusReport represents the current basic status of the node
func (StatusReport) TimeSinceLastRound ¶
func (status StatusReport) TimeSinceLastRound() time.Duration
TimeSinceLastRound returns the time since the last block was approved (locally), or 0 if no blocks seen
type TxnWithStatus ¶
type TxnWithStatus struct {
Txn transactions.SignedTxn
// Zero indicates no confirmation
ConfirmedRound basics.Round
// PoolError indicates that the transaction was kicked out of this
// node's transaction pool (and specifies why that happened). An
// empty string indicates the transaction wasn't kicked out of this
// node's txpool due to an error.
PoolError string
// ApplyData is the transaction.ApplyData, if committed.
ApplyData transactions.ApplyData
}
TxnWithStatus represents information about a single transaction, in particular, whether it has appeared in some block yet or not, and whether it was kicked out of the txpool due to some error.