@@ -78,16 +78,16 @@ const (
78
78
DefaultSessionDBTimeout = 5 * time .Second
79
79
)
80
80
81
- // DB is a bolt-backed persistent store.
82
- type DB struct {
81
+ // BoltStore is a bolt-backed persistent store.
82
+ type BoltStore struct {
83
83
* bbolt.DB
84
84
}
85
85
86
- // A compile-time check to ensure that DB implements the Store interface.
87
- var _ Store = (* DB )(nil )
86
+ // A compile-time check to ensure that BoltStore implements the Store interface.
87
+ var _ Store = (* BoltStore )(nil )
88
88
89
89
// NewDB creates a new bolt database that can be found at the given directory.
90
- func NewDB (dir , fileName string ) (* DB , error ) {
90
+ func NewDB (dir , fileName string ) (* BoltStore , error ) {
91
91
firstInit := false
92
92
path := filepath .Join (dir , fileName )
93
93
@@ -110,7 +110,7 @@ func NewDB(dir, fileName string) (*DB, error) {
110
110
return nil , err
111
111
}
112
112
113
- return & DB {DB : db }, nil
113
+ return & BoltStore {DB : db }, nil
114
114
}
115
115
116
116
// fileExists reports whether the named file or directory exists.
@@ -181,7 +181,7 @@ func getSessionKey(session *Session) []byte {
181
181
// local public key already exists an error is returned.
182
182
//
183
183
// NOTE: this is part of the Store interface.
184
- func (db * DB ) CreateSession (session * Session ) error {
184
+ func (db * BoltStore ) CreateSession (session * Session ) error {
185
185
var buf bytes.Buffer
186
186
if err := SerializeSession (& buf , session ); err != nil {
187
187
return err
@@ -275,7 +275,7 @@ func (db *DB) CreateSession(session *Session) error {
275
275
// to the session with the given local pub key.
276
276
//
277
277
// NOTE: this is part of the Store interface.
278
- func (db * DB ) UpdateSessionRemotePubKey (localPubKey ,
278
+ func (db * BoltStore ) UpdateSessionRemotePubKey (localPubKey ,
279
279
remotePubKey * btcec.PublicKey ) error {
280
280
281
281
key := localPubKey .SerializeCompressed ()
@@ -313,7 +313,7 @@ func (db *DB) UpdateSessionRemotePubKey(localPubKey,
313
313
// GetSession fetches the session with the given key.
314
314
//
315
315
// NOTE: this is part of the Store interface.
316
- func (db * DB ) GetSession (key * btcec.PublicKey ) (* Session , error ) {
316
+ func (db * BoltStore ) GetSession (key * btcec.PublicKey ) (* Session , error ) {
317
317
var session * Session
318
318
err := db .View (func (tx * bbolt.Tx ) error {
319
319
sessionBucket , err := getBucket (tx , sessionBucketKey )
@@ -343,7 +343,7 @@ func (db *DB) GetSession(key *btcec.PublicKey) (*Session, error) {
343
343
// ListSessions returns all sessions currently known to the store.
344
344
//
345
345
// NOTE: this is part of the Store interface.
346
- func (db * DB ) ListSessions (filterFn func (s * Session ) bool ) ([]* Session , error ) {
346
+ func (db * BoltStore ) ListSessions (filterFn func (s * Session ) bool ) ([]* Session , error ) {
347
347
var sessions []* Session
348
348
err := db .View (func (tx * bbolt.Tx ) error {
349
349
sessionBucket , err := getBucket (tx , sessionBucketKey )
@@ -383,7 +383,7 @@ func (db *DB) ListSessions(filterFn func(s *Session) bool) ([]*Session, error) {
383
383
// public key to be revoked.
384
384
//
385
385
// NOTE: this is part of the Store interface.
386
- func (db * DB ) RevokeSession (key * btcec.PublicKey ) error {
386
+ func (db * BoltStore ) RevokeSession (key * btcec.PublicKey ) error {
387
387
var session * Session
388
388
return db .Update (func (tx * bbolt.Tx ) error {
389
389
sessionBucket , err := getBucket (tx , sessionBucketKey )
@@ -416,7 +416,7 @@ func (db *DB) RevokeSession(key *btcec.PublicKey) error {
416
416
// GetSessionByID fetches the session with the given ID.
417
417
//
418
418
// NOTE: this is part of the Store interface.
419
- func (db * DB ) GetSessionByID (id ID ) (* Session , error ) {
419
+ func (db * BoltStore ) GetSessionByID (id ID ) (* Session , error ) {
420
420
var session * Session
421
421
err := db .View (func (tx * bbolt.Tx ) error {
422
422
sessionBucket , err := getBucket (tx , sessionBucketKey )
@@ -454,7 +454,7 @@ func (db *DB) GetSessionByID(id ID) (*Session, error) {
454
454
// used or discarded.
455
455
//
456
456
// NOTE: this is part of the Store interface.
457
- func (db * DB ) GetUnusedIDAndKeyPair () (ID , * btcec.PrivateKey , error ) {
457
+ func (db * BoltStore ) GetUnusedIDAndKeyPair () (ID , * btcec.PrivateKey , error ) {
458
458
var (
459
459
id ID
460
460
privKey * btcec.PrivateKey
@@ -500,7 +500,7 @@ func (db *DB) GetUnusedIDAndKeyPair() (ID, *btcec.PrivateKey, error) {
500
500
// GetGroupID will return the group ID for the given session ID.
501
501
//
502
502
// NOTE: this is part of the IDToGroupIndex interface.
503
- func (db * DB ) GetGroupID (sessionID ID ) (ID , error ) {
503
+ func (db * BoltStore ) GetGroupID (sessionID ID ) (ID , error ) {
504
504
var groupID ID
505
505
err := db .View (func (tx * bbolt.Tx ) error {
506
506
sessionBkt , err := getBucket (tx , sessionBucketKey )
@@ -540,7 +540,7 @@ func (db *DB) GetGroupID(sessionID ID) (ID, error) {
540
540
// group with the given ID.
541
541
//
542
542
// NOTE: this is part of the IDToGroupIndex interface.
543
- func (db * DB ) GetSessionIDs (groupID ID ) ([]ID , error ) {
543
+ func (db * BoltStore ) GetSessionIDs (groupID ID ) ([]ID , error ) {
544
544
var (
545
545
sessionIDs []ID
546
546
err error
@@ -567,7 +567,7 @@ func (db *DB) GetSessionIDs(groupID ID) ([]ID, error) {
567
567
// each session passes.
568
568
//
569
569
// NOTE: this is part of the Store interface.
570
- func (db * DB ) CheckSessionGroupPredicate (groupID ID ,
570
+ func (db * BoltStore ) CheckSessionGroupPredicate (groupID ID ,
571
571
fn func (s * Session ) bool ) (bool , error ) {
572
572
573
573
var (
0 commit comments