Exemple #1
0
// NewHelper constructs the consensus helper object
func NewHelper(mhc peer.MessageHandlerCoordinator) *Helper {
	h := &Helper{
		coordinator: mhc,
		secOn:       viper.GetBool("security.enabled"),
		secHelper:   mhc.GetSecHelper(),
		valid:       true, // Assume our state is consistent until we are told otherwise, actual consensus (pbft) will invalidate this immediately, but noops will not
	}

	h.executor = executor.NewImpl(h, h, mhc)
	return h
}
Exemple #2
0
// NewHelper constructs the consensus helper object
func NewHelper(mhc peer.MessageHandlerCoordinator) *Helper {
	h := &Helper{
		coordinator: mhc,
		secOn:       viper.GetBool("security.enabled"),
		secHelper:   mhc.GetSecHelper(),
	}
	h.sts = statetransfer.NewStateTransferState(h)
	h.sts.Initiate(nil)
	h.sts.RegisterListener(h)
	return h
}
Exemple #3
0
// NewHelper constructs the consensus helper object
func NewHelper(mhc peer.MessageHandlerCoordinator) *Helper {
	h := &Helper{
		coordinator: mhc,
		secOn:       viper.GetBool("security.enabled"),
		secHelper:   mhc.GetSecHelper(),
		valid:       true, // Assume our state is consistent until we are told otherwise, TODO: revisit
	}
	h.sts = statetransfer.NewStateTransferState(mhc)
	h.sts.RegisterListener(h)
	return h
}
Exemple #4
0
// NewHelper constructs the consensus helper object
func NewHelper(mhc peer.MessageHandlerCoordinator) *Helper {
	h := &Helper{
		coordinator: mhc,
		secOn:       viper.GetBool("security.enabled"),
		secHelper:   mhc.GetSecHelper(),
		valid:       true, // Assume our state is consistent until we are told otherwise, TODO: revisit
	}

	h.executor = executor.NewImpl(h, h, mhc)
	h.executor.Start()
	return h
}
Exemple #5
0
func GetEngine(coord peer.MessageHandlerCoordinator) (peer.Engine, error) {
	var err error
	engineOnce.Do(func() {
		engine = new(EngineImpl)
		helper := NewHelper(coord)
		engine.consenter = controller.NewConsenter(helper)
		helper.setConsenter(engine.consenter)
		engine.peerEndpoint, err = coord.GetPeerEndpoint()
		engine.consensusFan = util.NewMessageFan()

		go func() {
			logger.Debug("Starting up message thread for consenter")

			// The channel never closes, so this should never break
			for msg := range engine.consensusFan.GetOutChannel() {
				engine.consenter.RecvMsg(msg.Msg, msg.Sender)
			}
		}()
	})
	return engine, err
}