Skip to content

Commit

Permalink
Merge pull request ethereum#438 from dinhln89/testnet
Browse files Browse the repository at this point in the history
Fixed hard code 3 mns address only for testnet.
  • Loading branch information
ngtuna authored Feb 12, 2019
2 parents 82fab5d + c2e6908 commit 9b8b1d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
13 changes: 10 additions & 3 deletions consensus/posv/posv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
masternodes := c.GetMasternodes(chain, parent)

if common.IsTestnet {
// Only three mns for tomo testnet.
masternodes = masternodes[:3]
// Only three mns hard code for tomo testnet.
masternodes = []common.Address{
common.HexToAddress("0xfFC679Dcdf444D2eEb0491A998E7902B411CcF20"),
common.HexToAddress("0xd76fd76F7101811726DCE9E43C2617706a4c45c8"),
common.HexToAddress("0x8A97753311aeAFACfd76a68Cf2e2a9808d3e65E8"),
}
}

snap, err := c.GetSnapshot(chain, parent)
if err != nil {
log.Warn("Failed when trying to commit new work", "err", err)
Expand Down Expand Up @@ -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)
// 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
}
// Don't hold the signer fields for the entire sealing procedure
Expand Down Expand Up @@ -1023,6 +1029,7 @@ func (c *Posv) GetMasternodesFromCheckpointHeader(preCheckpointHeader *types.Hea
for i := 0; i < len(masternodes); i++ {
copy(masternodes[i][:], preCheckpointHeader.Extra[extraVanity+i*common.AddressLength:])
}

return masternodes
}

Expand Down
5 changes: 2 additions & 3 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,10 +585,10 @@ func (self *worker) commitNewWork() {
}
// won't grasp txs at checkpoint
var (
txs *types.TransactionsByPriceAndNonce
txs *types.TransactionsByPriceAndNonce
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()
if err != nil {
log.Error("Failed to fetch pending transactions", "err", err)
Expand All @@ -598,7 +598,6 @@ func (self *worker) commitNewWork() {
}
work.commitTransactions(self.mux, txs, specialTxs, self.chain, self.coinbase)


// compute uncles for the new block.
var (
uncles []*types.Header
Expand Down

0 comments on commit 9b8b1d7

Please sign in to comment.