From 0938ddad8f76ace931af6f12ff279890a3c0b64f Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Tue, 15 May 2018 14:39:18 -0400 Subject: [PATCH] detailed block info included --- shyftDb/postgres_setup/create_tables.psql | 5 +++++ shyftdb/shyft_database_util.go | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/shyftDb/postgres_setup/create_tables.psql b/shyftDb/postgres_setup/create_tables.psql index 1e3973286e..c4f5e0cb43 100644 --- a/shyftDb/postgres_setup/create_tables.psql +++ b/shyftDb/postgres_setup/create_tables.psql @@ -6,6 +6,11 @@ CREATE TABLE IF NOT EXISTS blocks ( txCount numeric, uncleCount numeric, age timestamp, + parentHash text, + uncleHash text, + difficulty bigint, + size text, + nonce numeric, number bigint ); diff --git a/shyftdb/shyft_database_util.go b/shyftdb/shyft_database_util.go index bd681906a6..a3de91d12d 100644 --- a/shyftdb/shyft_database_util.go +++ b/shyftdb/shyft_database_util.go @@ -106,6 +106,11 @@ type SendAndReceive struct { gasLimit := block.Header().GasLimit txCount := block.Transactions().Len() uncleCount := len(block.Uncles()) + parentHash := block.ParentHash().String() + uncleHash := block.UncleHash().String() + blockDifficulty := block.Difficulty().String() + blockSize := block.Size().String() + blockNonce := block.Nonce() // Convert the receipts into their storage form and serialize them storageReceipts := make([]*types.ReceiptForStorage, len(receipts)) @@ -140,8 +145,8 @@ type SendAndReceive struct { } age := time.Unix(i, 0) - sqlStatement := `INSERT INTO blocks(hash, coinbase, number, gasUsed, gasLimit, txCount, uncleCount, age) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8)) RETURNING number` - qerr := sqldb.QueryRow(sqlStatement, block.Header().Hash().Hex(), coinbase, number, gasUsed, gasLimit, txCount, uncleCount, age).Scan(&number) + sqlStatement := `INSERT INTO blocks(hash, coinbase, number, gasUsed, gasLimit, txCount, uncleCount, age, parentHash, uncleHash, difficulty, size, nonce) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10), ($11), ($12),($13)) RETURNING number` + qerr := sqldb.QueryRow(sqlStatement, block.Header().Hash().Hex(), coinbase, number, gasUsed, gasLimit, txCount, uncleCount, age, parentHash, uncleHash, blockDifficulty, blockSize, blockNonce).Scan(&number) if qerr != nil { panic(qerr) }