node

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: AGPL-3.0 Imports: 40 Imported by: 0

Documentation

Overview

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

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NetPrioResponseMaxSize

func NetPrioResponseMaxSize() (s int)

MaxSize returns a maximum valid message size for this message type

func NetPrioResponseSignedMaxSize

func NetPrioResponseSignedMaxSize() (s int)

MaxSize returns a maximum valid message size for this message type

Types

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 DepinSDKFollowerNode added in v0.3.2

type DepinSDKFollowerNode struct {
	// contains filtered or unexported fields
}

DepinSDKFollowerNode implements follower mode/ledger delta APIs and disables participation-related methods

func MakeFollower

func MakeFollower(log logging.Logger, rootDir string, cfg config.Local, phonebookAddresses []string, genesis bookkeeping.Genesis) (*DepinSDKFollowerNode, error)

MakeFollower sets up an DepinSDK data node

func (*DepinSDKFollowerNode) AbortCatchup added in v0.3.2

func (node *DepinSDKFollowerNode) AbortCatchup(catchpoint string) error

AbortCatchup aborts the given catchpoint this function is intended to be called externally via the REST api interface.

func (*DepinSDKFollowerNode) AppendParticipationKeys added in v0.3.2

func (node *DepinSDKFollowerNode) AppendParticipationKeys(_ account.ParticipationID, _ account.StateProofKeys) error

AppendParticipationKeys returns an error in follower mode

func (*DepinSDKFollowerNode) AsyncBroadcastSignedTxGroup added in v0.3.2

func (node *DepinSDKFollowerNode) AsyncBroadcastSignedTxGroup(_ []transactions.SignedTxn) (err error)

AsyncBroadcastSignedTxGroup errors in follower mode

func (*DepinSDKFollowerNode) BroadcastInternalSignedTxGroup added in v0.3.2

func (node *DepinSDKFollowerNode) BroadcastInternalSignedTxGroup(_ []transactions.SignedTxn) (err error)

BroadcastInternalSignedTxGroup errors in follower mode

func (*DepinSDKFollowerNode) BroadcastSignedTxGroup added in v0.3.2

func (node *DepinSDKFollowerNode) BroadcastSignedTxGroup(_ []transactions.SignedTxn) (err error)

BroadcastSignedTxGroup errors in follower mode

func (*DepinSDKFollowerNode) Config added in v0.3.2

func (node *DepinSDKFollowerNode) Config() config.Local

Config returns a copy of the node's Local configuration

func (*DepinSDKFollowerNode) GenesisHash added in v0.3.2

func (node *DepinSDKFollowerNode) GenesisHash() crypto.Digest

GenesisHash returns the hash of the genesis configuration.

func (*DepinSDKFollowerNode) GenesisID added in v0.3.2

func (node *DepinSDKFollowerNode) GenesisID() string

GenesisID returns the ID of the genesis node.

func (*DepinSDKFollowerNode) GetBlockTimeStampOffset added in v0.3.2

func (node *DepinSDKFollowerNode) GetBlockTimeStampOffset() (*int64, error)

GetBlockTimeStampOffset gets a timestamp offset. This is only available in dev mode.

func (*DepinSDKFollowerNode) GetParticipationKey added in v0.3.2

GetParticipationKey returns an error in follower mode

func (*DepinSDKFollowerNode) GetPendingTransaction added in v0.3.2

func (node *DepinSDKFollowerNode) GetPendingTransaction(_ transactions.Txid) (res TxnWithStatus, found bool)

GetPendingTransaction no-ops in follower mode

func (*DepinSDKFollowerNode) GetPendingTxnsFromPool added in v0.3.2

func (node *DepinSDKFollowerNode) GetPendingTxnsFromPool() ([]transactions.SignedTxn, error)

GetPendingTxnsFromPool returns an empty array in follower mode.

func (*DepinSDKFollowerNode) GetSyncRound added in v0.3.2

func (node *DepinSDKFollowerNode) GetSyncRound() uint64

GetSyncRound retrieves the sync round, removes cache offset used during SetSyncRound

func (*DepinSDKFollowerNode) InstallParticipationKey added in v0.3.2

func (node *DepinSDKFollowerNode) InstallParticipationKey(_ []byte) (account.ParticipationID, error)

InstallParticipationKey returns an error in follower mode

func (*DepinSDKFollowerNode) Ledger added in v0.3.2

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

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

func (*DepinSDKFollowerNode) ListParticipationKeys added in v0.3.2

func (node *DepinSDKFollowerNode) ListParticipationKeys() (partKeys []account.ParticipationRecord, err error)

ListParticipationKeys returns an empty list in follower mode

func (*DepinSDKFollowerNode) ListeningAddress added in v0.3.2

func (node *DepinSDKFollowerNode) ListeningAddress() (string, bool)

ListeningAddress retrieves the node's current listening address, if any. Returns true if currently listening, false otherwise.

func (*DepinSDKFollowerNode) OnNewBlock added in v0.3.2

func (node *DepinSDKFollowerNode) OnNewBlock(block bookkeeping.Block, _ ledgercore.StateDelta)

OnNewBlock implements the BlockListener interface so we're notified after each block is written to the ledger

func (*DepinSDKFollowerNode) RemoveParticipationKey added in v0.3.2

func (node *DepinSDKFollowerNode) RemoveParticipationKey(_ account.ParticipationID) error

RemoveParticipationKey returns an error in follower mode

func (*DepinSDKFollowerNode) SetBlockTimeStampOffset added in v0.3.2

func (node *DepinSDKFollowerNode) SetBlockTimeStampOffset(offset int64) error

SetBlockTimeStampOffset sets a timestamp offset in the block header. This is only available in dev mode.

func (*DepinSDKFollowerNode) SetCatchpointCatchupMode added in v0.3.2

func (node *DepinSDKFollowerNode) 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 (*DepinSDKFollowerNode) SetSyncRound added in v0.3.2

func (node *DepinSDKFollowerNode) SetSyncRound(rnd uint64) error

SetSyncRound sets the minimum sync round on the catchup service

func (*DepinSDKFollowerNode) Simulate added in v0.3.2

func (node *DepinSDKFollowerNode) Simulate(request simulation.Request) (result simulation.Result, err error)

Simulate speculatively runs a transaction group against the current blockchain state and returns the effects and/or errors that would result.

func (*DepinSDKFollowerNode) Start added in v0.3.2

func (node *DepinSDKFollowerNode) Start() error

Start the node: connect to peers while obtaining a lock. Doesn't wait for initial sync.

func (*DepinSDKFollowerNode) StartCatchup added in v0.3.2

func (node *DepinSDKFollowerNode) 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 (*DepinSDKFollowerNode) Status added in v0.3.2

func (node *DepinSDKFollowerNode) Status() (StatusReport, error)

Status returns a StatusReport structure reporting our status as Active and with our ledger's LastRound

func (*DepinSDKFollowerNode) Stop added in v0.3.2

func (node *DepinSDKFollowerNode) Stop()

Stop stops running the node. Once a node is closed, it can never start again.

func (*DepinSDKFollowerNode) SuggestedFee added in v0.3.2

func (node *DepinSDKFollowerNode) SuggestedFee() basics.MicroAlgos

SuggestedFee no-ops in follower mode

func (*DepinSDKFollowerNode) UnsetSyncRound added in v0.3.2

func (node *DepinSDKFollowerNode) UnsetSyncRound()

UnsetSyncRound removes the sync round constraint on the catchup service

type DepinSDKFullNode added in v0.3.2

type DepinSDKFullNode struct {
	// contains filtered or unexported fields
}

DepinSDKFullNode specifies and implements a full DepinSDK node.

func MakeFull

func MakeFull(log logging.Logger, rootDir string, cfg config.Local, phonebookAddresses []string, genesis bookkeeping.Genesis) (*DepinSDKFullNode, error)

MakeFull sets up an DepinSDK full node (i.e., it returns a node that participates in consensus)

func (*DepinSDKFullNode) AbortCatchup added in v0.3.2

func (node *DepinSDKFullNode) AbortCatchup(catchpoint string) error

AbortCatchup aborts the given catchpoint this function is intended to be called externally via the REST api interface.

func (*DepinSDKFullNode) AppendParticipationKeys added in v0.3.2

func (node *DepinSDKFullNode) AppendParticipationKeys(partKeyID account.ParticipationID, keys account.StateProofKeys) error

AppendParticipationKeys given a participation id, remove the records from the node

func (*DepinSDKFullNode) AssembleBlock added in v0.3.2

func (node *DepinSDKFullNode) AssembleBlock(round basics.Round, addrs []basics.Address) (agreement.UnfinishedBlock, error)

AssembleBlock implements Ledger.AssembleBlock.

func (*DepinSDKFullNode) AsyncBroadcastSignedTxGroup added in v0.3.2

func (node *DepinSDKFullNode) AsyncBroadcastSignedTxGroup(txgroup []transactions.SignedTxn) (err error)

AsyncBroadcastSignedTxGroup feeds a raw transaction group directly to the transaction pool. This method is intended to be used for performance testing and debugging purposes only.

func (*DepinSDKFullNode) BroadcastInternalSignedTxGroup added in v0.3.2

func (node *DepinSDKFullNode) 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 (*DepinSDKFullNode) BroadcastSignedTxGroup added in v0.3.2

func (node *DepinSDKFullNode) BroadcastSignedTxGroup(txgroup []transactions.SignedTxn) (err error)

BroadcastSignedTxGroup broadcasts a transaction group that has already been signed.

func (*DepinSDKFullNode) Capabilities added in v0.3.2

func (node *DepinSDKFullNode) Capabilities() []p2p.Capability

Capabilities returns the node's capabilities for advertising to other nodes.

func (*DepinSDKFullNode) Config added in v0.3.2

func (node *DepinSDKFullNode) Config() config.Local

Config returns a copy of the node's Local configuration

func (*DepinSDKFullNode) GenesisHash added in v0.3.2

func (node *DepinSDKFullNode) GenesisHash() crypto.Digest

GenesisHash returns the hash of the genesis configuration.

func (*DepinSDKFullNode) GenesisID added in v0.3.2

func (node *DepinSDKFullNode) GenesisID() string

GenesisID returns the ID of the genesis node.

func (*DepinSDKFullNode) GetBlockTimeStampOffset added in v0.3.2

func (node *DepinSDKFullNode) GetBlockTimeStampOffset() (*int64, error)

GetBlockTimeStampOffset gets a timestamp offset. This is only available in dev mode.

func (*DepinSDKFullNode) GetParticipationKey added in v0.3.2

func (node *DepinSDKFullNode) GetParticipationKey(partKeyID account.ParticipationID) (account.ParticipationRecord, error)

GetParticipationKey retries the information of a participation id from the node

func (*DepinSDKFullNode) GetPendingTransaction added in v0.3.2

func (node *DepinSDKFullNode) 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 (*DepinSDKFullNode) GetPendingTxnsFromPool added in v0.3.2

func (node *DepinSDKFullNode) 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 (*DepinSDKFullNode) GetPrioWeight added in v0.3.2

func (node *DepinSDKFullNode) GetPrioWeight(addr basics.Address) uint64

GetPrioWeight implements the network.NetPrioScheme interface

func (*DepinSDKFullNode) GetSyncRound added in v0.3.2

func (node *DepinSDKFullNode) GetSyncRound() uint64

GetSyncRound returns 0 (not set) in the base node implementation

func (*DepinSDKFullNode) InstallParticipationKey added in v0.3.2

func (node *DepinSDKFullNode) InstallParticipationKey(partKeyBinary []byte) (account.ParticipationID, error)

InstallParticipationKey Given a participation key binary stream install the participation key.

func (*DepinSDKFullNode) IsParticipating added in v0.3.2

func (node *DepinSDKFullNode) 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 (*DepinSDKFullNode) Ledger added in v0.3.2

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

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

func (*DepinSDKFullNode) ListParticipationKeys added in v0.3.2

func (node *DepinSDKFullNode) ListParticipationKeys() (partKeys []account.ParticipationRecord, err error)

ListParticipationKeys returns all participation keys currently installed on the node

func (*DepinSDKFullNode) ListeningAddress added in v0.3.2

func (node *DepinSDKFullNode) ListeningAddress() (string, bool)

ListeningAddress retrieves the node's current listening address, if any. Returns true if currently listening, false otherwise.

func (*DepinSDKFullNode) MakePrioResponse added in v0.3.2

func (node *DepinSDKFullNode) MakePrioResponse(challenge string) []byte

MakePrioResponse implements the network.NetPrioScheme interface

func (*DepinSDKFullNode) NewPrioChallenge added in v0.3.2

func (node *DepinSDKFullNode) NewPrioChallenge() string

NewPrioChallenge implements the network.NetPrioScheme interface

func (*DepinSDKFullNode) OnNewBlock added in v0.3.2

func (node *DepinSDKFullNode) 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 (*DepinSDKFullNode) Record added in v0.3.2

func (node *DepinSDKFullNode) Record(account basics.Address, round basics.Round, participationType account.ParticipationAction)

Record forwards participation record calls to the participation registry.

func (*DepinSDKFullNode) RemoveParticipationKey added in v0.3.2

func (node *DepinSDKFullNode) RemoveParticipationKey(partKeyID account.ParticipationID) error

RemoveParticipationKey given a participation id, remove the records from the node

func (*DepinSDKFullNode) SetBlockTimeStampOffset added in v0.3.2

func (node *DepinSDKFullNode) SetBlockTimeStampOffset(offset int64) error

SetBlockTimeStampOffset sets a timestamp offset in the block header. This is only available in dev mode.

func (*DepinSDKFullNode) SetCatchpointCatchupMode added in v0.3.2

func (node *DepinSDKFullNode) 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 (*DepinSDKFullNode) SetSyncRound added in v0.3.2

func (node *DepinSDKFullNode) SetSyncRound(_ uint64) error

SetSyncRound no-ops

func (*DepinSDKFullNode) Simulate added in v0.3.2

func (node *DepinSDKFullNode) Simulate(request simulation.Request) (result simulation.Result, err error)

Simulate speculatively runs a transaction group against the current blockchain state and returns the effects and/or errors that would result.

func (*DepinSDKFullNode) Start added in v0.3.2

func (node *DepinSDKFullNode) Start() error

Start the node: connect to peers and run the agreement service while obtaining a lock. Doesn't wait for initial sync.

func (*DepinSDKFullNode) StartCatchup added in v0.3.2

func (node *DepinSDKFullNode) 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 (*DepinSDKFullNode) Status added in v0.3.2

func (node *DepinSDKFullNode) Status() (StatusReport, error)

Status returns a StatusReport structure reporting our status as Active and with our ledger's LastRound

func (*DepinSDKFullNode) Stop added in v0.3.2

func (node *DepinSDKFullNode) Stop()

Stop stops running the node. Once a node is closed, it can never start again.

func (*DepinSDKFullNode) SuggestedFee added in v0.3.2

func (node *DepinSDKFullNode) 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 (*DepinSDKFullNode) Uint64 added in v0.3.2

func (node *DepinSDKFullNode) Uint64() uint64

Uint64 implements the randomness by calling the crypto library.

func (*DepinSDKFullNode) UnsetSyncRound added in v0.3.2

func (node *DepinSDKFullNode) UnsetSyncRound()

UnsetSyncRound no-ops

func (*DepinSDKFullNode) VerifyPrioResponse added in v0.3.2

func (node *DepinSDKFullNode) VerifyPrioResponse(challenge string, response []byte) (addr basics.Address, err error)

VerifyPrioResponse implements the network.NetPrioScheme interface

func (*DepinSDKFullNode) VotingAccountsForRound added in v0.3.2

func (node *DepinSDKFullNode) VotingAccountsForRound(round basics.Round) []basics.Address

VotingAccountsForRound provides a list of addresses that have participation keys valid for the given round. These accounts may not all be eligible to propose, but they are a superset of eligible proposers.

func (*DepinSDKFullNode) VotingKeys added in v0.3.2

func (node *DepinSDKFullNode) 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 StartCatchpointError

type StartCatchpointError struct {
	// contains filtered or unexported fields
}

StartCatchpointError is returned when the catchpoint service cannot start up.

func MakeStartCatchpointError

func MakeStartCatchpointError(catchpointRequested string, err error) *StartCatchpointError

MakeStartCatchpointError creates a StartCatchpointError for a given catchpoint

func (*StartCatchpointError) Error

func (e *StartCatchpointError) Error() string

Error satisfies the 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
	CatchpointCatchupTotalKVs          uint64
	CatchpointCatchupProcessedKVs      uint64
	CatchpointCatchupVerifiedKVs       uint64
	CatchpointCatchupTotalBlocks       uint64
	CatchpointCatchupAcquiredBlocks    uint64
	UpgradePropose                     protocol.ConsensusVersion
	UpgradeApprove                     bool
	UpgradeDelay                       uint64
	NextProtocolVoteBefore             basics.Round
	NextProtocolApprovals              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.

Jump to

Keyboard shortcuts

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