forked from keybase/kbfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextra_metadata.go
43 lines (37 loc) · 1.13 KB
/
extra_metadata.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2017 Keybase Inc. All rights reserved.
// Use of this source code is governed by a BSD
// license that can be found in the LICENSE file.
package kbfsmd
import (
"fmt"
"github.com/keybase/kbfs/kbfscodec"
)
// ExtraMetadata is a per-version blob of extra metadata which may
// exist outside of the given metadata block, e.g. key bundles for
// post-v2 metadata.
type ExtraMetadata interface {
MetadataVersion() MetadataVer
DeepCopy(kbfscodec.Codec) (ExtraMetadata, error)
MakeSuccessorCopy(kbfscodec.Codec) (ExtraMetadata, error)
}
// DumpExtraMetadata returns a detailed dump of the given
// ExtraMetadata's contents.
func DumpExtraMetadata(
codec kbfscodec.Codec, extra ExtraMetadata) (string, error) {
var s string
switch extra := extra.(type) {
case *ExtraMetadataV3:
serializedWKB, err := codec.Encode(extra.GetWriterKeyBundle())
if err != nil {
return "", err
}
serializedRKB, err := codec.Encode(extra.GetReaderKeyBundle())
if err != nil {
return "", err
}
s = fmt.Sprintf("WKB size: %d\nRKB size: %d\n",
len(serializedWKB), len(serializedRKB))
}
s += DumpConfig().Sdump(extra)
return s, nil
}