예제 #1
0
func sendLeaveProcess(process view.Process) {
	err := comm.SendRPCRequest(process, "AdminService.Leave", struct{}{}, &struct{}{})
	if err != nil {
		log.Println(err)
		return
	}
}
예제 #2
0
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
}
예제 #3
0
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
}
예제 #4
0
// 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))
}
예제 #5
0
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)
	}
}