Fixed hard code 3 mns address only for testnet.

This commit is contained in:
DinhLN 2019-02-12 09:56:04 +07:00
parent ee026fc506
commit c2e6908f2b
2 changed files with 12 additions and 6 deletions

View file

@ -483,10 +483,16 @@ func whoIsCreator(snap *Snapshot, header *types.Header) (common.Address, error)
func (c *Posv) YourTurn(chain consensus.ChainReader, parent *types.Header, signer common.Address) (int, int, int, bool, error) { func (c *Posv) YourTurn(chain consensus.ChainReader, parent *types.Header, signer common.Address) (int, int, int, bool, error) {
masternodes := c.GetMasternodes(chain, parent) masternodes := c.GetMasternodes(chain, parent)
if common.IsTestnet { if common.IsTestnet {
// Only three mns for tomo testnet. // Only three mns hard code for tomo testnet.
masternodes = masternodes[:3] masternodes = []common.Address{
common.HexToAddress("0xfFC679Dcdf444D2eEb0491A998E7902B411CcF20"),
common.HexToAddress("0xd76fd76F7101811726DCE9E43C2617706a4c45c8"),
common.HexToAddress("0x8A97753311aeAFACfd76a68Cf2e2a9808d3e65E8"),
}
} }
snap, err := c.GetSnapshot(chain, parent) snap, err := c.GetSnapshot(chain, parent)
if err != nil { if err != nil {
log.Warn("Failed when trying to commit new work", "err", err) log.Warn("Failed when trying to commit new work", "err", err)
@ -901,7 +907,7 @@ func (c *Posv) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan
} }
// For 0-period chains, refuse to seal empty blocks (no reward but would spin sealing) // For 0-period chains, refuse to seal empty blocks (no reward but would spin sealing)
// checkpoint blocks have no tx // checkpoint blocks have no tx
if c.config.Period == 0 && len(block.Transactions()) == 0 && number % c.config.Epoch != 0 { if c.config.Period == 0 && len(block.Transactions()) == 0 && number%c.config.Epoch != 0 {
return nil, errWaitTransactions return nil, errWaitTransactions
} }
// Don't hold the signer fields for the entire sealing procedure // Don't hold the signer fields for the entire sealing procedure
@ -1023,6 +1029,7 @@ func (c *Posv) GetMasternodesFromCheckpointHeader(preCheckpointHeader *types.Hea
for i := 0; i < len(masternodes); i++ { for i := 0; i < len(masternodes); i++ {
copy(masternodes[i][:], preCheckpointHeader.Extra[extraVanity+i*common.AddressLength:]) copy(masternodes[i][:], preCheckpointHeader.Extra[extraVanity+i*common.AddressLength:])
} }
return masternodes return masternodes
} }

View file

@ -585,10 +585,10 @@ func (self *worker) commitNewWork() {
} }
// won't grasp txs at checkpoint // won't grasp txs at checkpoint
var ( var (
txs *types.TransactionsByPriceAndNonce txs *types.TransactionsByPriceAndNonce
specialTxs types.Transactions specialTxs types.Transactions
) )
if self.config.Posv != nil && header.Number.Uint64() % self.config.Posv.Epoch != 0 { if self.config.Posv != nil && header.Number.Uint64()%self.config.Posv.Epoch != 0 {
pending, err := self.eth.TxPool().Pending() pending, err := self.eth.TxPool().Pending()
if err != nil { if err != nil {
log.Error("Failed to fetch pending transactions", "err", err) log.Error("Failed to fetch pending transactions", "err", err)
@ -598,7 +598,6 @@ func (self *worker) commitNewWork() {
} }
work.commitTransactions(self.mux, txs, specialTxs, self.chain, self.coinbase) work.commitTransactions(self.mux, txs, specialTxs, self.chain, self.coinbase)
// compute uncles for the new block. // compute uncles for the new block.
var ( var (
uncles []*types.Header uncles []*types.Header