mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
fix merge
This commit is contained in:
commit
c5b3b93fb4
10 changed files with 80 additions and 89 deletions
|
|
@ -38,7 +38,6 @@ import (
|
|||
"github.com/ethereum/go-ethereum/trie"
|
||||
"github.com/syndtr/goleveldb/leveldb/util"
|
||||
"gopkg.in/urfave/cli.v1"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -169,13 +168,7 @@ func initGenesis(ctx *cli.Context) error {
|
|||
if err != nil {
|
||||
utils.Fatalf("Failed to open database: %v", err)
|
||||
}
|
||||
// @NOTE:shyft instantiate BlockExplorerDB here
|
||||
connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
||||
blockExplorerDb, err := sql.Open("postgres", connStr)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
_, hash, err := core.SetupGenesisBlock(chaindb, genesis, blockExplorerDb)
|
||||
_, hash, err := core.SetupGenesisBlock(chaindb, genesis)
|
||||
if err != nil {
|
||||
utils.Fatalf("Failed to write genesis block: %v", err)
|
||||
}
|
||||
|
|
@ -321,6 +314,7 @@ func copyDb(ctx *cli.Context) error {
|
|||
|
||||
syncmode := *utils.GlobalTextMarshaler(ctx, utils.SyncModeFlag.Name).(*downloader.SyncMode)
|
||||
dl := downloader.New(syncmode, chainDb, new(event.TypeMux), chain, nil, nil)
|
||||
|
||||
// Create a source peer to satisfy downloader requests from
|
||||
db, err := ethdb.NewLDBDatabase(ctx.Args().First(), ctx.GlobalInt(utils.CacheFlag.Name), 256)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -57,9 +57,6 @@ import (
|
|||
"github.com/ethereum/go-ethereum/params"
|
||||
whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
|
||||
"gopkg.in/urfave/cli.v1"
|
||||
|
||||
// @shyft
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -1219,7 +1216,7 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai
|
|||
var err error
|
||||
chainDb = MakeChainDatabase(ctx, stack)
|
||||
|
||||
config, _, err := core.SetupGenesisBlock(chainDb, MakeGenesis(ctx), nil)
|
||||
config, _, err := core.SetupGenesisBlock(chainDb, MakeGenesis(ctx))
|
||||
if err != nil {
|
||||
Fatalf("%v", err)
|
||||
}
|
||||
|
|
@ -1252,14 +1249,8 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai
|
|||
}
|
||||
vmcfg := vm.Config{EnablePreimageRecording: ctx.GlobalBool(VMEnableDebugFlag.Name)}
|
||||
|
||||
// @NOTE:shyft instantiate BlockExplorerDB here?
|
||||
connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
||||
blockExplorerDb, err := sql.Open("postgres", connStr)
|
||||
if err != nil {
|
||||
return nil, nil
|
||||
}
|
||||
fmt.Println("Calling NewBlock CHAIN in flags.go ******************************")
|
||||
chain, err = core.NewBlockChain(chainDb, blockExplorerDb,cache, config, engine, vmcfg)
|
||||
chain, err = core.NewBlockChain(chainDb,cache, config, engine, vmcfg)
|
||||
if err != nil {
|
||||
Fatalf("Can't create BlockChain: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ import (
|
|||
"github.com/ethereum/go-ethereum/core/state"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
set "gopkg.in/fatih/set.v0"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -46,9 +46,6 @@ import (
|
|||
"github.com/ethereum/go-ethereum/trie"
|
||||
"github.com/hashicorp/golang-lru"
|
||||
"gopkg.in/karalabe/cookiejar.v2/collections/prque"
|
||||
|
||||
// @shyft
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -96,7 +93,6 @@ type BlockChain struct {
|
|||
cacheConfig *CacheConfig // Cache configuration for pruning
|
||||
|
||||
db ethdb.Database // Low level persistent database to store final content in
|
||||
blockExplorerDb *sql.DB
|
||||
|
||||
triegc *prque.Prque // Priority queue mapping block numbers to tries to gc
|
||||
gcproc time.Duration // Accumulates canonical block processing for trie dumping
|
||||
|
|
@ -141,7 +137,7 @@ type BlockChain struct {
|
|||
// NewBlockChain returns a fully initialised block chain using information
|
||||
// available in the database. It initialises the default Ethereum Validator and
|
||||
// Processor.
|
||||
func NewBlockChain(db ethdb.Database, blockExplorerDb *sql.DB, cacheConfig *CacheConfig, chainConfig *params.ChainConfig, engine consensus.Engine, vmConfig vm.Config) (*BlockChain, error) {
|
||||
func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *params.ChainConfig, engine consensus.Engine, vmConfig vm.Config) (*BlockChain, error) {
|
||||
if cacheConfig == nil {
|
||||
cacheConfig = &CacheConfig{
|
||||
TrieNodeLimit: 256 * 1024 * 1024,
|
||||
|
|
@ -158,7 +154,6 @@ func NewBlockChain(db ethdb.Database, blockExplorerDb *sql.DB, cacheConfig *Cach
|
|||
chainConfig: chainConfig,
|
||||
cacheConfig: cacheConfig,
|
||||
db: db,
|
||||
blockExplorerDb: blockExplorerDb,
|
||||
triegc: prque.New(),
|
||||
stateCache: state.NewDatabase(db),
|
||||
quit: make(chan struct{}),
|
||||
|
|
@ -907,7 +902,7 @@ func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types.
|
|||
return NonStatTy, err
|
||||
}
|
||||
// @NOTE:SHYFT - Write block data for block explorer
|
||||
if err := shyftdb.WriteBlock(bc.blockExplorerDb, block, receipts); err != nil {
|
||||
if err := shyftdb.WriteBlock(block, receipts); err != nil {
|
||||
return NonStatTy, err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,9 +28,6 @@ import (
|
|||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
|
||||
// @shyft
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
// So we can deterministically seed different blockchains
|
||||
|
|
@ -169,9 +166,7 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse
|
|||
genblock := func(i int, parent *types.Block, statedb *state.StateDB) (*types.Block, types.Receipts) {
|
||||
// TODO(karalabe): This is needed for clique, which depends on multiple blocks.
|
||||
// It's nonetheless ugly to spin up a blockchain here. Get rid of this somehow.
|
||||
connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
||||
blockExplorerDb, _ := sql.Open("postgres", connStr)
|
||||
blockchain, _ := NewBlockChain(db, blockExplorerDb,nil, config, engine, vm.Config{})
|
||||
blockchain, _ := NewBlockChain(db, nil, config, engine, vm.Config{})
|
||||
defer blockchain.Stop()
|
||||
|
||||
b := &BlockGen{i: i, parent: parent, chain: blocks, chainReader: blockchain, statedb: statedb, config: config, engine: engine}
|
||||
|
|
@ -253,9 +248,7 @@ func newCanonical(engine consensus.Engine, n int, full bool) (ethdb.Database, *B
|
|||
gspec := new(Genesis)
|
||||
db, _ := ethdb.NewMemDatabase()
|
||||
genesis := gspec.MustCommit(db)
|
||||
connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
||||
blockExplorerDb, _ := sql.Open("postgres", connStr)
|
||||
blockchain, _ := NewBlockChain(db, blockExplorerDb, nil, params.AllEthashProtocolChanges, engine, vm.Config{})
|
||||
blockchain, _ := NewBlockChain(db, nil, params.AllEthashProtocolChanges, engine, vm.Config{})
|
||||
// Create and inject the requested chain
|
||||
if n == 0 {
|
||||
return db, blockchain, nil
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ethereum/go-ethereum/shyftdb"
|
||||
"database/sql"
|
||||
"strconv"
|
||||
"time"
|
||||
|
|
@ -142,13 +143,9 @@ func (e *GenesisMismatchError) Error() string {
|
|||
|
||||
//WriteShyftGen writes the genesis block to Shyft db
|
||||
//@NOTE:SHYFT
|
||||
func WriteShyftGen(sqldb *sql.DB, gen *Genesis, block *types.Block) {
|
||||
if sqldb == nil {
|
||||
log.Info("Initializing Shyft Postgres DB")
|
||||
connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
||||
blockExplorerDb, _ := sql.Open("postgres", connStr)
|
||||
sqldb = blockExplorerDb
|
||||
}
|
||||
func WriteShyftGen(gen *Genesis, block *types.Block) {
|
||||
|
||||
sqldb, _ := shyftdb.DBConnection()
|
||||
|
||||
for k := range gen.Alloc {
|
||||
addr := k.String()
|
||||
|
|
@ -196,13 +193,9 @@ func WriteShyftGen(sqldb *sql.DB, gen *Genesis, block *types.Block) {
|
|||
log.Info("Found Genesis Block")
|
||||
}}}
|
||||
|
||||
func WriteShyftBlockZero(sqldb *sql.DB, block *types.Block, gen *Genesis) error {
|
||||
if sqldb == nil {
|
||||
log.Info("Initializing Shyft Postgres DB")
|
||||
connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
||||
blockExplorerDb, _ := sql.Open("postgres", connStr)
|
||||
sqldb = blockExplorerDb
|
||||
}
|
||||
func WriteShyftBlockZero(block *types.Block, gen *Genesis) error {
|
||||
|
||||
sqldb, _ := shyftdb.DBConnection()
|
||||
|
||||
coinbase := block.Header().Coinbase.String()
|
||||
number := block.Header().Number.String()
|
||||
|
|
@ -252,7 +245,7 @@ func WriteShyftBlockZero(sqldb *sql.DB, block *types.Block, gen *Genesis) error
|
|||
// error is a *params.ConfigCompatError and the new, unwritten config is returned.
|
||||
//
|
||||
// The returned chain configuration is never nil.
|
||||
func SetupGenesisBlock(db ethdb.Database, genesis *Genesis, sqldb *sql.DB) (*params.ChainConfig, common.Hash, error) {
|
||||
func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig, common.Hash, error) {
|
||||
if genesis != nil && genesis.Config == nil {
|
||||
return params.AllEthashProtocolChanges, common.Hash{}, errGenesisNoConfig
|
||||
}
|
||||
|
|
@ -267,9 +260,9 @@ func SetupGenesisBlock(db ethdb.Database, genesis *Genesis, sqldb *sql.DB) (*par
|
|||
}
|
||||
block, err := genesis.Commit(db)
|
||||
//@NOTE:SHYFT WRITE TO BLOCK ZERO DB
|
||||
WriteShyftBlockZero(sqldb, block, genesis)
|
||||
WriteShyftBlockZero(block, genesis)
|
||||
//@NOTE:SHYFT WRITE TO DB
|
||||
WriteShyftGen(sqldb, genesis, block)
|
||||
WriteShyftGen(genesis, block)
|
||||
|
||||
return genesis.Config, block.Hash(), err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,9 +47,6 @@ import (
|
|||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
|
||||
// @shyft
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type LesServer interface {
|
||||
|
|
@ -76,7 +73,6 @@ type Ethereum struct {
|
|||
|
||||
// DB interfaces
|
||||
chainDb ethdb.Database // Block chain database
|
||||
blockExplorerDb *sql.DB
|
||||
|
||||
eventMux *event.TypeMux
|
||||
engine consensus.Engine
|
||||
|
|
@ -116,16 +112,10 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// @NOTE:shyft instantiate BlockExplorerDB here
|
||||
// @TODO: Create Genesis Block
|
||||
// @NOTE:shyft instantiate BlockExplorerDB here?
|
||||
connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
||||
blockExplorerDb, err := sql.Open("postgres", connStr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
stopDbUpgrade := upgradeDeduplicateData(chainDb)
|
||||
chainConfig, genesisHash, genesisErr := core.SetupGenesisBlock(chainDb, config.Genesis, blockExplorerDb)
|
||||
chainConfig, genesisHash, genesisErr := core.SetupGenesisBlock(chainDb, config.Genesis)
|
||||
if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok {
|
||||
return nil, genesisErr
|
||||
}
|
||||
|
|
@ -134,7 +124,6 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
|||
eth := &Ethereum{
|
||||
config: config,
|
||||
chainDb: chainDb,
|
||||
blockExplorerDb: blockExplorerDb,
|
||||
chainConfig: chainConfig,
|
||||
eventMux: ctx.EventMux,
|
||||
accountManager: ctx.AccountManager,
|
||||
|
|
@ -161,7 +150,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
|||
vmConfig = vm.Config{EnablePreimageRecording: config.EnablePreimageRecording}
|
||||
cacheConfig = &core.CacheConfig{Disabled: config.NoPruning, TrieNodeLimit: config.TrieCache, TrieTimeLimit: config.TrieTimeout}
|
||||
)
|
||||
eth.blockchain, err = core.NewBlockChain(chainDb, blockExplorerDb, cacheConfig, eth.chainConfig, eth.engine, vmConfig)
|
||||
eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, eth.chainConfig, eth.engine, vmConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ func New(ctx *node.ServiceContext, config *eth.Config) (*LightEthereum, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
chainConfig, genesisHash, genesisErr := core.SetupGenesisBlock(chainDb, config.Genesis, nil)
|
||||
chainConfig, genesisHash, genesisErr := core.SetupGenesisBlock(chainDb, config.Genesis)
|
||||
if _, isCompat := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !isCompat {
|
||||
return nil, genesisErr
|
||||
}
|
||||
|
|
|
|||
31
shyftDb/db.go
Normal file
31
shyftDb/db.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package shyftdb
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
var blockExplorerDb *sql.DB
|
||||
|
||||
func InitDB() (*sql.DB, error){
|
||||
connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
||||
db, err := sql.Open("postgres", connStr)
|
||||
if err != nil {
|
||||
fmt.Println("ERROR OPENING DB, NOT INITIALIZING")
|
||||
fmt.Println(err)
|
||||
return nil, err
|
||||
} else {
|
||||
blockExplorerDb = db
|
||||
return blockExplorerDb, nil
|
||||
}
|
||||
}
|
||||
|
||||
func DBConnection() (*sql.DB, error) {
|
||||
if (blockExplorerDb == nil) {
|
||||
_, err := InitDB()
|
||||
if(err != nil) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return blockExplorerDb, nil
|
||||
}
|
||||
|
|
@ -104,8 +104,14 @@ type SendAndReceive struct {
|
|||
}
|
||||
|
||||
//WriteBlock writes to block info to sql db
|
||||
func WriteBlock(sqldb *sql.DB, block *types.Block, receipts []*types.Receipt) error {
|
||||
rewards := WriteMinerRewards(sqldb,block)
|
||||
func WriteBlock(block *types.Block, receipts []*types.Receipt) error {
|
||||
|
||||
sqldb, err := DBConnection()
|
||||
if (err != nil) {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
rewards := writeMinerRewards(sqldb,block)
|
||||
coinbase := block.Header().Coinbase.String()
|
||||
number := block.Header().Number.String()
|
||||
gasUsed := block.Header().GasUsed
|
||||
|
|
@ -132,21 +138,21 @@ func WriteBlock(sqldb *sql.DB, block *types.Block, receipts []*types.Receipt) er
|
|||
|
||||
if block.Transactions().Len() > 0 {
|
||||
for _, tx := range block.Transactions() {
|
||||
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 {
|
||||
WriteFromBalance(sqldb, tx)
|
||||
writeFromBalance(sqldb, tx)
|
||||
}
|
||||
if block.Transactions()[0].To() == nil {
|
||||
WriteContractBalance(sqldb, tx)
|
||||
WriteContractsTxHashReferences(sqldb, tx)
|
||||
writeContractBalance(sqldb, tx)
|
||||
writeContractsTxHashReferences(sqldb, tx)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//WriteTransactions writes to sqldb
|
||||
func WriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Hash, blockNumber string, receipts []*types.Receipt, age time.Time, gasLimit uint64) error {
|
||||
//writeTransactions writes to sqldb
|
||||
func writeTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Hash, blockNumber string, receipts []*types.Receipt, age time.Time, gasLimit uint64) error {
|
||||
txData := ShyftTxEntry{
|
||||
TxHash: tx.Hash(),
|
||||
From: tx.From(),
|
||||
|
|
@ -217,7 +223,7 @@ func WriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Ha
|
|||
return nil
|
||||
}
|
||||
|
||||
func WriteContractsTxHashReferences(sqldb *sql.DB, tx *types.Transaction) error {
|
||||
func writeContractsTxHashReferences(sqldb *sql.DB, tx *types.Transaction) error {
|
||||
txHash := tx.Hash().Hex()
|
||||
|
||||
sqlStatement := `INSERT INTO contracts(txHash) VALUES(($1)) RETURNING txHash`
|
||||
|
|
@ -228,8 +234,8 @@ func WriteContractsTxHashReferences(sqldb *sql.DB, tx *types.Transaction) error
|
|||
return nil
|
||||
}
|
||||
|
||||
func WriteContractBalance(sqldb *sql.DB, tx *types.Transaction) error {
|
||||
sendAndReceiveData,balanceSen,accountNonceSen := WriteContractBalanceHelper(sqldb, tx)
|
||||
func writeContractBalance(sqldb *sql.DB, tx *types.Transaction) error {
|
||||
sendAndReceiveData,balanceSen,accountNonceSen := writeContractBalanceHelper(sqldb, tx)
|
||||
fromAddr := sendAndReceiveData.From
|
||||
amount := sendAndReceiveData.Amount
|
||||
balanceSender := balanceSen
|
||||
|
|
@ -275,7 +281,7 @@ func WriteContractBalance(sqldb *sql.DB, tx *types.Transaction) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func WriteContractBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, string, string) {
|
||||
func writeContractBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, string, string) {
|
||||
sendAndReceiveData := SendAndReceive{
|
||||
From: tx.From().Hex(),
|
||||
Amount: tx.Value().String(),
|
||||
|
|
@ -294,9 +300,9 @@ func WriteContractBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndRe
|
|||
return sendAndReceiveData, balanceSender, accountNonceSender
|
||||
}
|
||||
|
||||
//WriteFromBalance writes senders balance to accounts db
|
||||
func WriteFromBalance(sqldb *sql.DB, tx *types.Transaction) error {
|
||||
sendAndReceiveData, balanceRec, balanceSen, accountNonceRec, accountNonceSen := WriteBalanceHelper(sqldb, tx)
|
||||
//writeFromBalance writes senders balance to accounts db
|
||||
func writeFromBalance(sqldb *sql.DB, tx *types.Transaction) error {
|
||||
sendAndReceiveData, balanceRec, balanceSen, accountNonceRec, accountNonceSen := writeBalanceHelper(sqldb, tx)
|
||||
toAddr := sendAndReceiveData.To
|
||||
fromAddr := sendAndReceiveData.From
|
||||
amount := sendAndReceiveData.Amount
|
||||
|
|
@ -370,7 +376,7 @@ func WriteFromBalance(sqldb *sql.DB, tx *types.Transaction) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func WriteBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, string, string, string, string) {
|
||||
func writeBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, string, string, string, string) {
|
||||
sendAndReceiveData := SendAndReceive{
|
||||
To: tx.To().Hex(),
|
||||
From: tx.From().Hex(),
|
||||
|
|
@ -406,7 +412,7 @@ func WriteBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, s
|
|||
// 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.
|
||||
// @TODO: Calculate reorg
|
||||
func WriteMinerRewards(sqldb *sql.DB, block *types.Block) string {
|
||||
func writeMinerRewards(sqldb *sql.DB, block *types.Block) string {
|
||||
minerAddr := block.Coinbase().String()
|
||||
shyftConduitAddress := Rewards.ShyftNetworkConduitAddress.String()
|
||||
// Calculate the total gas used in the block
|
||||
|
|
@ -436,13 +442,13 @@ func WriteMinerRewards(sqldb *sql.DB, block *types.Block) string {
|
|||
uncleAddrs = append(uncleAddrs, uncle.Coinbase.String())
|
||||
}
|
||||
|
||||
StoreReward(sqldb, minerAddr, totalMinerReward)
|
||||
StoreReward(sqldb, shyftConduitAddress, Rewards.ShyftNetworkBlockReward)
|
||||
storeReward(sqldb, minerAddr, totalMinerReward)
|
||||
storeReward(sqldb, shyftConduitAddress, Rewards.ShyftNetworkBlockReward)
|
||||
var uncRewards = new(big.Int)
|
||||
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)
|
||||
|
|
@ -452,7 +458,7 @@ func WriteMinerRewards(sqldb *sql.DB, block *types.Block) string {
|
|||
return fullRewardValue.String()
|
||||
}
|
||||
|
||||
func StoreReward(sqldb *sql.DB, address string, reward *big.Int) {
|
||||
func storeReward(sqldb *sql.DB, address string, reward *big.Int) {
|
||||
// Check if address exists
|
||||
var addressBalance string
|
||||
addressExistsStatement := `SELECT balance from accounts WHERE addr = ($1)`
|
||||
|
|
|
|||
Loading…
Reference in a new issue