mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
package doublylinkedtree
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
|
|
"github.com/prysmaticlabs/prysm/v4/config/params"
|
|
)
|
|
|
|
// applyProposerBoostScore applies the current proposer boost scores to the
|
|
// relevant nodes.
|
|
func (f *ForkChoice) applyProposerBoostScore() error {
|
|
s := f.store
|
|
proposerScore := uint64(0)
|
|
if s.previousProposerBoostRoot != params.BeaconConfig().ZeroHash {
|
|
previousNode, ok := s.nodeByRoot[s.previousProposerBoostRoot]
|
|
if !ok || previousNode == nil {
|
|
log.WithError(errInvalidProposerBoostRoot).Errorf(fmt.Sprintf("invalid prev root %#x", s.previousProposerBoostRoot))
|
|
} else {
|
|
previousNode.balance -= s.previousProposerBoostScore
|
|
}
|
|
}
|
|
|
|
if s.proposerBoostRoot != params.BeaconConfig().ZeroHash {
|
|
currentNode, ok := s.nodeByRoot[s.proposerBoostRoot]
|
|
if !ok || currentNode == nil {
|
|
log.WithError(errInvalidProposerBoostRoot).Errorf(fmt.Sprintf("invalid current root %#x", s.proposerBoostRoot))
|
|
} else {
|
|
proposerScore = (s.committeeWeight * params.BeaconConfig().ProposerScoreBoost) / 100
|
|
currentNode.balance += proposerScore
|
|
}
|
|
}
|
|
s.previousProposerBoostRoot = s.proposerBoostRoot
|
|
s.previousProposerBoostScore = proposerScore
|
|
return nil
|
|
}
|
|
|
|
// ProposerBoost of fork choice store.
|
|
func (s *Store) proposerBoost() [fieldparams.RootLength]byte {
|
|
return s.proposerBoostRoot
|
|
}
|