Issue Fixed

1.We must change the Do command to be able to append multiple log entries at one time.

Do func simply append a log entry, and try to invoke heartbeat to flush the newest information to all the peers. Also do func will wait for the callback.

Add a commitCenter() routine for leader. Leader will collect all successful response in this center. Also change the heartbeat func to send the response. 
When stepdown, we need to shutdown this routine. 


2.The Command callback need to think for a while, since the command can be committed at different leader than the previous leader who receive this command.

For now, I add a timeout for Do() func. Therefore, if leader has changed, the timeout will happend. But the command may still be commited. We need to think a way to notify the client. [ongardie suggests we can have a seq num for each command, but i have not thought through it.]

3.To vote to a candidate, the candidate lastLog is at least as up-to-date as this server (rather than the committed log index, which you are using for now.

Fixed in requestVote func() and add LastInfo() in log.go

4.Timer has a channel inside a mutex, which may lead to deadlock based on my test. I have change it to a select to test if the timer's channel can receive the signal.

Fix. Use select to detect if the channel is nil.

5.Change the way to start a server
First, init the server
Second, start the server as a leader or a follower.


TODO
1.Use a better way to print debug info
2.Fix the log test and promote test. I have changed some codes, which affect the struct of log entry and how to start a server.
3.Maybe setTimer should not start the timer, but only to change the duration of the timer.