review fixes
This commit is contained in:
parent
185f4c0e93
commit
fd407825c1
@ -186,9 +186,9 @@ func (blockRepository BlockRepository) insertBlock(block core.Block) (int64, err
|
||||
}
|
||||
|
||||
func (blockRepository BlockRepository) createUncleRewards(tx *sqlx.Tx, blockId int64, blockHash string, mappedUncleRewards map[string]map[string]*big.Int) error {
|
||||
for miner, uncleRewards := range mappedUncleRewards {
|
||||
for minerAddr, uncleRewards := range mappedUncleRewards {
|
||||
for uncleHash, reward := range uncleRewards {
|
||||
err := blockRepository.createUncleReward(tx, blockId, blockHash, miner, uncleHash, reward.String())
|
||||
err := blockRepository.createUncleReward(tx, blockId, blockHash, minerAddr, uncleHash, reward.String())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -197,13 +197,13 @@ func (blockRepository BlockRepository) createUncleRewards(tx *sqlx.Tx, blockId i
|
||||
return nil
|
||||
}
|
||||
|
||||
func (blockRepository BlockRepository) createUncleReward(tx *sqlx.Tx, blockId int64, blockHash, miner, uncleHash, amount string) error {
|
||||
func (blockRepository BlockRepository) createUncleReward(tx *sqlx.Tx, blockId int64, blockHash, minerAddr, uncleHash, amount string) error {
|
||||
_, err := tx.Exec(
|
||||
`INSERT INTO uncle_rewards
|
||||
(block_id, block_hash, uncle_hash, uncle_reward, miner_address)
|
||||
(block_id, block_hash, miner_address, uncle_hash, uncle_reward)
|
||||
VALUES ($1, $2, $3, $4, $5)
|
||||
RETURNING id`,
|
||||
blockId, blockHash, miner, uncleHash, utilities.NullToZero(amount))
|
||||
blockId, blockHash, minerAddr, uncleHash, utilities.NullToZero(amount))
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
package repositories
|
@ -1 +0,0 @@
|
||||
package repositories
|
@ -24,6 +24,9 @@ import (
|
||||
)
|
||||
|
||||
// (U_n + 8 - B_n) * R / 8
|
||||
// https://github.com/ethereum/go-ethereum/issues/1591
|
||||
// https://ethereum.stackexchange.com/questions/27172/different-uncles-reward
|
||||
// https://github.com/ethereum/homestead-guide/issues/399
|
||||
// Returns a map of miner addresses to a map of the uncles they mined (hashes) to the rewards received for that uncle
|
||||
func CalcUnclesReward(block core.Block, uncles []*types.Header) (*big.Int, map[string]map[string]*big.Int) {
|
||||
uncleRewards := new(big.Int)
|
||||
|
Loading…
Reference in New Issue
Block a user