func (r *Replica) EstablishQLease(ql *qlease.Lease) { now := time.Now().UnixNano() ql.LatestTsSent = now ql.PromiseRejects = 0 g := &qleaseproto.Guard{r.Id, now, qlease.GUARD_DURATION_NS} for i := int32(0); i < int32(r.N); i++ { if i == r.Id || !r.Alive[i] { continue } r.SendMsg(i, r.qleaseGuardRPC, g) } }
func (r *Replica) RenewQLease(ql *qlease.Lease, latestAccInst int32) { now := time.Now().UnixNano() ql.PromiseRejects = 0 p := &qleaseproto.Promise{r.Id, ql.PromisedByMeInst, now, ql.Duration, latestAccInst} for i := int32(0); i < int32(r.N); i++ { if i == r.Id || !r.Alive[i] { continue } ql.LatestRepliesReceived[i] += ql.Duration r.SendMsg(i, r.qleasePromiseRPC, p) } ql.LatestTsSent = now // sufficient to extend wait time by the duration of the lease, because // grantees must receive the lease refresh message before the previous lease expires // (otherwise they will dicount the refresh) ql.WriteInQuorumUntil += ql.Duration }