2020-10-12 08:39:33 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
2020-10-24 17:03:52 +00:00
|
|
|
|
2021-05-20 18:25:53 +00:00
|
|
|
"github.com/ledgerwatch/erigon/common/hexutil"
|
2020-10-12 08:39:33 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// DBAPI the interface for the db_ RPC commands (deprecated)
|
|
|
|
type DBAPI interface {
|
|
|
|
GetString(_ context.Context, _ string, _ string) (string, error)
|
2020-10-24 17:03:52 +00:00
|
|
|
PutString(_ context.Context, _ string, _ string, _ string) (bool, error)
|
|
|
|
GetHex(_ context.Context, _ string, _ string) (hexutil.Bytes, error)
|
|
|
|
PutHex(_ context.Context, _ string, _ string, _ hexutil.Bytes) (bool, error)
|
2020-10-12 08:39:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// DBAPIImpl data structure to store things needed for db_ commands
|
|
|
|
type DBAPIImpl struct {
|
|
|
|
unused uint64
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewDBAPIImpl returns NetAPIImplImpl instance
|
|
|
|
func NewDBAPIImpl() *DBAPIImpl {
|
|
|
|
return &DBAPIImpl{
|
|
|
|
unused: uint64(0),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-24 17:03:52 +00:00
|
|
|
// GetString implements db_getString. Returns string from the local database.
|
|
|
|
// Deprecated: This function will be removed in the future.
|
2020-10-12 08:39:33 +00:00
|
|
|
func (api *DBAPIImpl) GetString(_ context.Context, _ string, _ string) (string, error) {
|
|
|
|
return "", fmt.Errorf(NotAvailableDeprecated, "db_getString")
|
|
|
|
}
|
|
|
|
|
2020-10-24 17:03:52 +00:00
|
|
|
// PutString implements db_putString. Stores a string in the local database.
|
|
|
|
// Deprecated: This function will be removed in the future.
|
|
|
|
func (api *DBAPIImpl) PutString(_ context.Context, _ string, _ string, _ string) (bool, error) {
|
|
|
|
return false, fmt.Errorf(NotAvailableDeprecated, "db_putString")
|
2020-10-12 08:39:33 +00:00
|
|
|
}
|
|
|
|
|
2020-10-24 17:03:52 +00:00
|
|
|
// GetHex implements db_getHex. Returns binary data from the local database.
|
|
|
|
// Deprecated: This function will be removed in the future.
|
|
|
|
func (api *DBAPIImpl) GetHex(_ context.Context, _ string, _ string) (hexutil.Bytes, error) {
|
|
|
|
return hexutil.Bytes(""), fmt.Errorf(NotAvailableDeprecated, "db_getHex")
|
2020-10-12 08:39:33 +00:00
|
|
|
}
|
|
|
|
|
2020-10-24 17:03:52 +00:00
|
|
|
// PutHex implements db_putHex. Stores binary data in the local database.
|
|
|
|
// Deprecated: This function will be removed in the future.
|
|
|
|
func (api *DBAPIImpl) PutHex(_ context.Context, _ string, _ string, _ hexutil.Bytes) (bool, error) {
|
|
|
|
return false, fmt.Errorf(NotAvailableDeprecated, "db_putHex")
|
2020-10-12 08:39:33 +00:00
|
|
|
}
|