Files
vm/api/keystore/blockchain_keystore.go

51 lines
1.5 KiB
Go

// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package keystore
import (
"github.com/luxfi/log"
"github.com/luxfi/database"
"github.com/luxfi/database/encdb"
"github.com/luxfi/ids"
)
var _ BlockchainKeystore = (*blockchainKeystore)(nil)
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.Warn("deprecated keystore called",
log.String("method", "getDatabase"),
log.String("username", username),
log.Stringer("blockchainID", bks.blockchainID),
)
return bks.ks.GetDatabase(bks.blockchainID, username, password)
}
func (bks *blockchainKeystore) GetRawDatabase(username, password string) (database.Database, error) {
bks.ks.log.Warn("deprecated keystore called",
log.String("method", "getRawDatabase"),
log.String("username", username),
log.Stringer("blockchainID", bks.blockchainID),
)
return bks.ks.GetRawDatabase(bks.blockchainID, username, password)
}