process

package
v0.0.0-...-5a6e01e Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: GPL-3.0 Imports: 48 Imported by: 0

Documentation

Overview

Package process defines the processes.

Index

Constants

View Source
const (
	ProcessNameConfig               = "config"
	HookNameConfigSuffrage          = "hook_process_suffrage"
	HookNameConfigProposalProcessor = "hook_proposal_processor"
	HookNameConfigGenesisOperations = "hook_genesis_operations"
	HookNameConfigVerbose           = "hook_config_verbose"
)
View Source
const (
	ProcessNameGenerateGenesisBlock = "generate_genesis_block"
	HookNameCheckGenesisBlock       = "check_genesis_block"
)
View Source
const (
	ProcessNameDatabase  = "database"
	ProcessNameBlockdata = "blockdata"
)
View Source
const HookNameAddHinters = "add_hinters"
View Source
const HookNameCheckEmptyBlock = "check_empty_block"
View Source
const HookNameCheckVersion = "check_version"
View Source
const HookNameCleanTempMongodbDatabase = "clean_temp_mongodb_database"
View Source
const HookNameNetworkRateLimit = "network_ratelimit"
View Source
const HookNameNodepool = "nodepool"
View Source
const HookNameSetNetworkHandlers = "set_network_handlers"
View Source
const HookNameSetPolicy = "set_policy"
View Source
const HookNameValidateConfig = "validate_config"
View Source
const ProcessNameConsensusStates = "consensus_states"
View Source
const ProcessNameDiscovery = "discovery"
View Source
const ProcessNameEncoders = "encoders"
View Source
const ProcessNameLocalNode = "local_node"
View Source
const ProcessNameNetwork = "network"
View Source
const ProcessNameProposalProcessor = "proposal_processor"
View Source
const ProcessNameSuffrage = "suffrage"
View Source
const ProcessNameTimeSyncer = "time-syncer"

Variables

View Source
var (
	ContextValueVersion                 util.ContextKey = "version"
	ContextValueConfigSource            util.ContextKey = "config_source"
	ContextValueConfigSourceType        util.ContextKey = "config_source_type"
	ContextValueNetwork                 util.ContextKey = "network"
	ContextValueBlockdata               util.ContextKey = "blockdata"
	ContextValueDatabase                util.ContextKey = "database"
	ContextValueLocalNode               util.ContextKey = "local_node"
	ContextValueNodepool                util.ContextKey = "nodepool"
	ContextValueSuffrage                util.ContextKey = "suffrage"
	ContextValueProposalProcessor       util.ContextKey = "proposal_processor"
	ContextValueConsensusStates         util.ContextKey = "consensus_states"
	ContextValueGenesisBlockForceCreate util.ContextKey = "force_create_genesis_block"
	ContextValueGenesisBlock            util.ContextKey = "genesis_block"
	ContextValueOperationProcessors     util.ContextKey = "operation_processors"
	ContextValuePolicy                  util.ContextKey = "policy"
	ContextValueRateLimitStore          util.ContextKey = "ratelimit-store"
	ContextValueRateLimitHandlerMap     util.ContextKey = "ratelimit-handler-map"
	ContextValueDiscovery               util.ContextKey = "discovery"
	ContextValueDiscoveryConnInfos      util.ContextKey = "discovery-conninfos"
)
View Source
var (
	DefaultGenesisOperationToken         = []byte("genesis-operation-token")
	DefaultHookHandlersGenesisOperations = map[string]HookHandlerGenesisOperations{}
)
View Source
var (
	ProcessorBlockdata pm.Process
	ProcessorDatabase  pm.Process
)
View Source
var DefaultHookHandlersProposalProcessorConfig = map[string]HookHandlerProposalProcessorConfig{
	"default": ProposalProcessorConfigHandlerDefault,
	"error":   ErrorProposalProcessorConfigHandler,
}
View Source
var DefaultHookHandlersSuffrageConfig = map[string]HookHandlerSuffrageConfig{
	"fixed-suffrage": SuffrageConfigHandlerFixedProposer,
	"roundrobin":     SuffrageConfigHandlerRoundrobin,
}
View Source
var HookNameCheckBlockdataPath = "check_blockdata_path"
View Source
var ProcessorConfig pm.Process
View Source
var ProcessorConsensusStates pm.Process
View Source
var ProcessorDiscovery pm.Process
View Source
var ProcessorEncoders pm.Process
View Source
var ProcessorGenerateGenesisBlock pm.Process
View Source
var ProcessorLocalNode pm.Process
View Source
var ProcessorNetwork pm.Process
View Source
var ProcessorProposalProcessor pm.Process
View Source
var ProcessorSuffrage pm.Process
View Source
var ProcessorTimeSyncer pm.Process

Functions

func Config

func Config(ps *pm.Processes) error

func ErrorProposalProcessorConfigHandler

func ErrorProposalProcessorConfigHandler(
	_ context.Context,
	m map[string]interface{},
) (config.ProposalProcessor, error)

func HookAddHinters

func HookAddHinters(types []hint.Type, hinters []hint.Hinter) pm.ProcessFunc

func HookCheckBlockdataPath

func HookCheckBlockdataPath(ctx context.Context) (context.Context, error)

func HookCheckEmptyBlock

func HookCheckEmptyBlock(ctx context.Context) (context.Context, error)

HookCheckEmptyBlock checks whether local has empty block.

func HookCheckGenesisBlock

func HookCheckGenesisBlock(ctx context.Context) (context.Context, error)

func HookCheckVersion

func HookCheckVersion(ctx context.Context) (context.Context, error)

func HookCleanTempMongodbDatabase

func HookCleanTempMongodbDatabase(ctx context.Context) (context.Context, error)

func HookConfigVerbose

func HookConfigVerbose(ctx context.Context) (context.Context, error)

func HookGenesisOperationFunc

func HookGenesisOperationFunc(handlers map[string]HookHandlerGenesisOperations) pm.ProcessFunc

func HookNetworkRateLimit

func HookNetworkRateLimit(ctx context.Context) (context.Context, error)

func HookNodepool

func HookNodepool(ctx context.Context) (context.Context, error)

HookNodepool generates the node list of local node. It does not include the local node itself.

func HookProposalProcessorConfigFunc

func HookProposalProcessorConfigFunc(handlers map[string]HookHandlerProposalProcessorConfig) pm.ProcessFunc

func HookSetNetworkHandlers

func HookSetNetworkHandlers(ctx context.Context) (context.Context, error)

func HookSetPolicy

func HookSetPolicy(ctx context.Context) (context.Context, error)

func HookSuffrageConfigFunc

func HookSuffrageConfigFunc(handlers map[string]HookHandlerSuffrageConfig) pm.ProcessFunc

func HookValidateConfig

func HookValidateConfig(ctx context.Context) (context.Context, error)

func LoadBlockdataContextValue

func LoadBlockdataContextValue(ctx context.Context, l *blockdata.Blockdata) error

func LoadConfigSourceContextValue

func LoadConfigSourceContextValue(ctx context.Context, l *[]byte) error

func LoadConfigSourceTypeContextValue

func LoadConfigSourceTypeContextValue(ctx context.Context, l *string) error

func LoadConsensusStatesContextValue

func LoadConsensusStatesContextValue(ctx context.Context, l *states.States) error

func LoadDatabaseContextValue

func LoadDatabaseContextValue(ctx context.Context, l *storage.Database) error

func LoadDiscoveryConnInfosContextValue

func LoadDiscoveryConnInfosContextValue(ctx context.Context, l *[]network.ConnInfo) error

func LoadDiscoveryContextValue

func LoadDiscoveryContextValue(ctx context.Context, l *discovery.Discovery) error

func LoadGenesisBlockContextValue

func LoadGenesisBlockContextValue(ctx context.Context, l *block.Block) error

func LoadGenesisBlockForceCreateContextValue

func LoadGenesisBlockForceCreateContextValue(ctx context.Context, l *bool) error

func LoadLocalNodeContextValue

func LoadLocalNodeContextValue(ctx context.Context, l *node.Local) error

func LoadNetworkContextValue

func LoadNetworkContextValue(ctx context.Context, l *network.Server) error

func LoadNodeChannel

func LoadNodeChannel(
	connInfo network.ConnInfo,
	encs *encoder.Encoders,
	connectionTimeout time.Duration,
) (network.Channel, error)

func LoadNodepoolContextValue

func LoadNodepoolContextValue(ctx context.Context, l **network.Nodepool) error

func LoadOperationProcessorsContextValue

func LoadOperationProcessorsContextValue(ctx context.Context, l **hint.Hintmap) error

func LoadPolicyContextValue

func LoadPolicyContextValue(ctx context.Context, l **isaac.LocalPolicy) error

func LoadProposalProcessorContextValue

func LoadProposalProcessorContextValue(ctx context.Context, l **prprocessor.Processors) error

func LoadRateLimitHandlerMapContextValue

func LoadRateLimitHandlerMapContextValue(ctx context.Context, l *map[string][]RateLimitRule) error

func LoadRateLimitStoreContextValue

func LoadRateLimitStoreContextValue(ctx context.Context, l *limiter.Store) error

func LoadSuffrageContextValue

func LoadSuffrageContextValue(ctx context.Context, l *base.Suffrage) error

func LoadVersionContextValue

func LoadVersionContextValue(ctx context.Context, l *util.Version) error

func NewErrorProcessorNewFunc

func NewErrorProcessorNewFunc(
	db storage.Database,
	bd blockdata.Blockdata,
	nodepool *network.Nodepool,
	suffrage base.Suffrage,
	oprHintset *hint.Hintmap,
	whenPreparePoints []config.ErrorPoint,
	whenSavePoints []config.ErrorPoint,
) prprocessor.ProcessorNewFunc

func NewNetworkServer

func NewNetworkServer(
	bind string,
	certs []tls.Certificate,
	encs *encoder.Encoders,
	ca cache.Cache,
	connInfo network.ConnInfo,
	nodepool *network.Nodepool,
	httpLog *logging.Logging,
) (network.Server, error)

func ProcessBlockdata

func ProcessBlockdata(ctx context.Context) (context.Context, error)

func ProcessConfig

func ProcessConfig(ctx context.Context) (context.Context, error)

func ProcessConsensusStates

func ProcessConsensusStates(ctx context.Context) (context.Context, error)

func ProcessDatabase

func ProcessDatabase(ctx context.Context) (context.Context, error)

func ProcessDiscovery

func ProcessDiscovery(ctx context.Context) (context.Context, error)

func ProcessEncoders

func ProcessEncoders(ctx context.Context) (context.Context, error)

func ProcessGenerateGenesisBlock

func ProcessGenerateGenesisBlock(ctx context.Context) (context.Context, error)

func ProcessLocalNode

func ProcessLocalNode(ctx context.Context) (context.Context, error)

func ProcessProposalProcessor

func ProcessProposalProcessor(ctx context.Context) (context.Context, error)

func ProcessQuicNetwork

func ProcessQuicNetwork(ctx context.Context) (context.Context, error)

func ProcessSuffrage

func ProcessSuffrage(ctx context.Context) (context.Context, error)

func ProcessTimeSyncer

func ProcessTimeSyncer(ctx context.Context) (context.Context, error)

func ProposalProcessorConfigHandlerDefault

func ProposalProcessorConfigHandlerDefault(context.Context, map[string]interface{}) (config.ProposalProcessor, error)

func SuffrageConfigHandlerFixedProposer

func SuffrageConfigHandlerFixedProposer(
	ctx context.Context,
	m map[string]interface{},
	nodes []base.Address,
) (config.Suffrage, error)

func SuffrageConfigHandlerRoundrobin

func SuffrageConfigHandlerRoundrobin(
	_ context.Context,
	m map[string]interface{},
	nodes []base.Address,
) (config.Suffrage, error)

Types

type ActinfSuffrageElectFunc

type ActinfSuffrageElectFunc func(base.Height, base.Round) (base.ActingSuffrage, error)

type BaseSuffrage

type BaseSuffrage struct {
	sync.RWMutex
	*logging.Logging
	// contains filtered or unexported fields
}

func NewBaseSuffrage

func NewBaseSuffrage(
	name string,
	nodes []base.Address,
	numberOfActing uint,
	electFunc ActinfSuffrageElectFunc,
	cacheSize int,
) (*BaseSuffrage, error)

func (*BaseSuffrage) Acting

func (sf *BaseSuffrage) Acting(height base.Height, round base.Round) (base.ActingSuffrage, error)

func (*BaseSuffrage) CacheSize

func (sf *BaseSuffrage) CacheSize() int

func (*BaseSuffrage) Initialize

func (*BaseSuffrage) Initialize() error

func (*BaseSuffrage) IsActing

func (sf *BaseSuffrage) IsActing(height base.Height, round base.Round, n base.Address) (bool, error)

func (*BaseSuffrage) IsInside

func (sf *BaseSuffrage) IsInside(a base.Address) bool

func (*BaseSuffrage) IsProposer

func (sf *BaseSuffrage) IsProposer(height base.Height, round base.Round, n base.Address) (bool, error)

func (*BaseSuffrage) Name

func (sf *BaseSuffrage) Name() string

func (*BaseSuffrage) Nodes

func (sf *BaseSuffrage) Nodes() []base.Address

func (*BaseSuffrage) NumberOfActing

func (sf *BaseSuffrage) NumberOfActing() uint

func (*BaseSuffrage) Verbose

func (*BaseSuffrage) Verbose() string

type EmptySuffrage

type EmptySuffrage struct{}

func (EmptySuffrage) Acting

func (EmptySuffrage) Acting(height base.Height, round base.Round) (base.ActingSuffrage, error)

func (EmptySuffrage) Initialize

func (EmptySuffrage) Initialize() error

func (EmptySuffrage) IsActing

func (EmptySuffrage) IsInside

func (EmptySuffrage) IsInside(base.Address) bool

func (EmptySuffrage) IsProposer

func (EmptySuffrage) Name

func (EmptySuffrage) Name() string

func (EmptySuffrage) Nodes

func (EmptySuffrage) Nodes() []base.Address

func (EmptySuffrage) NumberOfActing

func (EmptySuffrage) NumberOfActing() uint

func (EmptySuffrage) Verbose

func (sf EmptySuffrage) Verbose() string

type ErrorProposalProcessor

type ErrorProposalProcessor struct {
	*isaac.DefaultProcessor
	// contains filtered or unexported fields
}

func NewErrorProposalProcessor

func NewErrorProposalProcessor(
	d *isaac.DefaultProcessor,
	whenPreparePoints, whenSavePoints []config.ErrorPoint,
) *ErrorProposalProcessor

func (*ErrorProposalProcessor) Prepare

func (pp *ErrorProposalProcessor) Prepare(ctx context.Context) (block.Block, error)

func (*ErrorProposalProcessor) Save

type FixedSuffrage

type FixedSuffrage struct {
	*BaseSuffrage
	// contains filtered or unexported fields
}

func NewFixedSuffrage

func NewFixedSuffrage(
	proposer base.Address,
	nodes []base.Address,
	numberOfActing uint,
	cacheSize int,
) (*FixedSuffrage, error)

func (*FixedSuffrage) Verbose

func (sf *FixedSuffrage) Verbose() string

type HookHandlerGenesisOperations

type HookHandlerGenesisOperations func(context.Context, map[string]interface{}) (operation.Operation, error)

type HookHandlerProposalProcessorConfig

type HookHandlerProposalProcessorConfig func(context.Context, map[string]interface{}) (config.ProposalProcessor, error)

type HookHandlerSuffrageConfig

type HookHandlerSuffrageConfig func(context.Context, map[string]interface{}, []base.Address) (config.Suffrage, error)

type RateLimit

type RateLimit struct {
	*logging.Logging
	// contains filtered or unexported fields
}

func NewRateLimit

func NewRateLimit(
	rules []RateLimitRule,
	defaultRate limiter.Rate,
) *RateLimit

func (*RateLimit) Rate

func (rl *RateLimit) Rate(ip net.IP) limiter.Rate

type RateLimitMiddleware

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

func NewRateLimitMiddleware

func NewRateLimitMiddleware(lt *RateLimit, store limiter.Store) *RateLimitMiddleware

func (*RateLimitMiddleware) Middleware

func (mw *RateLimitMiddleware) Middleware(next http.Handler) http.Handler

type RateLimitRule

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

func NewRateLimiterRule

func NewRateLimiterRule(ipnet *net.IPNet, rate limiter.Rate) RateLimitRule

func (RateLimitRule) Match

func (rr RateLimitRule) Match(ip net.IP) bool

func (RateLimitRule) Rate

func (rr RateLimitRule) Rate() limiter.Rate

type RoundrobinSuffrage

type RoundrobinSuffrage struct {
	*BaseSuffrage
	// contains filtered or unexported fields
}

func NewRoundrobinSuffrage

func NewRoundrobinSuffrage(
	nodes []base.Address,
	numberOfActing uint,
	cacheSize int,
	getManifestFunc func(base.Height) (valuehash.Hash, error),
) (*RoundrobinSuffrage, error)

func (*RoundrobinSuffrage) Verbose

func (sf *RoundrobinSuffrage) Verbose() string

type SettingNetworkHandlers

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

func SettingNetworkHandlersFromContext

func SettingNetworkHandlersFromContext(ctx context.Context) (*SettingNetworkHandlers, error)

func (*SettingNetworkHandlers) Set

func (sn *SettingNetworkHandlers) Set() error

Jump to

Keyboard shortcuts

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