node

package
v0.0.0-...-76c1feb Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: AGPL-3.0 Imports: 39 Imported by: 0

Documentation

Overview

Package node is the Algorand node itself, with functions exposed to the frontend

Index

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

func (node *AlgorandFullNode) AssembleBlock(round basics.Round, deadline time.Time) (agreement.ValidatedBlock, error)

AssembleBlock implements Ledger.AssembleBlock.

func (*AlgorandFullNode) BroadcastSignedTxGroup

func (node *AlgorandFullNode) BroadcastSignedTxGroup(txgroup []transactions.SignedTxn) 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) 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 withing 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) HasCaughtUp

func (node *AlgorandFullNode) HasCaughtUp() bool

HasCaughtUp (implements NodeContext) returns true if we have completely caught up at least once

func (*AlgorandFullNode) Indexer

func (node *AlgorandFullNode) Indexer() (*indexer.Indexer, error)

Indexer returns a pointer to nodes indexer

func (*AlgorandFullNode) IsArchival

func (node *AlgorandFullNode) IsArchival() bool

IsArchival returns true the node is an archival node, false otherwise

func (*AlgorandFullNode) IsCatchingUp

func (node *AlgorandFullNode) IsCatchingUp() bool

IsCatchingUp (implements NodeContext) returns true if our sync routine is currently running

func (*AlgorandFullNode) IsInitialCatchupComplete

func (node *AlgorandFullNode) IsInitialCatchupComplete() bool

IsInitialCatchupComplete (implements NodeContext) returns true if the initial sync has completed (doesn't mean it succeeded)

func (*AlgorandFullNode) Ledger

func (node *AlgorandFullNode) Ledger() *data.Ledger

Ledger exposes the node's ledger handle to the algod API code

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) 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 asyncronisly so that the caller could detect and handle the usecase where the node is being shut down while we're switching to/from catchup mode without deadlocking on the shared node mutex.

func (*AlgorandFullNode) SetLastLiveRound

func (node *AlgorandFullNode) SetLastLiveRound(round basics.Round)

SetLastLiveRound is called to record observation of a round completion

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.MicroAlgos

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.Participation

VotingKeys implements the key maanger'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

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

Error satisfies builtin interface `error`

type PoolStats

type PoolStats struct {
	NumConfirmed   uint64
	NumOutstanding uint64
	NumExpired     uint64
}

PoolStats represents some statistics about the transaction pool

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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