func sendLeaveProcess(process view.Process) { err := comm.SendRPCRequest(process, "AdminService.Leave", struct{}{}, &struct{}{}) if err != nil { log.Println(err) return } }
func sendWrite(process view.Process, writeMsg *RegisterMsg, resultChan chan RegisterMsg) { var result RegisterMsg err := comm.SendRPCRequest(process, "RegisterService.Write", writeMsg, &result) if err != nil { resultChan <- RegisterMsg{Err: err} return } result.process = process resultChan <- result }
func sendRead(process view.Process, viewRef view.ViewRef, resultChan chan RegisterMsg) { var result RegisterMsg err := comm.SendRPCRequest(process, "RegisterService.Read", viewRef, &result) if err != nil { resultChan <- RegisterMsg{Err: err} return } result.process = process resultChan <- result }
// GetCurrentView asks processes for the its current view and returns it. func GetCurrentView(processes ...view.Process) (*view.View, error) { for _, loopProcess := range processes { var receivedView *view.View err := comm.SendRPCRequest(loopProcess, "RegisterService.GetCurrentView", struct{}{}, &receivedView) if err != nil { continue } return receivedView, nil } return nil, errors.New(fmt.Sprintf("Failed to get current view from any of the processes: %v", processes)) }
func broadcastAcceptRequest(destinationView *view.View, proposal Proposal, resultChan chan Proposal) { for _, process := range destinationView.GetMembers() { go func(process view.Process) { var result Proposal err := comm.SendRPCRequest(process, "ConsensusRequest.Accept", proposal, &result) if err != nil { resultChan <- Proposal{Err: err} return } resultChan <- result }(process) } }