mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 18:30:45 +00:00
Fixed randomize for mi and m2
This commit is contained in:
parent
4af57cc070
commit
2fa93cdbf2
1 changed files with 15 additions and 16 deletions
|
|
@ -27,6 +27,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts"
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
"github.com/ethereum/go-ethereum/accounts/keystore"
|
"github.com/ethereum/go-ethereum/accounts/keystore"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
|
|
@ -34,6 +35,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/consensus/ethash"
|
"github.com/ethereum/go-ethereum/consensus/ethash"
|
||||||
"github.com/ethereum/go-ethereum/consensus/XDPoS"
|
"github.com/ethereum/go-ethereum/consensus/XDPoS"
|
||||||
"github.com/ethereum/go-ethereum/contracts"
|
"github.com/ethereum/go-ethereum/contracts"
|
||||||
|
contractValidator "github.com/ethereum/go-ethereum/contracts/validator/contract"
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/core/vm"
|
"github.com/ethereum/go-ethereum/core/vm"
|
||||||
|
|
@ -44,17 +46,15 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
"github.com/syndtr/goleveldb/leveldb"
|
"github.com/syndtr/goleveldb/leveldb"
|
||||||
"github.com/syndtr/goleveldb/leveldb/util"
|
"github.com/syndtr/goleveldb/leveldb/util"
|
||||||
contractValidator "github.com/ethereum/go-ethereum/contracts/validator/contract"
|
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
defaultGasPrice = 50 * params.Shannon
|
defaultGasPrice = 50 * params.Shannon
|
||||||
// statuses of candidates
|
// statuses of candidates
|
||||||
statusMasternode = "MASTERNODE"
|
statusMasternode = "MASTERNODE"
|
||||||
statusSlashed = "SLASHED"
|
statusSlashed = "SLASHED"
|
||||||
statusProposed = "PROPOSED"
|
statusProposed = "PROPOSED"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -700,14 +700,13 @@ func (s *PublicBlockChainAPI) GetMasternodes(ctx context.Context, b *types.Block
|
||||||
return masternodes, nil
|
return masternodes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// GetCandidateStatus returns status of the given candidate at a specified epochNumber
|
// GetCandidateStatus returns status of the given candidate at a specified epochNumber
|
||||||
func (s *PublicBlockChainAPI) GetCandidateStatus(ctx context.Context, coinbaseAddress common.Address, epochNumber rpc.EpochNumber) (string, error) {
|
func (s *PublicBlockChainAPI) GetCandidateStatus(ctx context.Context, coinbaseAddress common.Address, epochNumber rpc.EpochNumber) (string, error) {
|
||||||
var (
|
var (
|
||||||
block *types.Block
|
block *types.Block
|
||||||
masternodes, penaltyList []common.Address
|
masternodes, penaltyList []common.Address
|
||||||
penalties []byte
|
penalties []byte
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
block = s.b.CurrentBlock()
|
block = s.b.CurrentBlock()
|
||||||
epoch := s.b.ChainConfig().XDPoS.Epoch
|
epoch := s.b.ChainConfig().XDPoS.Epoch
|
||||||
|
|
@ -749,7 +748,7 @@ func (s *PublicBlockChainAPI) GetCandidateStatus(ctx context.Context, coinbaseAd
|
||||||
opts := new(bind.CallOpts)
|
opts := new(bind.CallOpts)
|
||||||
var (
|
var (
|
||||||
candidateAddresses []common.Address
|
candidateAddresses []common.Address
|
||||||
candidates []XDPoS.Masternode
|
candidates []XDPoS.Masternode
|
||||||
)
|
)
|
||||||
|
|
||||||
candidateAddresses, err = validator.GetCandidates(opts)
|
candidateAddresses, err = validator.GetCandidates(opts)
|
||||||
|
|
@ -780,13 +779,13 @@ func (s *PublicBlockChainAPI) GetCandidateStatus(ctx context.Context, coinbaseAd
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if isTopCandidate == false {
|
if !isTopCandidate {
|
||||||
return status, nil
|
return status, nil
|
||||||
}
|
}
|
||||||
// look up recent checkpoint headers to get penalty list
|
// look up recent checkpoint headers to get penalty list
|
||||||
for i := 0; i <= common.LimitPenaltyEpoch; i++ {
|
for i := 0; i <= common.LimitPenaltyEpoch; i++ {
|
||||||
if blockNum > uint64(i) * epoch {
|
if blockNum > uint64(i)*epoch {
|
||||||
blockCheckpointNumber := rpc.BlockNumber(blockNum - (blockNum % epoch) - (uint64(i) * epoch))
|
blockCheckpointNumber := rpc.BlockNumber(blockNum - (blockNum % epoch) - (uint64(i) * epoch))
|
||||||
blockCheckpoint, err := s.b.BlockByNumber(ctx, blockCheckpointNumber)
|
blockCheckpoint, err := s.b.BlockByNumber(ctx, blockCheckpointNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Failed to get block by number", "num", blockCheckpointNumber, "err", err)
|
log.Error("Failed to get block by number", "num", blockCheckpointNumber, "err", err)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue