func (bs *boltStorage) Snapshot() (raftpb.Snapshot, error) {
	snap := &raftpb.Snapshot{}
	err := bs.db.View(func(tx *bolt.Tx) error {
		_, bites := tx.Bucket(snapshotsBucket).Cursor().Last()

		if bites != nil && len(bites) > 0 {
			return proto.Unmarshal(bites, snap)
		}

		return nil
	})

	return *snap, err
}
// Snapshot returns the most recent snapshot.
// If snapshot is temporarily unavailable, it should return ErrSnapshotTemporarilyUnavailable,
// so raft state machine could know that Storage needs some time to prepare
// snapshot and call Snapshot later.
Snapshot returns the most recent snapshot.
If snapshot is temporarily unavailable, it should return ErrSnapshotTemporarilyUnavailable,
so raft state machine could know that Storage needs some time to prepare
snapshot and call Snapshot later.
// Snapshot returns the most recent snapshot . // If snapshot is temporarily unavailable it should return ErrSnapshotTemporarilyUnavailable // so raft state machine could know that Storage needs some time to prepare // snapshot and call Snapshot later .
func (bs *boltStorage) Snapshot() (raftpb.Snapshot, error) {
	snap := &raftpb.Snapshot{}
	err := bs.db.View(func(tx *bolt.Tx) error {
		_, bites := tx.Bucket(snapshotsBucket).Cursor().Last()
		if bites != nil && len(bites) > 0 {
			return proto.Unmarshal(bites, snap)
		}
		return nil
	})
	return *snap, err
}
func ( bs * boltStorage ) Snapshot ( ) ( raftpb . Snapshot , error ) { snap := & raftpb . Snapshot { } err := bs . db . View ( func ( tx * bolt . Tx ) error { _ , bites := tx . Bucket ( snapshotsBucket ) . Cursor ( ) . Last ( ) if bites != nil && len ( bites ) > 0 { return proto . Unmarshal ( bites , snap ) } return nil } ) return * snap , err }
Snapshot returns the most recent snapshot.
Snapshot returns the most recent snapshot .