Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | remove deprecated code; other minor cleanup |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
715d5551f2902de61aadc0d120e0cd6b |
User & Date: | dnc 2020-01-04 16:13:48 |
Context
2020-01-06
| ||
21:04 | cmd/hancock: update generated documentation check-in: 86031540c6 user: dnc tags: trunk | |
2020-01-04
| ||
16:13 | remove deprecated code; other minor cleanup check-in: 715d5551f2 user: dnc tags: trunk | |
16:12 | cmd/hancock: client of http testimony store server side is implemented by hancockd check-in: ceb5b81ccf user: dnc tags: trunk | |
Changes
Changes to model/index.go.
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
..
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
// // Provides a consistent naming convention for index files. Multiple // commands may create and inspect indexes, so we define the common // conventions in this package. package model import ( "encoding/hex" "errors" "fmt" "log" "golang.org/x/crypto/ssh" ) // We use Keys to store/lookup content. A Key is really a special // case of Content, so each Key has its own CID. We define a KID type // so that our source code can be explicit and avoid confusion when // working with Keys. type KID CID ................................................................................ this.kid = &id return this.kid } func (this *TestimonyKey) Split() []string { return []string{this.Content.String(), this.Authority.String()} } // deprecated, use TestimonyKey.Split func IndexKey(source CID, authority interface{}) (key []string, err error) { var public ssh.PublicKey switch pub := authority.(type) { case Authority: // use hex of ssh encoding of public key public, _, _, _, err = ssh.ParseAuthorizedKey([]byte(pub)) if err != nil { return } case ssh.PublicKey: public = pub default: return nil, fmt.Errorf("unexpected authority (%T %#v) not a public key", authority, authority) } return []string{ source.String(), hex.EncodeToString(public.Marshal()), }, nil } |
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
..
67
68
69
70
71
72
73
|
//
// Provides a consistent naming convention for index files. Multiple
// commands may create and inspect indexes, so we define the common
// conventions in this package.
package model
import (
"errors"
"log"
)
// We use Keys to store/lookup content. A Key is really a special
// case of Content, so each Key has its own CID. We define a KID type
// so that our source code can be explicit and avoid confusion when
// working with Keys.
type KID CID
................................................................................
this.kid = &id
return this.kid
}
func (this *TestimonyKey) Split() []string {
return []string{this.Content.String(), this.Authority.String()}
}
|
Changes to model/testimony.go.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
} func (this Authority) String() string { return string(this) } // Type Testimony, when produced by a trusted authority, allows a // verifier to authenticate a source file. type Testimony struct { // The signer's public key. Authority Authority `json:"authority"` // The data or source file which is the object of attestation. Content CID `json:"content,omitempty"` // The encoded bytes that were signed. May be decoded into a manifest. |
> |
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
} func (this Authority) String() string { return string(this) } // Type Testimony, when produced by a trusted authority, allows a // verifier to authenticate a source file. type Testimony struct { // The signer's public key. Authority Authority `json:"authority"` // The data or source file which is the object of attestation. Content CID `json:"content,omitempty"` // The encoded bytes that were signed. May be decoded into a manifest. |
Changes to store/boltstore/boltstore.go.
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
..
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
_, err := tx.CreateBucketIfNotExists(this.bucket) return err }) return this, err } func (this *boltStore) PutTestimony(testimony model.Testimony) (*model.TestimonyKey, error) { //log.Println("boltStore.PutTestimony()") // troubleshoot // use key format consistent with kademlia tkey := testimony.Key() key := tkey.KID().Sum() value, err := model.Encode(testimony) if err != nil { ................................................................................ } // persist to underlying db err = this.DB.Batch(func(tx *bolt.Tx) error { b := tx.Bucket(this.bucket) return b.Put(key, value) }) return tkey, err } func (this *boltStore) GetTestimony(tkey model.TestimonyKey) (testimony *model.Testimony, err error) { //log.Println("boltStore.FindTestimony()", this) // troubleshoot key := tkey.KID().Sum() err = this.DB.View(func(tx *bolt.Tx) (err error) { b := tx.Bucket(this.bucket) v := b.Get(key) if v != nil { testimony = new(model.Testimony) |
<
>
<
|
32
33
34
35
36
37
38
39
40
41
42
43
44
45
..
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
_, err := tx.CreateBucketIfNotExists(this.bucket)
return err
})
return this, err
}
func (this *boltStore) PutTestimony(testimony model.Testimony) (*model.TestimonyKey, error) {
// use key format consistent with kademlia
tkey := testimony.Key()
key := tkey.KID().Sum()
value, err := model.Encode(testimony)
if err != nil {
................................................................................
}
// persist to underlying db
err = this.DB.Batch(func(tx *bolt.Tx) error {
b := tx.Bucket(this.bucket)
return b.Put(key, value)
})
return tkey, err
}
func (this *boltStore) GetTestimony(tkey model.TestimonyKey) (testimony *model.Testimony, err error) {
key := tkey.KID().Sum()
err = this.DB.View(func(tx *bolt.Tx) (err error) {
b := tx.Bucket(this.bucket)
v := b.Get(key)
if v != nil {
testimony = new(model.Testimony)
|