Skip to content
Snippets Groups Projects
Commit 862c2e3b authored by Krzysztof Leśniak's avatar Krzysztof Leśniak Committed by Bartek Wrona
Browse files

Implement cast from operation to account_update2_operation

parent f98cc157
No related branches found
No related tags found
6 merge requests!627merge in fix for get_current_block_age,!626Fix get_current_block_age function to avoid healthcheck fails,!622merge develop to master,!599merge ( with merge commit) develop to master,!597Merge develop to master for release,!264Implement conversion functions from custom operation type to specific sql operation type
......@@ -102,6 +102,12 @@ Datum to_datum(const hive::protocol::public_key_type& value)
{
return CStringGetTextDatum(static_cast<std::string>(value).c_str());
}
template<typename T>
Datum to_datum(const fc::optional<T>& value)
{
if (value.valid()) return to_datum(value.value());
else return (Datum)0; // NULL
}
template<typename T>
struct members_to_sql_tuple_visitor {
......@@ -417,4 +423,11 @@ extern "C"
_operation* op = PG_GETARG_HIVE_OPERATION_PP( 0 );
return operation_to<hive::protocol::account_create_with_delegation_operation>(op);
}
PG_FUNCTION_INFO_V1( operation_to_account_update2_operation );
Datum operation_to_account_update2_operation( PG_FUNCTION_ARGS )
{
_operation* op = PG_GETARG_HIVE_OPERATION_PP( 0 );
return operation_to<hive::protocol::account_update2_operation>(op);
}
}
......@@ -57,3 +57,13 @@ AS 'MODULE_PATHNAME',
CREATE CAST (hive.operation AS hive.account_create_with_delegation_operation)
WITH FUNCTION hive._operation_to_account_create_with_delegation_operation
AS ASSIGNMENT;
CREATE OR REPLACE FUNCTION hive._operation_to_account_update2_operation(
hive.operation
) RETURNS hive.account_update2_operation LANGUAGE c IMMUTABLE STRICT PARALLEL SAFE
AS 'MODULE_PATHNAME',
'operation_to_account_update2_operation';
CREATE CAST (hive.operation AS hive.account_update2_operation)
WITH FUNCTION hive._operation_to_account_update2_operation
AS ASSIGNMENT;
......@@ -139,4 +139,15 @@ CREATE TYPE hive.account_create_with_delegation_operation AS (
extensions hive.extensions_type
);
CREATE TYPE hive.account_update2_operation AS (
account hive.account_name_type,
owner hive.authority,
active hive.authority,
posting hive.authority,
memo_key hive.public_key_type,
json_metadata text,
posting_json_metadata text,
extensions hive.extensions_type
);
CREATE TYPE hive.void_t AS ();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment