Merge branch 'writeAccounts' of github.com:ShyftNetwork/shyft_go-ethereum into uiIntegration

This commit is contained in:
Dustin Brickwood 2018-05-15 14:39:44 -04:00
commit 38dfd729f0
2 changed files with 12 additions and 2 deletions

View file

@ -6,6 +6,11 @@ CREATE TABLE IF NOT EXISTS blocks (
txCount numeric, txCount numeric,
uncleCount numeric, uncleCount numeric,
age timestamp, age timestamp,
parentHash text,
uncleHash text,
difficulty bigint,
size text,
nonce numeric,
number bigint number bigint
); );

View file

@ -106,6 +106,11 @@ type SendAndReceive struct {
gasLimit := block.Header().GasLimit gasLimit := block.Header().GasLimit
txCount := block.Transactions().Len() txCount := block.Transactions().Len()
uncleCount := len(block.Uncles()) 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 // Convert the receipts into their storage form and serialize them
storageReceipts := make([]*types.ReceiptForStorage, len(receipts)) storageReceipts := make([]*types.ReceiptForStorage, len(receipts))
@ -140,8 +145,8 @@ type SendAndReceive struct {
} }
age := time.Unix(i, 0) 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` 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).Scan(&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 { if qerr != nil {
panic(qerr) panic(qerr)
} }