-
Notifications
You must be signed in to change notification settings - Fork 662
/
blockchain_keystore.go
40 lines (30 loc) · 1.39 KB
/
blockchain_keystore.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
// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package keystore
import (
"github.com/ava-labs/avalanchego/database"
"github.com/ava-labs/avalanchego/database/encdb"
"github.com/ava-labs/avalanchego/ids"
)
var _ BlockchainKeystore = &blockchainKeystore{}
type BlockchainKeystore interface {
// Get a database that is able to read and write unencrypted values from the
// underlying database.
GetDatabase(username, password string) (*encdb.Database, error)
// Get the underlying database that is able to read and write encrypted
// values. This Database will not perform any encrypting or decrypting of
// values and is not recommended to be used when implementing a VM.
GetRawDatabase(username, password string) (database.Database, error)
}
type blockchainKeystore struct {
blockchainID ids.ID
ks *keystore
}
func (bks *blockchainKeystore) GetDatabase(username, password string) (*encdb.Database, error) {
bks.ks.log.Debug("Keystore: GetDatabase called with %s from %s", username, bks.blockchainID)
return bks.ks.GetDatabase(bks.blockchainID, username, password)
}
func (bks *blockchainKeystore) GetRawDatabase(username, password string) (database.Database, error) {
bks.ks.log.Debug("Keystore: GetRawDatabase called with %s from %s", username, bks.blockchainID)
return bks.ks.GetRawDatabase(bks.blockchainID, username, password)
}