예제 #1
0
// function handling the promise message
func gotPromise(data string) {
	res := strings.Split(data, "@")
	roundnumber, _ := strconv.Atoi(res[1])
	lastVotedRound, _ := strconv.Atoi(res[2])
	lastVotedValue := res[3]
	slot, _ := strconv.Atoi(res[4])
	//processID := res[4]
	slotRN := slotsManager.GetRoundNumber(slot)
	//println("############PROMISE DECRYPTED", strconv.Itoa(roundnumber),strconv.Itoa(slotRN))
	if roundnumber == slotRN {
		//println("$$$$$$$$ADDING TO PROMISE MAP")
		slotsManager.AddToPromiseMap(slot, lastVotedRound, lastVotedValue)
		if lastVotedRound > slotsManager.GetMaxRoundInPromises(slot) {
			slotsManager.SetMaxRoundInPromises(slot, lastVotedRound)
		}
		if slotsManager.GetCptPromise(slot) > len(process)/2 {
			//println("WAITING FOR VALUE ##########")
			waitForValue(slot)
			//println("VALUE DECIDED !!!!!!!!!!!!!!!!!")
			slotsManager.ClearPromiseMap(slot)
			curR := strconv.Itoa(slotRN) //// FIXME : modify for slotsManager !!!!!!!!!!
			sendAll("Accept@" + curR + "@" + slotsManager.GetValueToDecide(slot) + "@" + strconv.Itoa(slot))
		}
	}
}
예제 #2
0
// the round number increase function
func pickNext(slot int) int {
	currentRound := 1 + slotsManager.GetRoundNumber(slot) // TO TEST
	slotsManager.SetRoundNumber(slot, currentRound)
	/*println("*************************************************************0")
	println("Slot ",strconv.Itoa(slot),":")
	println("Round number set :", strconv.Itoa(currentRound), "and get :", strconv.Itoa(slotsManager.GetRoundNumber(slot)))
	println("*************************************************************0")*/
	return currentRound
}