Example #1
0
func Follower(state interfaces.IState) {

	for {
		msg := <-state.FollowerInMsgQueue()
		if state.PrintType(msg.Type()) {
			log.Printf("%20s %s\n", "Follower:", msg.String())
		}
		msg.FollowerExecute(state)
	}

}
Example #2
0
// Execute the leader functions of the given message
func (m *FactoidTransaction) LeaderExecute(state interfaces.IState) error {
	if err := state.GetFactoidState().Validate(1, m.Transaction); err != nil {
		return err
	}
	b, err := m.Transaction.MarshalBinarySig()
	if err != nil {
		return err
	}
	msg, err := NewAck(state, primitives.Sha(b))
	if err != nil {
		return err
	}
	state.NetworkOutMsgQueue() <- msg
	state.FollowerInMsgQueue() <- m   // Send factoid trans to follower
	state.FollowerInMsgQueue() <- msg // Send the Ack to follower
	return nil
}
Example #3
0
// Execute the leader functions of the given message
func (m *RevealEntryMsg) LeaderExecute(state interfaces.IState) error {
	v := m.Validate(state)
	if v <= 0 {
		return fmt.Errorf("Reveal is no longer valid")
	}
	b := m.GetHash()

	msg, err := NewAck(state, b)

	if err != nil {
		return err
	}

	state.NetworkOutMsgQueue() <- msg
	state.FollowerInMsgQueue() <- m   // Send factoid trans to follower
	state.FollowerInMsgQueue() <- msg // Send the Ack to follower

	return nil
}