diff --git a/server.go b/server.go index dc7f498a1b..645a2e4a06 100644 --- a/server.go +++ b/server.go @@ -1017,6 +1017,7 @@ func (s *Server) TakeSnapshot() error { i := 0 for _, peer := range s.peers { peers[i] = peer.clone() + i++ } peers[i] = &Peer{ diff --git a/snapshot_recovery_request.go b/snapshot_recovery_request.go index 2e69123793..0cbef3f184 100644 --- a/snapshot_recovery_request.go +++ b/snapshot_recovery_request.go @@ -35,7 +35,7 @@ func newSnapshotRecoveryRequest(leaderName string, snapshot *Snapshot) *Snapshot // Encodes the SnapshotRecoveryRequest to a buffer. Returns the number of bytes // written and any error that may have occurred. -func (req *SnapshotRecoveryRequest) encode(w io.Writer) (int, error) { +func (req *SnapshotRecoveryRequest) Encode(w io.Writer) (int, error) { protoPeers := make([]*protobuf.ProtoSnapshotRecoveryRequest_ProtoPeer, len(req.Peers)) @@ -63,7 +63,7 @@ func (req *SnapshotRecoveryRequest) encode(w io.Writer) (int, error) { // Decodes the SnapshotRecoveryRequest from a buffer. Returns the number of bytes read and // any error that occurs. -func (req *SnapshotRecoveryRequest) decode(r io.Reader) (int, error) { +func (req *SnapshotRecoveryRequest) Decode(r io.Reader) (int, error) { data, err := ioutil.ReadAll(r) if err != nil { diff --git a/snapshot_recovery_response.go b/snapshot_recovery_response.go index d434d38ef7..7e09f86d01 100644 --- a/snapshot_recovery_response.go +++ b/snapshot_recovery_response.go @@ -31,7 +31,7 @@ func newSnapshotRecoveryResponse(term uint64, success bool, commitIndex uint64) // Encodes the SnapshotRecoveryResponse to a buffer. Returns the number of bytes // written and any error that may have occurred. -func (req *SnapshotRecoveryResponse) encode(w io.Writer) (int, error) { +func (req *SnapshotRecoveryResponse) Encode(w io.Writer) (int, error) { pb := &protobuf.ProtoSnapshotRecoveryResponse{ Term: proto.Uint64(req.Term), Success: proto.Bool(req.Success), @@ -47,7 +47,7 @@ func (req *SnapshotRecoveryResponse) encode(w io.Writer) (int, error) { // Decodes the SnapshotRecoveryResponse from a buffer. Returns the number of bytes read and // any error that occurs. -func (req *SnapshotRecoveryResponse) decode(r io.Reader) (int, error) { +func (req *SnapshotRecoveryResponse) Decode(r io.Reader) (int, error) { data, err := ioutil.ReadAll(r) if err != nil { diff --git a/snapshot_request.go b/snapshot_request.go index 675dcfb802..8166ef4870 100644 --- a/snapshot_request.go +++ b/snapshot_request.go @@ -31,7 +31,7 @@ func newSnapshotRequest(leaderName string, snapshot *Snapshot) *SnapshotRequest // Encodes the SnapshotRequest to a buffer. Returns the number of bytes // written and any error that may have occurred. -func (req *SnapshotRequest) encode(w io.Writer) (int, error) { +func (req *SnapshotRequest) Encode(w io.Writer) (int, error) { pb := &protobuf.ProtoSnapshotRequest{ LeaderName: proto.String(req.LeaderName), LastIndex: proto.Uint64(req.LastIndex), @@ -47,7 +47,7 @@ func (req *SnapshotRequest) encode(w io.Writer) (int, error) { // Decodes the SnapshotRequest from a buffer. Returns the number of bytes read and // any error that occurs. -func (req *SnapshotRequest) decode(r io.Reader) (int, error) { +func (req *SnapshotRequest) Decode(r io.Reader) (int, error) { data, err := ioutil.ReadAll(r) if err != nil { diff --git a/snapshot_response.go b/snapshot_response.go index 9a7ab92d07..a26244b0c4 100644 --- a/snapshot_response.go +++ b/snapshot_response.go @@ -27,7 +27,7 @@ func newSnapshotResponse(success bool) *SnapshotResponse { // Encodes the SnapshotResponse to a buffer. Returns the number of bytes // written and any error that may have occurred. -func (resp *SnapshotResponse) encode(w io.Writer) (int, error) { +func (resp *SnapshotResponse) Encode(w io.Writer) (int, error) { pb := &protobuf.ProtoSnapshotResponse{ Success: proto.Bool(resp.Success), } @@ -41,7 +41,7 @@ func (resp *SnapshotResponse) encode(w io.Writer) (int, error) { // Decodes the SnapshotResponse from a buffer. Returns the number of bytes read and // any error that occurs. -func (resp *SnapshotResponse) decode(r io.Reader) (int, error) { +func (resp *SnapshotResponse) Decode(r io.Reader) (int, error) { data, err := ioutil.ReadAll(r) if err != nil {