// // Callback when a new proposal arrives // func (s *Server) UpdateStateOnNewProposal(proposal protocol.ProposalMsg) { fid := proposal.GetFid() reqId := proposal.GetReqId() txnid := proposal.GetTxnid() // If this host is the one that sends the request to the leader if fid == s.handler.GetFollowerId() { s.state.mutex.Lock() defer s.state.mutex.Unlock() // look up the request handle from the pending list and // move it to the proposed list handle, ok := s.state.pendings[reqId] if ok { delete(s.state.pendings, reqId) s.state.proposals[common.Txnid(txnid)] = handle } } }
// // Update the request upon new proposal. // func (c *Coordinator) updateRequestOnNewProposal(proposal protocol.ProposalMsg) { fid := proposal.GetFid() reqId := proposal.GetReqId() txnid := proposal.GetTxnid() logging.Debugf("Coorindator.updateRequestOnNewProposal(): recieve proposal. Txnid %d, follower id %s, coorindator fid %s", txnid, fid, c.GetFollowerId()) // If this host is the one that sends the request to the leader if fid == c.GetFollowerId() { c.state.mutex.Lock() defer c.state.mutex.Unlock() // look up the request handle from the pending list and // move it to the proposed list handle, ok := c.state.pendings[reqId] if ok { delete(c.state.pendings, reqId) c.state.proposals[common.Txnid(txnid)] = handle } } }