Esempio n. 1
0
func prepareHandler(prepare string) {
	// wait for inPrepChan
	//println("################### PREPARE HANDLER", prepare)
	s := strings.Split(prepare, "@")
	prepRN, _ := strconv.Atoi(s[1])     // get the int value for the if
	prepSender, _ := strconv.Atoi(s[3]) // get the int value for the preSend func
	slot, _ := strconv.Atoi(s[2])       // the slot number (instance of paxos)
	lvrn := slotsManager.GetLastVotedRN(slot)
	if prepRN > lvrn {
		lvval := slotsManager.GetLastVotedVal(slot)
		promise := "Promise@" + strconv.Itoa(prepRN) + "@" + strconv.Itoa(lvrn) + "@" + lvval + "@" + strconv.Itoa(slot)
		preSend(promise, prepSender)
	}
}
Esempio n. 2
0
func acceptHandler(accept string) {
	// wait for inAcceptChan
	s := strings.Split(accept, "@")
	rN, _ := strconv.Atoi(s[1])   // get the int value for the if
	val := s[2]                   // the value
	slot, _ := strconv.Atoi(s[3]) // the slot number (instance of paxos)
	lvrn := slotsManager.GetLastVotedRN(slot)
	if rN >= lvrn {
		learn := "Learn@" + s[1] + "@" + s[2] + "@" + s[3]
		//lvrn = rN
		slotsManager.SetLastVotedRN(slot, rN)
		//sendRoundChan <- lvrn
		slotsManager.SetLastVotedVal(slot, val)
		for i := range learnList {
			preSend(learn, learnList[i])
		}
	}

}