From 87013110f9c37ab44d1dca187aa8ffd4f0f16196 Mon Sep 17 00:00:00 2001 From: i-norden Date: Thu, 2 Mar 2023 17:41:44 -0600 Subject: [PATCH] public.blocks => ipld.blocks --- pkg/eth/backend.go | 11 ++++------- pkg/eth/cid_retriever.go | 4 ++-- pkg/eth/ipld_retriever.go | 14 +++++++------- pkg/shared/functions.go | 4 ++-- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/pkg/eth/backend.go b/pkg/eth/backend.go index 6d92f994..c5f554ac 100644 --- a/pkg/eth/backend.go +++ b/pkg/eth/backend.go @@ -61,9 +61,6 @@ var ( errMultipleHeadersForHash = errors.New("more than one headers for the given hash") errTxHashNotFound = errors.New("transaction for hash not found") errTxHashInMultipleBlocks = errors.New("transaction for hash found in more than one canonical block") - - // errMissingSignature is returned if a block's extra-data section doesn't seem - // to contain a 65 byte secp256k1 signature. ) const ( @@ -71,15 +68,15 @@ const ( FROM canonical_header_hash($1) AS block_hash WHERE block_hash IS NOT NULL` RetrieveCanonicalHeaderByNumber = `SELECT cid, data FROM eth.header_cids - INNER JOIN public.blocks ON ( + INNER JOIN ipld.blocks ON ( header_cids.mh_key = blocks.key AND header_cids.block_number = blocks.block_number ) WHERE block_hash = (SELECT canonical_header_hash($1))` - RetrieveTD = `SELECT CAST(td as Text) FROM eth.header_cids + RetrieveTD = `SELECT CAST(td as TEXT) FROM eth.header_cids WHERE header_cids.block_hash = $1` RetrieveRPCTransaction = `SELECT blocks.data, header_id, transaction_cids.block_number, index - FROM public.blocks, eth.transaction_cids + FROM ipld.blocks, eth.transaction_cids WHERE blocks.key = transaction_cids.mh_key AND blocks.block_number = transaction_cids.block_number AND transaction_cids.tx_hash = $1 @@ -97,7 +94,7 @@ const ( AND header_cids.block_hash = (SELECT canonical_header_hash(header_cids.block_number)) ORDER BY header_cids.block_number DESC LIMIT 1` - RetrieveCodeByMhKey = `SELECT data FROM public.blocks WHERE key = $1` + RetrieveCodeByMhKey = `SELECT data FROM ipld.blocks WHERE key = $1` ) const ( diff --git a/pkg/eth/cid_retriever.go b/pkg/eth/cid_retriever.go index b9b943b4..d6ff7ac1 100644 --- a/pkg/eth/cid_retriever.go +++ b/pkg/eth/cid_retriever.go @@ -41,7 +41,7 @@ type IPLDModelRecord struct { // TableName overrides the table name used by IPLD func (IPLDModelRecord) TableName() string { - return "public.blocks" + return "ipld.blocks" } type HeaderCIDRecord struct { @@ -205,7 +205,7 @@ func (ecr *CIDRetriever) RetrieveFilteredGQLLogs(tx *sqlx.Tx, rctFilter ReceiptF eth.log_cids.leaf_cid, eth.log_cids.index, eth.log_cids.rct_id, eth.log_cids.address, eth.log_cids.topic0, eth.log_cids.topic1, eth.log_cids.topic2, eth.log_cids.topic3, eth.log_cids.log_data, data, eth.receipt_cids.leaf_cid as cid, eth.receipt_cids.post_status, eth.receipt_cids.tx_id AS tx_hash - FROM eth.log_cids, eth.receipt_cids, public.blocks + FROM eth.log_cids, eth.receipt_cids, ipld.blocks WHERE eth.log_cids.rct_id = receipt_cids.tx_id AND eth.log_cids.header_id = receipt_cids.header_id AND eth.log_cids.block_number = receipt_cids.block_number diff --git a/pkg/eth/ipld_retriever.go b/pkg/eth/ipld_retriever.go index 51a12cb4..5d1075d3 100644 --- a/pkg/eth/ipld_retriever.go +++ b/pkg/eth/ipld_retriever.go @@ -33,7 +33,7 @@ import ( const ( RetrieveHeaderByHashPgStr = `SELECT cid, data FROM eth.header_cids - INNER JOIN public.blocks ON ( + INNER JOIN ipld.blocks ON ( header_cids.mh_key = blocks.key AND header_cids.block_number = blocks.block_number ) @@ -44,7 +44,7 @@ const ( uncle_cids.header_id = header_cids.block_hash AND uncle_cids.block_number = header_cids.block_number ) - INNER JOIN public.blocks ON ( + INNER JOIN ipld.blocks ON ( uncle_cids.mh_key = blocks.key AND uncle_cids.block_number = blocks.block_number ) @@ -57,7 +57,7 @@ const ( uncle_cids.header_id = header_cids.block_hash AND uncle_cids.block_number = header_cids.block_number ) - INNER JOIN public.blocks ON ( + INNER JOIN ipld.blocks ON ( uncle_cids.mh_key = blocks.key AND uncle_cids.block_number = blocks.block_number ) @@ -69,7 +69,7 @@ const ( transaction_cids.header_id = header_cids.block_hash AND transaction_cids.block_number = header_cids.block_number ) - INNER JOIN public.blocks ON ( + INNER JOIN ipld.blocks ON ( transaction_cids.mh_key = blocks.key AND transaction_cids.block_number = blocks.block_number ) @@ -82,7 +82,7 @@ const ( transaction_cids.header_id = header_cids.block_hash AND transaction_cids.block_number = header_cids.block_number ) - INNER JOIN public.blocks ON ( + INNER JOIN ipld.blocks ON ( transaction_cids.mh_key = blocks.key AND transaction_cids.block_number = blocks.block_number ) @@ -99,7 +99,7 @@ const ( transaction_cids.header_id = header_cids.block_hash AND transaction_cids.block_number = header_cids.block_number ) - INNER JOIN public.blocks ON ( + INNER JOIN ipld.blocks ON ( receipt_cids.leaf_mh_key = blocks.key AND receipt_cids.block_number = blocks.block_number ) @@ -117,7 +117,7 @@ const ( transaction_cids.header_id = header_cids.block_hash AND transaction_cids.block_number = header_cids.block_number ) - INNER JOIN public.blocks ON ( + INNER JOIN ipld.blocks ON ( receipt_cids.leaf_mh_key = blocks.key AND receipt_cids.block_number = blocks.block_number ) diff --git a/pkg/shared/functions.go b/pkg/shared/functions.go index f5eac06c..d54ddaf1 100644 --- a/pkg/shared/functions.go +++ b/pkg/shared/functions.go @@ -50,14 +50,14 @@ func Rollback(tx *sqlx.Tx) { // FetchIPLDByMhKeyAndBlockNumber is used to retrieve an ipld from Postgres blockstore with the provided tx, mhkey string and blockNumber func FetchIPLDByMhKeyAndBlockNumber(tx *sqlx.Tx, mhKey string, blockNumber uint64) ([]byte, error) { - pgStr := `SELECT data FROM public.blocks WHERE key = $1 AND block_number = $2` + pgStr := `SELECT data FROM ipld.blocks WHERE key = $1 AND block_number = $2` var block []byte return block, tx.Get(&block, pgStr, mhKey, blockNumber) } // FetchIPLD is used to retrieve an IPLD from Postgres mhkey and blockNumber func FetchIPLD(db *sqlx.DB, mhKey string, blockNumber uint64) ([]byte, error) { - pgStr := `SELECT data FROM public.blocks WHERE key = $1 AND block_number = $2` + pgStr := `SELECT data FROM ipld.blocks WHERE key = $1 AND block_number = $2` var block []byte return block, db.Get(&block, pgStr, mhKey, blockNumber) }