mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
added rewards to UI
This commit is contained in:
parent
8e6ff5f621
commit
f9b1ed77b4
11 changed files with 140 additions and 34 deletions
|
|
@ -26,9 +26,9 @@ class AccountTable extends Component {
|
||||||
const sorted = [...this.state.data];
|
const sorted = [...this.state.data];
|
||||||
sorted.sort((a, b) => a.Balance > b.Balance);
|
sorted.sort((a, b) => a.Balance > b.Balance);
|
||||||
const table = sorted.reverse().map((data, i) => {
|
const table = sorted.reverse().map((data, i) => {
|
||||||
const conversion = data.Balance / 1000000000000000000;
|
const conversion = data.Balance / 10000000000000000000;
|
||||||
const total = sorted
|
const total = sorted
|
||||||
.map(num => num.Balance / 1000000000000000000)
|
.map(num => num.Balance / 10000000000000000000)
|
||||||
.reduce((acc, cur) => acc + cur ,0);
|
.reduce((acc, cur) => acc + cur ,0);
|
||||||
const percentage = ( (conversion / total) *100);
|
const percentage = ( (conversion / total) *100);
|
||||||
return <AccountsTable
|
return <AccountsTable
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ class BlocksTable extends Component {
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get("http://localhost:8080/api/get_all_blocks")
|
const response = await axios.get("http://localhost:8080/api/get_all_blocks");
|
||||||
await this.setState({data: response.data});
|
await this.setState({data: response.data});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
|
@ -24,6 +24,7 @@ class BlocksTable extends Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const table = this.state.data.map((data, i) => {
|
const table = this.state.data.map((data, i) => {
|
||||||
|
const conversion = data.Rewards / 10000000000000000000;
|
||||||
return <BlockTable
|
return <BlockTable
|
||||||
key={`${data.TxHash}${i}`}
|
key={`${data.TxHash}${i}`}
|
||||||
Hash={data.Hash}
|
Hash={data.Hash}
|
||||||
|
|
@ -34,6 +35,7 @@ class BlocksTable extends Component {
|
||||||
GasLimit={data.GasLimit}
|
GasLimit={data.GasLimit}
|
||||||
UncleCount={data.UncleCount}
|
UncleCount={data.UncleCount}
|
||||||
TxCount={data.TxCount}
|
TxCount={data.TxCount}
|
||||||
|
Reward={conversion}
|
||||||
detailBlockHandler={this.props.detailBlockHandler}
|
detailBlockHandler={this.props.detailBlockHandler}
|
||||||
/>
|
/>
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ const BlockTable = (props) => {
|
||||||
<td>{props.GasUsed}</td>
|
<td>{props.GasUsed}</td>
|
||||||
<td>{props.GasLimit}</td>
|
<td>{props.GasLimit}</td>
|
||||||
<td>TBD</td>
|
<td>TBD</td>
|
||||||
<td>TBD</td>
|
<td>{props.Reward}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import classes from './table.css';
|
import classes from './table.css';
|
||||||
|
import { Link } from 'react-router-dom'
|
||||||
|
|
||||||
class DetailBlockTable extends Component {
|
class DetailBlockTable extends Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let data = this.props.data
|
let data = this.props.data;
|
||||||
let combinedClasses = ['responsive-table', classes.table];
|
let combinedClasses = ['responsive-table', classes.table];
|
||||||
return (
|
return (
|
||||||
<table className={combinedClasses.join(' ')}>
|
<table className={combinedClasses.join(' ')}>
|
||||||
|
|
@ -19,7 +20,7 @@ class DetailBlockTable extends Component {
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Txn:</th>
|
<th scope="col">Txn:</th>
|
||||||
<td>{data.TxCount} transactions</td>
|
<td><Link to="/block/transactions" onClick={() => this.props.getBlockTransactions(data.Number)}>{data.TxCount} transactions</Link></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Block Hash:</th>
|
<th scope="col">Block Hash:</th>
|
||||||
|
|
@ -67,7 +68,7 @@ class DetailBlockTable extends Component {
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Reward:</th>
|
<th scope="col">Reward:</th>
|
||||||
<td>TBD</td>
|
<td>{data.Rewards}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
import React, { Component } from 'react';
|
||||||
|
import TransactionsTable from './transactionTable';
|
||||||
|
import classes from './table.css';
|
||||||
|
|
||||||
|
class BlockTransactionTable extends Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
data: []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const table = this.props.data.map((data, i) => {
|
||||||
|
const conversion = data.Cost / 10000000000000000000;
|
||||||
|
return <TransactionsTable
|
||||||
|
key={`${data.TxHash}${i}`}
|
||||||
|
age={data.Age}
|
||||||
|
txHash={data.TxHash}
|
||||||
|
blockNumber={data.BlockNumber}
|
||||||
|
to={data.To}
|
||||||
|
from={data.From}
|
||||||
|
value={data.Amount}
|
||||||
|
cost={conversion}
|
||||||
|
getBlockTransactions={this.props.getBlockTransactions}
|
||||||
|
detailTransactionHandler={this.props.detailTransactionHandler}
|
||||||
|
detailAccountHandler={this.props.detailAccountHandler}
|
||||||
|
/>
|
||||||
|
})
|
||||||
|
|
||||||
|
let combinedClasses = ['responsive-table', classes.table];
|
||||||
|
return (
|
||||||
|
<table key={this.props.data.TxHash} className={combinedClasses.join(' ')}>
|
||||||
|
<thead className={classes.tHead}>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">TxHash</th>
|
||||||
|
<th scope="col">Block</th>
|
||||||
|
<th scope="col">Age</th>
|
||||||
|
<th scope="col">From</th>
|
||||||
|
<th scope="col"></th>
|
||||||
|
<th scope="col">To</th>
|
||||||
|
<th scope="col">Value</th>
|
||||||
|
<th scope="col">TxFee</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
{table}
|
||||||
|
</table>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default BlockTransactionTable;
|
||||||
|
|
@ -6,6 +6,7 @@ class DetailTransactionTable extends Component {
|
||||||
render() {
|
render() {
|
||||||
let data = this.props.data
|
let data = this.props.data
|
||||||
let combinedClasses = ['responsive-table', classes.table];
|
let combinedClasses = ['responsive-table', classes.table];
|
||||||
|
const conversion = data.Cost / 10000000000000000000;
|
||||||
return (
|
return (
|
||||||
<table className={combinedClasses.join(' ')}>
|
<table className={combinedClasses.join(' ')}>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
@ -51,7 +52,7 @@ class DetailTransactionTable extends Component {
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Actual Tx Cost/Fee:</th>
|
<th scope="col">Actual Tx Cost/Fee:</th>
|
||||||
<td>{data.Cost}</td>
|
<td>{conversion}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Nonce:</th>
|
<th scope="col">Nonce:</th>
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ class TransactionTable extends Component {
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
const table = this.state.data.map((data, i) => {
|
const table = this.state.data.map((data, i) => {
|
||||||
|
const conversion = data.Cost / 10000000000000000000;
|
||||||
return <TransactionsTable
|
return <TransactionsTable
|
||||||
key={`${data.TxHash}${i}`}
|
key={`${data.TxHash}${i}`}
|
||||||
age={data.Age}
|
age={data.Age}
|
||||||
|
|
@ -33,7 +34,8 @@ class TransactionTable extends Component {
|
||||||
to={data.To}
|
to={data.To}
|
||||||
from={data.From}
|
from={data.From}
|
||||||
value={data.Amount}
|
value={data.Amount}
|
||||||
cost={data.Cost}
|
cost={conversion}
|
||||||
|
getBlockTransactions={this.props.getBlockTransactions}
|
||||||
detailTransactionHandler={this.props.detailTransactionHandler}
|
detailTransactionHandler={this.props.detailTransactionHandler}
|
||||||
detailAccountHandler={this.props.detailAccountHandler}
|
detailAccountHandler={this.props.detailAccountHandler}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ const TransactionTable = (props) => {
|
||||||
<Link to="/transaction/details" className={flag ? "" : classes.disabled} onClick={() => props.detailTransactionHandler(props.txHash)}>
|
<Link to="/transaction/details" className={flag ? "" : classes.disabled} onClick={() => props.detailTransactionHandler(props.txHash)}>
|
||||||
{props.txHash}</Link>
|
{props.txHash}</Link>
|
||||||
</td>
|
</td>
|
||||||
<td>{props.blockNumber}</td>
|
<td><Link to="/block/transactions" onClick={() => props.getBlockTransactions(props.blockNumber)}>{props.blockNumber}</Link></td>
|
||||||
<td>{props.age}</td>
|
<td>{props.age}</td>
|
||||||
<td className={flag ? classes.fromTag : classes.disabled }><Link to="/account/detail" onClick={() => props.detailAccountHandler(props.from)}>{props.from}</Link></td>
|
<td className={flag ? classes.fromTag : classes.disabled }><Link to="/account/detail" onClick={() => props.detailAccountHandler(props.from)}>{props.from}</Link></td>
|
||||||
<td><img className={classes.arrow} src={arrow} alt="arrow"/></td>
|
<td><img className={classes.arrow} src={arrow} alt="arrow"/></td>
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@ import TransactionRow from '../components/table/transactions/transactionRow';
|
||||||
import TransactionHeader from "../components/nav/transactionHeader/transactionHeader";
|
import TransactionHeader from "../components/nav/transactionHeader/transactionHeader";
|
||||||
import TransactionDetailHeader from "../components/nav/transactionHeader/transactionDetailHeader";
|
import TransactionDetailHeader from "../components/nav/transactionHeader/transactionDetailHeader";
|
||||||
import DetailTransactionTable from "../components/table/transactions/transactionDetailsRow";
|
import DetailTransactionTable from "../components/table/transactions/transactionDetailsRow";
|
||||||
|
import BlockTxs from "../components/table/transactions/blockTx";
|
||||||
|
|
||||||
///**BLOCKS**///
|
///**BLOCKS**///
|
||||||
import BlocksRow from '../components/table/blocks/blockRows';
|
import BlocksRow from '../components/table/blocks/blockRows';
|
||||||
import DetailBlockTable from '../components/table/blocks/blocksDetailsRow';
|
import DetailBlockTable from '../components/table/blocks/blocksDetailsRow';
|
||||||
|
|
@ -31,6 +33,7 @@ class App extends Component {
|
||||||
blockDetailData: [],
|
blockDetailData: [],
|
||||||
transactionDetailData: [],
|
transactionDetailData: [],
|
||||||
accountDetailData: [],
|
accountDetailData: [],
|
||||||
|
blockTransactions: [],
|
||||||
reqAccount: ''
|
reqAccount: ''
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -65,6 +68,16 @@ class App extends Component {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
getBlockTransactions = async(blockNumber) => {
|
||||||
|
try {
|
||||||
|
const response = await axios.get(`http://localhost:8080/api/get_all_transactions_from_block/${blockNumber}`)
|
||||||
|
await this.setState({ blockTransactions: response.data })
|
||||||
|
}
|
||||||
|
catch(error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
|
|
@ -79,6 +92,7 @@ class App extends Component {
|
||||||
<div>
|
<div>
|
||||||
<TransactionHeader />
|
<TransactionHeader />
|
||||||
<TransactionRow
|
<TransactionRow
|
||||||
|
getBlockTransactions={this.getBlockTransactions}
|
||||||
detailTransactionHandler={this.detailTransactionHandler}
|
detailTransactionHandler={this.detailTransactionHandler}
|
||||||
detailAccountHandler={this.detailAccountHandler}/>
|
detailAccountHandler={this.detailAccountHandler}/>
|
||||||
</div>}
|
</div>}
|
||||||
|
|
@ -87,7 +101,9 @@ class App extends Component {
|
||||||
<Route path="/blocks" exact render={({match}) =>
|
<Route path="/blocks" exact render={({match}) =>
|
||||||
<div>
|
<div>
|
||||||
<BlockHeader/>
|
<BlockHeader/>
|
||||||
<BlocksRow detailBlockHandler={this.detailBlockHandler}/>
|
<BlocksRow
|
||||||
|
getBlockTransactions={this.getBlockTransactions}
|
||||||
|
detailBlockHandler={this.detailBlockHandler}/>
|
||||||
</div>}
|
</div>}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
@ -112,10 +128,24 @@ class App extends Component {
|
||||||
<BlockDetailHeader
|
<BlockDetailHeader
|
||||||
blockNumber={this.state.blockDetailData.Number}/>
|
blockNumber={this.state.blockDetailData.Number}/>
|
||||||
<DetailBlockTable
|
<DetailBlockTable
|
||||||
|
getBlockTransactions={this.getBlockTransactions}
|
||||||
data={this.state.blockDetailData}/>
|
data={this.state.blockDetailData}/>
|
||||||
</div>}
|
</div>}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<Route path="/block/transactions" exact render={({match}) =>
|
||||||
|
<div>
|
||||||
|
{/*<BlockDetailHeader*/}
|
||||||
|
{/*blockNumber={this.state.blockTransactions.BlockNumber}/>*/}
|
||||||
|
<BlockTxs
|
||||||
|
data={this.state.blockTransactions}
|
||||||
|
getBlockTransactions={this.getBlockTransactions}
|
||||||
|
detailTransactionHandler={this.detailTransactionHandler}
|
||||||
|
detailAccountHandler={this.detailAccountHandler}/>
|
||||||
|
|
||||||
|
</div>}
|
||||||
|
/>
|
||||||
|
|
||||||
<Route path="/account/detail" exact render={({match}) =>
|
<Route path="/account/detail" exact render={({match}) =>
|
||||||
<div>
|
<div>
|
||||||
<AccountDetailHeader
|
<AccountDetailHeader
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ CREATE TABLE IF NOT EXISTS blocks (
|
||||||
difficulty bigint,
|
difficulty bigint,
|
||||||
size text,
|
size text,
|
||||||
nonce numeric,
|
nonce numeric,
|
||||||
|
rewards numeric,
|
||||||
number bigint
|
number bigint
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ type SBlock struct {
|
||||||
Difficulty string
|
Difficulty string
|
||||||
Size string
|
Size string
|
||||||
Nonce string
|
Nonce string
|
||||||
|
Rewards string
|
||||||
}
|
}
|
||||||
|
|
||||||
//blockRes struct
|
//blockRes struct
|
||||||
|
|
@ -104,12 +105,7 @@ type SendAndReceive struct {
|
||||||
|
|
||||||
//WriteBlock writes to block info to sql db
|
//WriteBlock writes to block info to sql db
|
||||||
func WriteBlock(sqldb *sql.DB, block *types.Block, receipts []*types.Receipt) error {
|
func WriteBlock(sqldb *sql.DB, block *types.Block, receipts []*types.Receipt) error {
|
||||||
//Need to create field in postgres db isContract : True || False
|
rewards := WriteMinerRewards(sqldb,block)
|
||||||
//Need to fix nonce numeric issue (attempt to reproduce and record)
|
|
||||||
//Need to update tx To Field where null with Contract Address
|
|
||||||
//Need to update account table with that Contract Address
|
|
||||||
//Need to update AccountNonce and Balance of Tx To field || Contract Address
|
|
||||||
WriteMinerRewards(sqldb,block)
|
|
||||||
coinbase := block.Header().Coinbase.String()
|
coinbase := block.Header().Coinbase.String()
|
||||||
number := block.Header().Number.String()
|
number := block.Header().Number.String()
|
||||||
gasUsed := block.Header().GasUsed
|
gasUsed := block.Header().GasUsed
|
||||||
|
|
@ -128,15 +124,14 @@ func WriteBlock(sqldb *sql.DB, block *types.Block, receipts []*types.Receipt) er
|
||||||
}
|
}
|
||||||
age := time.Unix(i, 0)
|
age := time.Unix(i, 0)
|
||||||
|
|
||||||
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`
|
sqlStatement := `INSERT INTO blocks(hash, coinbase, number, gasUsed, gasLimit, txCount, uncleCount, age, parentHash, uncleHash, difficulty, size, rewards, nonce) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10), ($11), ($12),($13), ($14)) RETURNING number`
|
||||||
qerr := sqldb.QueryRow(sqlStatement, block.Header().Hash().Hex(), coinbase, number, gasUsed, gasLimit, txCount, uncleCount, age, parentHash, uncleHash, blockDifficulty, blockSize, blockNonce).Scan(&number)
|
qerr := sqldb.QueryRow(sqlStatement, block.Header().Hash().Hex(), coinbase, number, gasUsed, gasLimit, txCount, uncleCount, age, parentHash, uncleHash, blockDifficulty, blockSize, rewards, blockNonce).Scan(&number)
|
||||||
if qerr != nil {
|
if qerr != nil {
|
||||||
panic(qerr)
|
panic(qerr)
|
||||||
}
|
}
|
||||||
|
|
||||||
if block.Transactions().Len() > 0 {
|
if block.Transactions().Len() > 0 {
|
||||||
for _, tx := range block.Transactions() {
|
for _, tx := range block.Transactions() {
|
||||||
//WriteMinerRewards(sqldb, block)
|
|
||||||
WriteTransactions(sqldb, tx, block.Header().Hash(), block.Header().Number.String(), receipts, age, gasLimit)
|
WriteTransactions(sqldb, tx, block.Header().Hash(), block.Header().Number.String(), receipts, age, gasLimit)
|
||||||
if block.Transactions()[0].To() != nil {
|
if block.Transactions()[0].To() != nil {
|
||||||
WriteFromBalance(sqldb, tx)
|
WriteFromBalance(sqldb, tx)
|
||||||
|
|
@ -411,7 +406,7 @@ func WriteBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, s
|
||||||
// uncle blocks, account balance updates based on reorgs, diverges that get dropped.
|
// uncle blocks, account balance updates based on reorgs, diverges that get dropped.
|
||||||
// Reason for this is because the accounts are not deterministic like the block and tx hashes.
|
// Reason for this is because the accounts are not deterministic like the block and tx hashes.
|
||||||
// @TODO: Calculate reorg
|
// @TODO: Calculate reorg
|
||||||
func WriteMinerRewards(sqldb *sql.DB, block *types.Block) {
|
func WriteMinerRewards(sqldb *sql.DB, block *types.Block) string {
|
||||||
minerAddr := block.Coinbase().String()
|
minerAddr := block.Coinbase().String()
|
||||||
shyftConduitAddress := Rewards.ShyftNetworkConduitAddress.String()
|
shyftConduitAddress := Rewards.ShyftNetworkConduitAddress.String()
|
||||||
// Calculate the total gas used in the block
|
// Calculate the total gas used in the block
|
||||||
|
|
@ -443,9 +438,18 @@ func WriteMinerRewards(sqldb *sql.DB, block *types.Block) {
|
||||||
|
|
||||||
StoreReward(sqldb, minerAddr, totalMinerReward)
|
StoreReward(sqldb, minerAddr, totalMinerReward)
|
||||||
StoreReward(sqldb, shyftConduitAddress, Rewards.ShyftNetworkBlockReward)
|
StoreReward(sqldb, shyftConduitAddress, Rewards.ShyftNetworkBlockReward)
|
||||||
|
var uncRewards = new(big.Int)
|
||||||
for i := 0; i < len(uncleAddrs); i++ {
|
for i := 0; i < len(uncleAddrs); i++ {
|
||||||
|
uncRewards := uncleRewards[i]
|
||||||
|
fmt.Println(uncRewards)
|
||||||
StoreReward(sqldb, uncleAddrs[i], uncleRewards[i])
|
StoreReward(sqldb, uncleAddrs[i], uncleRewards[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fullRewardValue := new(big.Int)
|
||||||
|
fullRewardValue.Add(totalMinerReward, Rewards.ShyftNetworkBlockReward)
|
||||||
|
fullRewardValue.Add(fullRewardValue, uncRewards)
|
||||||
|
|
||||||
|
return fullRewardValue.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func StoreReward(sqldb *sql.DB, address string, reward *big.Int) {
|
func StoreReward(sqldb *sql.DB, address string, reward *big.Int) {
|
||||||
|
|
@ -497,16 +501,7 @@ func GetAllBlocks(sqldb *sql.DB) string {
|
||||||
var arr blockRes
|
var arr blockRes
|
||||||
var blockArr string
|
var blockArr string
|
||||||
rows, err := sqldb.Query(`
|
rows, err := sqldb.Query(`
|
||||||
SELECT
|
SELECT * FROM blocks`)
|
||||||
hash,
|
|
||||||
coinbase,
|
|
||||||
gasused,
|
|
||||||
gaslimit,
|
|
||||||
txcount,
|
|
||||||
unclecount,
|
|
||||||
age,
|
|
||||||
number
|
|
||||||
FROM blocks`)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("err")
|
fmt.Println("err")
|
||||||
}
|
}
|
||||||
|
|
@ -520,6 +515,12 @@ func GetAllBlocks(sqldb *sql.DB) string {
|
||||||
var txCount string
|
var txCount string
|
||||||
var uncleCount string
|
var uncleCount string
|
||||||
var age string
|
var age string
|
||||||
|
var parentHash string
|
||||||
|
var uncleHash string
|
||||||
|
var difficulty string
|
||||||
|
var size string
|
||||||
|
var nonce string
|
||||||
|
var rewards string
|
||||||
var num string
|
var num string
|
||||||
|
|
||||||
err = rows.Scan(
|
err = rows.Scan(
|
||||||
|
|
@ -530,8 +531,13 @@ func GetAllBlocks(sqldb *sql.DB) string {
|
||||||
&txCount,
|
&txCount,
|
||||||
&uncleCount,
|
&uncleCount,
|
||||||
&age,
|
&age,
|
||||||
&num,
|
&parentHash,
|
||||||
)
|
&uncleHash,
|
||||||
|
&difficulty,
|
||||||
|
&size,
|
||||||
|
&nonce,
|
||||||
|
&rewards,
|
||||||
|
&num,)
|
||||||
|
|
||||||
arr.Blocks = append(arr.Blocks, SBlock{
|
arr.Blocks = append(arr.Blocks, SBlock{
|
||||||
Hash: hash,
|
Hash: hash,
|
||||||
|
|
@ -541,6 +547,12 @@ func GetAllBlocks(sqldb *sql.DB) string {
|
||||||
TxCount: txCount,
|
TxCount: txCount,
|
||||||
UncleCount: uncleCount,
|
UncleCount: uncleCount,
|
||||||
Age: age,
|
Age: age,
|
||||||
|
ParentHash:parentHash,
|
||||||
|
UncleHash:uncleHash,
|
||||||
|
Difficulty:difficulty,
|
||||||
|
Size: size,
|
||||||
|
Nonce:nonce,
|
||||||
|
Rewards: rewards,
|
||||||
Number: num,
|
Number: num,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -568,6 +580,7 @@ func GetBlock(sqldb *sql.DB, blockNumber string) string {
|
||||||
var difficulty string
|
var difficulty string
|
||||||
var size string
|
var size string
|
||||||
var nonce string
|
var nonce string
|
||||||
|
var rewards string
|
||||||
var num string
|
var num string
|
||||||
row.Scan(
|
row.Scan(
|
||||||
&hash,
|
&hash,
|
||||||
|
|
@ -582,6 +595,7 @@ func GetBlock(sqldb *sql.DB, blockNumber string) string {
|
||||||
&difficulty,
|
&difficulty,
|
||||||
&size,
|
&size,
|
||||||
&nonce,
|
&nonce,
|
||||||
|
&rewards,
|
||||||
&num,)
|
&num,)
|
||||||
|
|
||||||
block := SBlock{
|
block := SBlock{
|
||||||
|
|
@ -597,6 +611,7 @@ func GetBlock(sqldb *sql.DB, blockNumber string) string {
|
||||||
Difficulty:difficulty,
|
Difficulty:difficulty,
|
||||||
Size: size,
|
Size: size,
|
||||||
Nonce:nonce,
|
Nonce:nonce,
|
||||||
|
Rewards: rewards,
|
||||||
Number: num,
|
Number: num,
|
||||||
}
|
}
|
||||||
json, _ := json.Marshal(block)
|
json, _ := json.Marshal(block)
|
||||||
|
|
@ -618,6 +633,7 @@ func GetRecentBlock(sqldb *sql.DB) string {
|
||||||
var difficulty string
|
var difficulty string
|
||||||
var size string
|
var size string
|
||||||
var nonce string
|
var nonce string
|
||||||
|
var rewards string
|
||||||
var num string
|
var num string
|
||||||
row.Scan(
|
row.Scan(
|
||||||
&hash,
|
&hash,
|
||||||
|
|
@ -632,6 +648,7 @@ func GetRecentBlock(sqldb *sql.DB) string {
|
||||||
&difficulty,
|
&difficulty,
|
||||||
&size,
|
&size,
|
||||||
&nonce,
|
&nonce,
|
||||||
|
&rewards,
|
||||||
&num,)
|
&num,)
|
||||||
|
|
||||||
block := SBlock{
|
block := SBlock{
|
||||||
|
|
@ -647,6 +664,7 @@ func GetRecentBlock(sqldb *sql.DB) string {
|
||||||
Difficulty:difficulty,
|
Difficulty:difficulty,
|
||||||
Size: size,
|
Size: size,
|
||||||
Nonce:nonce,
|
Nonce:nonce,
|
||||||
|
Rewards: rewards,
|
||||||
Number: num,
|
Number: num,
|
||||||
}
|
}
|
||||||
json, _ := json.Marshal(block)
|
json, _ := json.Marshal(block)
|
||||||
|
|
@ -656,7 +674,7 @@ func GetRecentBlock(sqldb *sql.DB) string {
|
||||||
func GetAllTransactionsFromBlock(sqldb *sql.DB, blockNumber string) string {
|
func GetAllTransactionsFromBlock(sqldb *sql.DB, blockNumber string) string {
|
||||||
var arr txRes
|
var arr txRes
|
||||||
var txx string
|
var txx string
|
||||||
sqlStatement := `SELECT * FROM txs WHERE blockNumber=$1`
|
sqlStatement := `SELECT * FROM txs WHERE blocknumber=$1`
|
||||||
rows, err := sqldb.Query(sqlStatement, blockNumber)
|
rows, err := sqldb.Query(sqlStatement, blockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("err")
|
fmt.Println("err")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue