Documentation
¶
Index ¶
- Constants
- type Builder
- type Config
- type Opt
- func WithExpiryBuffer(buf uint) Opt
- func WithMaxCollectionByteSize(limit uint64) Opt
- func WithMaxCollectionSize(size uint) Opt
- func WithMaxCollectionTotalGas(limit uint64) Opt
- func WithMaxPayerTransactionRate(rate float64) Opt
- func WithRateLimitDryRun(dryRun bool) Opt
- func WithUnlimitedPayers(payers ...flow.Address) Opt
Constants ¶
const ( DefaultExpiryBuffer uint = 15 // 15 blocks for collections to be included DefaultMaxPayerTransactionRate float64 = 0 // no rate limiting )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is the builder for collection block payloads. Upon providing a payload hash, it also memorizes the payload contents.
NOTE: Builder is NOT safe for use with multiple goroutines. Since the HotStuff event loop is the only consumer of this interface and is single threaded, this is OK.
func NewBuilder ¶
func NewBuilder( db *badger.DB, tracer module.Tracer, protoState protocol.State, clusterState clusterstate.State, mainHeaders storage.Headers, clusterHeaders storage.Headers, payloads storage.ClusterPayloads, transactions mempool.Transactions, log zerolog.Logger, epochCounter uint64, opts ...Opt, ) (*Builder, error)
func (*Builder) BuildOn ¶
func (b *Builder) BuildOn(parentID flow.Identifier, setter func(*flow.Header) error, sign func(*flow.Header) error) (*flow.Header, error)
BuildOn generates a new payload that is valid with respect to the parent being built upon, with the view being provided by the consensus algorithm. The builder stores the block and validates it against the cluster state before returning it. The specified parent block must exist in the cluster state.
NOTE: Since the block is stored within Builder, HotStuff MUST propose the block once BuildOn successfully returns.
# Errors This function does not produce any expected errors. However, it will pass through all errors returned by `setter` and `sign`. Callers must be aware of possible error returns from the `setter` and `sign` arguments they provide, and handle them accordingly when handling errors returned from BuildOn.
type Config ¶ added in v0.11.0
type Config struct { // MaxCollectionSize is the maximum size of collections. MaxCollectionSize uint // ExpiryBuffer is how much buffer we add when considering transaction // expiry. If the buffer is set to 10, and a transaction actually expires // in 15 blocks, we consider it expired in 5 (15-10) blocks. This accounts // for the time between the collection being built and being included in // block. ExpiryBuffer uint // DryRunRateLimit will, when enabled, log when a transaction would have // been omitted from a collection due to rate limiting settings. Rate // limiting settings are not actually enforced while dry-run is true. DryRunRateLimit bool // MaxPayerTransactionRate is the maximum number of transactions per payer // per collection. Fractional values greater than 1 are rounded down. // Fractional values 0<k<1 mean that only 1 transaction every ceil(1/k) // collections is allowed. // // A negative value or 0 indicates no rate limiting. MaxPayerTransactionRate float64 // UnlimitedPayer is a set of addresses which are not affected by per-payer // rate limiting. UnlimitedPayers map[flow.Address]struct{} // MaxCollectionByteSize is the maximum byte size of a collection. MaxCollectionByteSize uint64 // MaxCollectionTotalGas is the maximum of total of gas per collection (sum of maxGasLimit over transactions) MaxCollectionTotalGas uint64 }
Config is the configurable options for the collection builder.
func DefaultConfig ¶ added in v0.11.0
func DefaultConfig() Config
type Opt ¶
type Opt func(config *Config)