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

network

package
v1.36.187 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: BSD-3-Clause Imports: 20 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	MaxValidatorSetStaleness:                    time.Minute,
	TargetGossipSize:                            20 * constants.KiB,
	PushGossipPercentStake:                      .9,
	PushGossipNumValidators:                     100,
	PushGossipNumPeers:                          0,
	PushRegossipNumValidators:                   10,
	PushRegossipNumPeers:                        0,
	PushGossipDiscardedCacheSize:                16384,
	PushGossipMaxRegossipFrequency:              30 * time.Second,
	PushGossipFrequency:                         500 * time.Millisecond,
	PullGossipPollSize:                          1,
	PullGossipFrequency:                         1500 * time.Millisecond,
	PullGossipThrottlingPeriod:                  10 * time.Second,
	PullGossipThrottlingLimit:                   2,
	ExpectedBloomFilterElements:                 8 * 1024,
	ExpectedBloomFilterFalsePositiveProbability: .01,
	MaxBloomFilterFalsePositiveProbability:      .05,
}
View Source
var ErrZapNativeNotYetExecutable = errors.New(
	"zap_native: tx kind executor not yet implemented; rejected at mempool admission " +
		"to prevent zombie txs during Neo ZAP-activation=0 rollout (LP-023 R7V5)",
)

ErrZapNativeNotYetExecutable is returned at mempool admission when a tx is of a zap_native kind whose executor body is still a stub. Wire-decode path is canonical (the buffer is well-formed); execution is gated. See the package comment for the removal checklist.

Wrapped per-kind with the tx-kind name for context; consumers match the bare error via errors.Is.

Functions

This section is empty.

Types

type Config added in v1.1.11

type Config struct {
	// MaxValidatorSetStaleness limits how old of a validator set the network
	// will use for peer sampling and rate limiting.
	MaxValidatorSetStaleness time.Duration `json:"max-validator-set-staleness"`
	// TargetGossipSize is the number of bytes that will be attempted to be
	// sent when pushing transactions and when responded to transaction pull
	// requests.
	TargetGossipSize int `json:"target-gossip-size"`
	// PushGossipPercentStake is the percentage of total stake to push
	// transactions to in the first round of gossip. Nodes with higher stake are
	// preferred over nodes with less stake to minimize the number of messages
	// sent over the p2p network.
	PushGossipPercentStake float64 `json:"push-gossip-percent-stake"`
	// PushGossipNumValidators is the number of validators to push transactions
	// to in the first round of gossip.
	PushGossipNumValidators int `json:"push-gossip-num-validators"`
	// PushGossipNumPeers is the number of peers to push transactions to in the
	// first round of gossip.
	PushGossipNumPeers int `json:"push-gossip-num-peers"`
	// PushRegossipNumValidators is the number of validators to push
	// transactions to after the first round of gossip.
	PushRegossipNumValidators int `json:"push-regossip-num-validators"`
	// PushRegossipNumPeers is the number of peers to push transactions to after
	// the first round of gossip.
	PushRegossipNumPeers int `json:"push-regossip-num-peers"`
	// PushGossipDiscardedCacheSize is the number of txIDs to cache to avoid
	// pushing transactions that were recently dropped from the mempool.
	PushGossipDiscardedCacheSize int `json:"push-gossip-discarded-cache-size"`
	// PushGossipMaxRegossipFrequency is the limit for how frequently a
	// transaction will be push gossiped.
	PushGossipMaxRegossipFrequency time.Duration `json:"push-gossip-max-regossip-frequency"`
	// PushGossipFrequency is how frequently rounds of push gossip are
	// performed.
	PushGossipFrequency time.Duration `json:"push-gossip-frequency"`
	// PullGossipPollSize is the number of validators to sample when performing
	// a round of pull gossip.
	PullGossipPollSize int `json:"pull-gossip-poll-size"`
	// PullGossipFrequency is how frequently rounds of pull gossip are
	// performed.
	PullGossipFrequency time.Duration `json:"pull-gossip-frequency"`
	// PullGossipThrottlingPeriod is how large of a window the throttler should
	// use.
	PullGossipThrottlingPeriod time.Duration `json:"pull-gossip-throttling-period"`
	// PullGossipThrottlingLimit is the number of pull querys that are allowed
	// by a validator in every throttling window.
	PullGossipThrottlingLimit int `json:"pull-gossip-throttling-limit"`
	// ExpectedBloomFilterElements is the number of elements to expect when
	// creating a new bloom filter. The larger this number is, the larger the
	// bloom filter will be.
	ExpectedBloomFilterElements int `json:"expected-bloom-filter-elements"`
	// ExpectedBloomFilterFalsePositiveProbability is the expected probability
	// of a false positive after having inserted ExpectedBloomFilterElements
	// into a bloom filter. The smaller this number is, the larger the bloom
	// filter will be.
	ExpectedBloomFilterFalsePositiveProbability float64 `json:"expected-bloom-filter-false-positive-probability"`
	// MaxBloomFilterFalsePositiveProbability is used to determine when the
	// bloom filter should be refreshed. Once the expected probability of a
	// false positive exceeds this value, the bloom filter will be regenerated.
	// The smaller this number is, the more frequently that the bloom filter
	// will be regenerated.
	MaxBloomFilterFalsePositiveProbability float64 `json:"max-bloom-filter-false-positive-probability"`
}

type LockedTxVerifier

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

func NewLockedTxVerifier

func NewLockedTxVerifier(lock sync.Locker, txVerifier TxVerifier) *LockedTxVerifier

func (*LockedTxVerifier) VerifyTx

func (l *LockedTxVerifier) VerifyTx(tx *txs.Tx) error

type Network

type Network struct {
	*p2p.Network
	// contains filtered or unexported fields
}

func New

func New(
	log log.Logger,
	nodeID ids.NodeID,
	netID ids.ID,
	vdrs validators.State,
	txVerifier TxVerifier,
	mempool mempool.Mempool[*txs.Tx],
	appSender extwarp.Sender,
	stateLock sync.Locker,
	state state.Chain,
	signer warp.Signer,
	registerer metric.Registerer,
	config config.Network,
) (*Network, error)

func (*Network) Gossip added in v1.22.87

func (n *Network) Gossip(ctx context.Context, nodeID ids.NodeID, msgBytes []byte) error

func (*Network) IssueTxFromRPC

func (n *Network) IssueTxFromRPC(tx *txs.Tx) error

func (*Network) PullGossip

func (n *Network) PullGossip(ctx context.Context)

func (*Network) PushGossip

func (n *Network) PushGossip(ctx context.Context)

type TxVerifier

type TxVerifier interface {
	// VerifyTx verifies that the transaction should be issued into the mempool.
	VerifyTx(tx *txs.Tx) error
}

func NewZapNativeAdmissionGate added in v1.28.20

func NewZapNativeAdmissionGate(inner TxVerifier) TxVerifier

NewZapNativeAdmissionGate wraps a TxVerifier with the R7V5 gate. The wrapped verifier is consulted only for txs the gate admits.

USAGE: pass the gate-wrapped TxVerifier into network.New so every inbound tx routes through the gate first. The bare TxVerifier should never be installed into a production Network — the gate must be the outermost layer at every admission boundary.

Jump to

Keyboard shortcuts

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