From 99b6f60eb708b343a8c302b05d7c53ab2b650fe2 Mon Sep 17 00:00:00 2001 From: i-norden Date: Mon, 27 Feb 2023 16:16:52 -0600 Subject: [PATCH] begin sql statements --- sql.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 sql.go diff --git a/sql.go b/sql.go new file mode 100644 index 0000000..f130d91 --- /dev/null +++ b/sql.go @@ -0,0 +1,17 @@ +package ipld_eth_statedb + +const ( + GetBalancePgStr = `SELECT balance FROM eth.state_cids + INNER JOIN eth.header_cids ON ( + state_cids.header_id = header_cids.block_hash + AND state_cids.block_number = header_cids.block_number + ) + WHERE state_leaf_key = $1 + AND header_cids.block_number <= (SELECT block_number + FROM eth.header_cids + WHERE block_hash = $2) + AND header_cids.block_hash = (SELECT canonical_header_hash(header_cids.block_number)) + ORDER BY header_cids.block_number DESC + LIMIT 1` + GetContractCodePgStr = `SELECT data FROM public.blocks WHERE key = $1` +)