Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Frozen committed Oct 2, 2023
1 parent 0fa3f42 commit e6e8389
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions core/blockchain_leader_rotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import (
"github.com/pkg/errors"
)

// LeaderRotationMeta contains information about leader rotation
type LeaderRotationMeta struct {
Pub []byte
Epoch uint64
Count uint64
Shifts uint64
Pub []byte // bls public key of previous block miner
Epoch uint64 // epoch number of previously inserted block
Count uint64 // quantity of continuous blocks inserted by the same leader
Shifts uint64 // number of leader shifts, shift happens when leader changes
}

// ShortString returns string representation of the struct
func (a LeaderRotationMeta) ShortString() string {
s := strings.Builder{}
s.Write(a.Pub[3:])
Expand All @@ -31,7 +33,7 @@ func (a LeaderRotationMeta) ShortString() string {
return s.String()
}

// Hash returns has of the struct
// Hash returns hash of the struct
func (a LeaderRotationMeta) Hash() []byte {
c := crc32.NewIEEE()
c.Write(a.Pub)
Expand All @@ -41,6 +43,7 @@ func (a LeaderRotationMeta) Hash() []byte {
return c.Sum(nil)
}

// Clone returns a copy of the struct
func (a LeaderRotationMeta) Clone() LeaderRotationMeta {
return LeaderRotationMeta{
Pub: append([]byte{}, a.Pub...),
Expand Down Expand Up @@ -89,6 +92,7 @@ func (bc *BlockChainImpl) buildLeaderRotationMeta(curHeader *block.Header) error
return errors.New("no leader rotation meta to save")
}

// saveLeaderRotationMeta saves leader rotation meta if feature is activated.
func (bc *BlockChainImpl) saveLeaderRotationMeta(h *block.Header) error {
blockPubKey, err := bc.getLeaderPubKeyFromCoinbase(h)
if err != nil {
Expand Down

0 comments on commit e6e8389

Please sign in to comment.