src/server/pkg/hashtree/db.go
func (h *dbHashTree) Serialize(_w io.Writer) error {
	w := pbutil.NewWriter(_w)
	return h.View(func(tx *bolt.Tx) error {
		for _, bucket := range buckets {
			b := tx.Bucket(b(bucket))
			if _, err := w.Write(
				&BucketHeader{
					Bucket: bucket,
				}); err != nil {
				return err
			}
			if err := b.ForEach(func(k, v []byte) error {
				if _, err := w.WriteBytes(k); err != nil {
					return err
				}
				_, err := w.WriteBytes(v)
				return err
			}); err != nil {
				return err
			}
			if _, err := w.WriteBytes(SentinelByte); err != nil {
				return err
			}
		}
		return nil
	})
}
func (h *dbHashTree) Serialize(_w io.Writer) error {
	w := pbutil.NewWriter(_w)
	return h.View(func(tx *bolt.Tx) error {
		for _, bucket := range buckets {
			b := tx.Bucket(b(bucket))
			if _, err := w.Write(
				&BucketHeader{
					Bucket: bucket,
				}); err != nil {
				return err
			}
			if err := b.ForEach(func(k, v []byte) error {
				if _, err := w.WriteBytes(k); err != nil {
					return err
				}
				_, err := w.WriteBytes(v)
				return err
			}); err != nil {
				return err
			}
			if _, err := w.WriteBytes(SentinelByte); err != nil {
				return err
			}
		}
		return nil
	})
}
// Serialize serializes a binary version of the hashtree.