Esempio n. 1
0
func (m *CommitEntryMsg) FollowerExecute(state interfaces.IState) error {
	acks := state.GetAcks()
	ack, ok := acks[m.GetHash().Fixed()].(*Ack)
	if !ok || ack == nil {
		state.GetHolding()[m.GetHash().Fixed()] = m
	} else {
		processlist := state.GetProcessList()[ack.ServerIndex]
		for len(processlist) < ack.Height+1 {
			processlist = append(processlist, nil)
		}
		processlist[ack.Height] = m
		state.GetProcessList()[ack.ServerIndex] = processlist
		delete(acks, m.GetHash().Fixed())
	}

	return nil
}
Esempio n. 2
0
func (m *Ack) FollowerExecute(state interfaces.IState) error {
	acks := state.GetAcks()
	holding := state.GetHolding()
	msg := holding[m.MessageHash.Fixed()]
	if msg == nil {
		acks[m.GetHash().Fixed()] = m
	} else {
		processlist := state.GetProcessList()[m.ServerIndex]
		for len(processlist) < m.Height+1 {
			processlist = append(processlist, nil)
		}
		processlist[m.Height] = msg
		state.GetProcessList()[m.ServerIndex] = processlist
		delete(holding, m.MessageHash.Fixed())
	}

	state.UpdateProcessLists()

	return nil
}