-
Notifications
You must be signed in to change notification settings - Fork 10
Ensure compatibility with stellar-core 15.x #207
Copy link
Copy link
Open
Description
stellar-core 15.0.0 introduces breaking changes to the DB schema: stellar/stellar-core#2593
For now I fixed it in a quick and dirty way by applying the following changes to the running stellar-core DB:
CREATE SCHEMA xdrs;
CREATE OR REPLACE FUNCTION xdrs.xdr_int64(xdr bytea, inout pos integer, out result bigint) AS $$
SELECT pos + 8, ('x' || encode(substring(xdr from pos for 8), 'hex'))::bit(64)::bigint
$$ LANGUAGE SQL IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION buyingLiabilities(acc accounts) RETURNS bigint AS $$
SELECT coalesce(buying.value, 0)
FROM decode(acc.extension, 'base64') accraw(xdrbytes),
xdrs.xdr_int64(accraw.xdrbytes, 5) as buying(pos, value)
$$ LANGUAGE SQL IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION sellingLiabilities(acc accounts) RETURNS bigint AS $$
SELECT coalesce(selling.value, 0)
FROM decode(acc.extension, 'base64') accraw(xdrbytes),
xdrs.xdr_int64(accraw.xdrbytes, 13) as selling(pos, value)
$$ LANGUAGE SQL IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION buyingLiabilities(tl trustlines) RETURNS bigint AS $$
SELECT coalesce(buying.value, 0)
FROM decode(tl.extension, 'base64') accraw(xdrbytes),
xdrs.xdr_int64(accraw.xdrbytes, 5) as buying(pos, value)
$$ LANGUAGE SQL IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION sellingLiabilities(tl trustlines) RETURNS bigint AS $$
SELECT coalesce(selling.value, 0)
FROM decode(tl.extension, 'base64') accraw(xdrbytes),
xdrs.xdr_int64(accraw.xdrbytes, 13) as selling(pos, value)
$$ LANGUAGE SQL IMMUTABLE STRICT;It seems to solve an issue for the time being, but we need to update Astrograph ORM layer to work with the new LedgerEntry format which stores extensions as base64-encoded XDR: entry-specific extension (AccountEntryExt, TrustLineEntryExt) in extension column, and common extension (LedgerEntryExt) in ledgerext column. It's similar to how we currently work with account signers.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels