func createRunningPbftWithManager(id uint64, config *viper.Viper, stack innerStack) (*pbftCore, events.Manager) { manager := events.NewManagerImpl() core := newPbftCore(id, loadConfig(), stack, events.NewTimerFactoryImpl(manager)) manager.SetReceiver(core) manager.Start() return core, manager }
func makePBFTNetwork(N int, config *viper.Viper) *pbftNetwork { if config == nil { config = loadConfig() } config.Set("general.N", N) config.Set("general.f", (N-1)/3) endpointFunc := func(id uint64, net *testnet) endpoint { tep := makeTestEndpoint(id, net) pe := &pbftEndpoint{ testEndpoint: tep, manager: events.NewManagerImpl(), } pe.sc = &simpleConsumer{ pe: pe, } pe.pbft = newPbftCore(id, config, pe.sc, events.NewTimerFactoryImpl(pe.manager)) pe.manager.SetReceiver(pe.pbft) pe.manager.Start() return pe } pn := &pbftNetwork{testnet: makeTestnet(N, endpointFunc)} pn.pbftEndpoints = make([]*pbftEndpoint, len(pn.endpoints)) for i, ep := range pn.endpoints { pn.pbftEndpoints[i] = ep.(*pbftEndpoint) pn.pbftEndpoints[i].sc.pbftNet = pn } return pn }
// NewCoordinatorImpl creates a new executor.Coordinator func NewImpl(consumer consensus.ExecutionConsumer, rawExecutor PartialStack, stps statetransfer.PartialStack) consensus.Executor { co := &coordinatorImpl{ rawExecutor: rawExecutor, consumer: consumer, stc: statetransfer.NewCoordinatorImpl(stps), manager: events.NewManagerImpl(), } co.manager.SetReceiver(co) return co }
func (shim *legacyGenericShim) init(id uint64, config *viper.Viper, consumer legacyInnerStack) { shim.pbft = &legacyPbftShim{ closed: make(chan struct{}), manager: events.NewManagerImpl(), consumer: consumer, } shim.pbft.pbftCore = newPbftCore(id, config, consumer, events.NewTimerFactoryImpl(shim.pbft.manager)) shim.pbft.manager.SetReceiver(shim.pbft) logger.Debug("Replica %d Consumer is %p", shim.pbft.id, shim.pbft.consumer) shim.pbft.manager.Start() logger.Debug("Replica %d legacyGenericShim now initialized: %v", id, shim) }
func newObcBatch(id uint64, config *viper.Viper, stack consensus.Stack) *obcBatch { var err error op := &obcBatch{ obcGeneric: obcGeneric{stack: stack}, } op.persistForward.persistor = stack logger.Debugf("Replica %d obtaining startup information", id) op.manager = events.NewManagerImpl() // TODO, this is hacky, eventually rip it out op.manager.SetReceiver(op) etf := events.NewTimerFactoryImpl(op.manager) op.pbft = newPbftCore(id, config, op, etf) op.manager.Start() op.externalEventReceiver.manager = op.manager op.broadcaster = newBroadcaster(id, op.pbft.N, op.pbft.f, stack) op.batchSize = config.GetInt("general.batchsize") op.batchStore = nil op.batchTimeout, err = time.ParseDuration(config.GetString("general.timeout.batch")) if err != nil { panic(fmt.Errorf("Cannot parse batch timeout: %s", err)) } logger.Infof("PBFT Batch size = %d", op.batchSize) logger.Infof("PBFT Batch timeout = %v", op.batchTimeout) if op.batchTimeout >= op.pbft.requestTimeout { op.pbft.requestTimeout = 3 * op.batchTimeout / 2 logger.Warningf("Configured request timeout must be greater than batch timeout, setting to %v", op.pbft.requestTimeout) } if op.pbft.requestTimeout >= op.pbft.nullRequestTimeout && op.pbft.nullRequestTimeout != 0 { op.pbft.nullRequestTimeout = 3 * op.pbft.requestTimeout / 2 logger.Warningf("Configured null request timeout must be greater than request timeout, setting to %v", op.pbft.nullRequestTimeout) } op.incomingChan = make(chan *batchMessage) op.batchTimer = etf.CreateTimer() op.reqStore = newRequestStore() op.deduplicator = newDeduplicator() op.idleChan = make(chan struct{}) close(op.idleChan) // TODO remove eventually return op }