mediatorplugin

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: GPL-3.0, GPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPassword              = "1"
	DefaultInitPrivKey           = "3ouzX3aTwrJM6PaqJrvE9XEWiycKuFgnZcfrW7duMEFu"
	DefaultRequiredParticipation = 33
)

Variables

View Source
var (
	MediatorFlags = []cli.Flag{
		NoProduceUnitFlag,
		StaleProductionFlag,
		ConsecutiveProductionFlag,
		RequiredParticipationFlag,
		NoGroupSignFlag,
		IdledProducingFlag,
		MediatorsFlag,
	}

	NoProduceUnitFlag = cli.BoolFlag{
		Name:  "noProduce",
		Usage: "Disable producing unit when start up node.",
	}
	StaleProductionFlag = cli.BoolFlag{
		Name:  "staleProduce",
		Usage: "Enable unit production(only once), even if the chain is stale.",
	}
	ConsecutiveProductionFlag = cli.BoolFlag{
		Name:  "allowConsecutive",
		Usage: "Enable unit production(only once), even if the last unit was generated by the same mediator.",
	}
	RequiredParticipationFlag = cli.UintFlag{
		Name:  "requiredParticipation",
		Usage: "Percent of mediators (0-99) that must be participating in order to produce units.",
	}
	NoGroupSignFlag = cli.BoolFlag{
		Name:  "noGroupSign",
		Usage: "Disable group-signing in this node.",
	}
	MediatorsFlag = cli.StringSliceFlag{
		Name: "mediators",
		Usage: "the mediator account controlled by this node, may specify multiple times. for example:\n" +
			"{\\\"Address\\\":\\\"P1xx\\\",\\\"Password\\\":\\\"xxx\\\",\\\"InitPrivKey\\\":\\\"xxx\\\"," +
			"\\\"InitPubKey\\\":\\\"xxx\\\"}",
	}
	IdledProducingFlag = cli.BoolFlag{
		Name:  "idledProducing",
		Usage: "Enable producing unit, even if we have no pending transactions.",
	}
)
View Source
var DefaultConfig = Config{
	EnableProducing:             true,
	EnableStaleProduction:       false,
	EnableConsecutiveProduction: false,
	RequiredParticipation:       DefaultRequiredParticipation,
	EnableGroupSigning:          true,
	EnableIdledProduction:       true,
	Mediators: []*MediatorConf{
		DefaultMediatorConf(),
	},
}

mediator plugin default config

Functions

func RegisterMediatorPluginService

func RegisterMediatorPluginService(stack *node.Node, cfg *Config)

匿名函数的好处之一:能在匿名函数内部直接使用本函数之外的变量; 函数使用外部变量的特性称之为闭包; 例如,以下匿名方法就直接使用cfg变量

func SetMediatorConfig

func SetMediatorConfig(ctx *cli.Context, cfg *Config)

Types

type Config

type Config struct {
	// the set of mediator accounts controlled by this node
	Mediators []*MediatorConf

	// Percent of mediators (0-99) that must be participating in order to produce uints
	RequiredParticipation uint32

	// 主程序启动时,是否立即开启unit生产
	EnableProducing bool

	// Enable Unit production(only once), even if the chain is stale. 运行本节点开始生产unit,即使数据不是最新的
	EnableStaleProduction bool

	// Enable Unit production(only once), even if the last unit was generated by the same mediator.
	// 允许本节点的mediator可以连续生产unit
	EnableConsecutiveProduction bool

	// 标记本节点是否开启群签名的功能
	EnableGroupSigning bool

	// 标记本节点是否生产无交易的区块
	EnableIdledProduction bool
}

config data for mediator plugin

func MakeConfig

func MakeConfig() Config

type GroupSigEvent

type GroupSigEvent struct {
	UnitHash common.Hash
	GroupSig []byte
}

func (*GroupSigEvent) Hash added in v1.0.4

func (e *GroupSigEvent) Hash() common.Hash

type InitDKSResult

type InitDKSResult struct {
	PrivateKey string `json:"private_key"` // 初始群签名私钥
	PublicKey  string `json:"public_key"`  // 初始群签名公钥
}

初始群签名公私钥

type MediatorAccount

type MediatorAccount struct {
	Address     common.Address
	Password    string
	InitPrivKey kyber.Scalar
	InitPubKey  kyber.Point
}

type MediatorConf

type MediatorConf struct {
	Address     string //`json:"account" toml:"account"`
	Password    string //`json:"password" toml:"password"`
	InitPrivKey string //`json:"initPrivKey" toml:"initPrivKey"`
	InitPubKey  string //`json:"initPubKey" toml:"initPubKey"`
}

func DefaultMediatorConf

func DefaultMediatorConf() *MediatorConf

type MediatorPlugin

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

func NewMediatorPlugin

func NewMediatorPlugin(cfg *Config, ptn PalletOne, dag iDag) (*MediatorPlugin, error)

func (*MediatorPlugin) APIs

func (mp *MediatorPlugin) APIs() []rpc.API

func (*MediatorPlugin) AddToDealBuf added in v1.0.1

func (mp *MediatorPlugin) AddToDealBuf(dealEvent *VSSDealEvent)

func (*MediatorPlugin) AddToResponseBuf

func (mp *MediatorPlugin) AddToResponseBuf(respEvent *VSSResponseEvent)

func (*MediatorPlugin) AddToTBLSRecoverBuf

func (mp *MediatorPlugin) AddToTBLSRecoverBuf(event *SigShareEvent, header *modules.Header)

收集签名分片

func (*MediatorPlugin) AddToTBLSSignBufs

func (mp *MediatorPlugin) AddToTBLSSignBufs(newHash common.Hash)

func (*MediatorPlugin) ClearGroupSignBufs added in v1.0.6

func (mp *MediatorPlugin) ClearGroupSignBufs(stableUnit *modules.Unit)

func (*MediatorPlugin) GetLocalActiveMediators

func (mp *MediatorPlugin) GetLocalActiveMediators() []common.Address

func (*MediatorPlugin) GetLocalPrecedingMediators

func (mp *MediatorPlugin) GetLocalPrecedingMediators() []common.Address

func (*MediatorPlugin) IsLocalMediator added in v1.0.4

func (mp *MediatorPlugin) IsLocalMediator(add common.Address) bool

func (*MediatorPlugin) LocalHaveActiveMediator

func (mp *MediatorPlugin) LocalHaveActiveMediator() bool

func (*MediatorPlugin) LocalHavePrecedingMediator

func (mp *MediatorPlugin) LocalHavePrecedingMediator() bool

func (*MediatorPlugin) LocalMediators

func (mp *MediatorPlugin) LocalMediators() []common.Address

func (*MediatorPlugin) Protocols

func (mp *MediatorPlugin) Protocols() []p2p.Protocol

func (*MediatorPlugin) Start

func (mp *MediatorPlugin) Start(server *p2p.Server) error

func (*MediatorPlugin) Stop

func (mp *MediatorPlugin) Stop() error

func (*MediatorPlugin) SubscribeGroupSigEvent

func (mp *MediatorPlugin) SubscribeGroupSigEvent(ch chan<- GroupSigEvent) event.Subscription

func (*MediatorPlugin) SubscribeNewProducedUnitEvent

func (mp *MediatorPlugin) SubscribeNewProducedUnitEvent(ch chan<- NewProducedUnitEvent) event.Subscription

func (*MediatorPlugin) SubscribeSigShareEvent

func (mp *MediatorPlugin) SubscribeSigShareEvent(ch chan<- SigShareEvent) event.Subscription

func (*MediatorPlugin) SubscribeVSSDealEvent

func (mp *MediatorPlugin) SubscribeVSSDealEvent(ch chan<- VSSDealEvent) event.Subscription

func (*MediatorPlugin) SubscribeVSSResponseEvent

func (mp *MediatorPlugin) SubscribeVSSResponseEvent(ch chan<- VSSResponseEvent) event.Subscription

func (*MediatorPlugin) UpdateMediatorsDKG

func (mp *MediatorPlugin) UpdateMediatorsDKG(isRenew bool)

type NewProducedUnitEvent

type NewProducedUnitEvent struct {
	Unit *modules.Unit
}

NewUnitEvent is posted when a unit has been produced.

type PalletOne

type PalletOne interface {
	GetKeyStore() *keystore.KeyStore
	TxPool() txspool.ITxPool
	ContractProcessor() *jury.Processor
}

PalletOne wraps all methods required for producing unit.

type PrivateMediatorAPI

type PrivateMediatorAPI struct {
	*MediatorPlugin
}

func NewPrivateMediatorAPI

func NewPrivateMediatorAPI(mp *MediatorPlugin) *PrivateMediatorAPI

func (*PrivateMediatorAPI) StartProduce

func (a *PrivateMediatorAPI) StartProduce() bool

func (*PrivateMediatorAPI) StopProduce

func (a *PrivateMediatorAPI) StopProduce() bool

type ProductionCondition

type ProductionCondition uint8

unit生产的状态类型

const (
	Produced ProductionCondition = iota // 正常生产unit
	NotSynced
	NotMyTurn
	NotTimeYet
	NotUnlocked
	LowParticipation
	Lag
	Consecutive
	NoTransaction
	ExceptionProducing
)

unit生产的状态枚举

type PublicMediatorAPI

type PublicMediatorAPI struct {
	*MediatorPlugin
}

func NewPublicMediatorAPI

func NewPublicMediatorAPI(mp *MediatorPlugin) *PublicMediatorAPI

func (*PublicMediatorAPI) DumpInitDKS

func (a *PublicMediatorAPI) DumpInitDKS() (res InitDKSResult)

type SigShareEvent

type SigShareEvent struct {
	UnitHash common.Hash
	SigShare []byte
}

func (*SigShareEvent) Hash added in v1.0.4

func (e *SigShareEvent) Hash() common.Hash

type VSSDealEvent

type VSSDealEvent struct {
	DstIndex uint32
	Deal     *dkg.Deal
	Deadline uint64 // 被广播的截止日期
}

func (*VSSDealEvent) Hash added in v1.0.4

func (e *VSSDealEvent) Hash() common.Hash

type VSSResponseEvent

type VSSResponseEvent struct {
	Resp     *dkg.Response
	Deadline uint64 // 被广播的截止日期
}

func (*VSSResponseEvent) Hash added in v1.0.4

func (e *VSSResponseEvent) Hash() common.Hash

Jump to

Keyboard shortcuts

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