Go-Ethereum

我如何將一半的挖礦獎勵轉移到一個地址?

  • July 12, 2018

創建一個需要分配一半挖礦費用的 dapp 應該去一個地址。

我設法減少了挖礦和區塊獎勵:

共識.go

   // Accumulate the rewards for the miner and any included uncles
   reward := new(big.Int).Set(blockReward)
   rew := new(big.Int).Set(blockReward)
   r := new(big.Int)
   for _, uncle := range uncles {
       r.Add(uncle.Number, big8)
       r.Sub(r, header.Number)
       r.Mul(r, blockReward)
       r.Div(r, big8)
       state.AddBalance(uncle.Coinbase, r)

       r.Div(blockReward, big32)
       reward.Add(reward, r)
   }

   changedRew := new(big.Int).Set(rew) // half reward
   changedRew.Div(changedRew, big.NewInt(2))
   log.Warn("Mining block reward status .. ", "CHANGED", changedRew )
   state.AddBalance(header.Coinbase, changedRew)
}

state_transition.go

       if vmerr == vm.ErrInsufficientBalance {
           return nil, 0, false, vmerr
       }
   }
   st.refundGas()
   log.Warn("Half fee taken away ")
   // change price 
   st.state.AddBalance(st.evm.Coinbase, changedRew.Div(new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), st.gasPrice), big.NewInt(2)))

   return ret, st.gasUsed(), vmerr != nil, err
}

我現在如何將另一半轉移到一個地址?如果我指定要轉移的帳戶/地址,則可以輕鬆更改而不影響阻止規則。我怎樣才能安全地做到這一點?

PS:每個節點只需一個賬戶固定賬戶,即可轉出一半的挖礦費。

就這麼簡單:

the_other_half_addr:=common.HexToAddress("0xlajfklsadjflsafjklsadjdflkadjfl")
state.AddBalance(the_other_half_addr,changedRew)

你做得很安全,但你也忘了從叔叔那裡拿一半。

引用自:https://ethereum.stackexchange.com/questions/53262