mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
v3rpc: add sha trailer to snapshot
This commit is contained in:
parent
a663828a32
commit
ac2e3e43bf
@ -15,6 +15,7 @@
|
|||||||
package v3rpc
|
package v3rpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/sha256"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/coreos/etcd/etcdserver"
|
"github.com/coreos/etcd/etcdserver"
|
||||||
@ -81,6 +82,8 @@ func (ms *maintenanceServer) Snapshot(sr *pb.SnapshotRequest, srv pb.Maintenance
|
|||||||
pw.Close()
|
pw.Close()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
// send file data
|
||||||
|
h := sha256.New()
|
||||||
br := int64(0)
|
br := int64(0)
|
||||||
buf := make([]byte, 32*1024)
|
buf := make([]byte, 32*1024)
|
||||||
sz := snap.Size()
|
sz := snap.Size()
|
||||||
@ -97,6 +100,14 @@ func (ms *maintenanceServer) Snapshot(sr *pb.SnapshotRequest, srv pb.Maintenance
|
|||||||
if err = srv.Send(resp); err != nil {
|
if err = srv.Send(resp); err != nil {
|
||||||
return togRPCError(err)
|
return togRPCError(err)
|
||||||
}
|
}
|
||||||
|
h.Write(buf[:n])
|
||||||
|
}
|
||||||
|
|
||||||
|
// send sha
|
||||||
|
sha := h.Sum(nil)
|
||||||
|
hresp := &pb.SnapshotResponse{RemainingBytes: 0, Blob: sha}
|
||||||
|
if err := srv.Send(hresp); err != nil {
|
||||||
|
return togRPCError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user