2023-07-08 17:01:26 +00:00
|
|
|
package jsonrpc
|
2020-10-12 08:39:33 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
2020-10-24 17:03:52 +00:00
|
|
|
|
2023-04-13 11:19:02 +00:00
|
|
|
"github.com/ledgerwatch/erigon-lib/common/hexutility"
|
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)
|
2023-04-13 11:19:02 +00:00
|
|
|
GetHex(_ context.Context, _ string, _ string) (hexutility.Bytes, error)
|
|
|
|
PutHex(_ context.Context, _ string, _ string, _ hexutility.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.
|
2023-04-13 11:19:02 +00:00
|
|
|
func (api *DBAPIImpl) GetHex(_ context.Context, _ string, _ string) (hexutility.Bytes, error) {
|
|
|
|
return hexutility.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.
|
2023-04-13 11:19:02 +00:00
|
|
|
func (api *DBAPIImpl) PutHex(_ context.Context, _ string, _ string, _ hexutility.Bytes) (bool, error) {
|
2020-10-24 17:03:52 +00:00
|
|
|
return false, fmt.Errorf(NotAvailableDeprecated, "db_putHex")
|
2020-10-12 08:39:33 +00:00
|
|
|
}
|