Skip to content

Commit

Permalink
Merge pull request #131 from getamis/feature/remove-checkpoints-from-…
Browse files Browse the repository at this point in the history
…round-state

consensus/istanbul: remove checkpoints from round state
  • Loading branch information
alanchchen authored Jul 31, 2017
2 parents f0c734b + 3ad497a commit b59c7d0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 31 deletions.
43 changes: 19 additions & 24 deletions consensus/istanbul/core/roundstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,24 @@ import (
// we need to keep a reference of preprepare in order to propose locked proposal when there is a lock and itself is the proposer
func newRoundState(view *istanbul.View, validatorSet istanbul.ValidatorSet, lockedHash common.Hash, preprepare *istanbul.Preprepare) *roundState {
return &roundState{
round: view.Round,
sequence: view.Sequence,
Preprepare: preprepare,
Prepares: newMessageSet(validatorSet),
Commits: newMessageSet(validatorSet),
Checkpoints: newMessageSet(validatorSet),
lockedHash: lockedHash,
mu: new(sync.RWMutex),
round: view.Round,
sequence: view.Sequence,
Preprepare: preprepare,
Prepares: newMessageSet(validatorSet),
Commits: newMessageSet(validatorSet),
lockedHash: lockedHash,
mu: new(sync.RWMutex),
}
}

// roundState stores the consensus state
type roundState struct {
round *big.Int
sequence *big.Int
Preprepare *istanbul.Preprepare
Prepares *messageSet
Commits *messageSet
Checkpoints *messageSet
lockedHash common.Hash
round *big.Int
sequence *big.Int
Preprepare *istanbul.Preprepare
Prepares *messageSet
Commits *messageSet
lockedHash common.Hash

mu *sync.RWMutex
}
Expand Down Expand Up @@ -153,13 +151,12 @@ func (s *roundState) GetLockedHash() common.Hash {
// be confusing.
func (s *roundState) DecodeRLP(stream *rlp.Stream) error {
var ss struct {
Round *big.Int
Sequence *big.Int
Preprepare *istanbul.Preprepare
Prepares *messageSet
Commits *messageSet
Checkpoints *messageSet
lockedHash common.Hash
Round *big.Int
Sequence *big.Int
Preprepare *istanbul.Preprepare
Prepares *messageSet
Commits *messageSet
lockedHash common.Hash
}

if err := stream.Decode(&ss); err != nil {
Expand All @@ -170,7 +167,6 @@ func (s *roundState) DecodeRLP(stream *rlp.Stream) error {
s.Preprepare = ss.Preprepare
s.Prepares = ss.Prepares
s.Commits = ss.Commits
s.Checkpoints = ss.Checkpoints
s.lockedHash = ss.lockedHash
s.mu = new(sync.RWMutex)

Expand All @@ -195,7 +191,6 @@ func (s *roundState) EncodeRLP(w io.Writer) error {
s.Preprepare,
s.Prepares,
s.Commits,
s.Checkpoints,
s.lockedHash,
})
}
13 changes: 6 additions & 7 deletions consensus/istanbul/core/roundstate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ import (

func newTestRoundState(view *istanbul.View, validatorSet istanbul.ValidatorSet) *roundState {
return &roundState{
round: view.Round,
sequence: view.Sequence,
Preprepare: newTestPreprepare(view),
Prepares: newMessageSet(validatorSet),
Commits: newMessageSet(validatorSet),
Checkpoints: newMessageSet(validatorSet),
mu: new(sync.RWMutex),
round: view.Round,
sequence: view.Sequence,
Preprepare: newTestPreprepare(view),
Prepares: newMessageSet(validatorSet),
Commits: newMessageSet(validatorSet),
mu: new(sync.RWMutex),
}
}

Expand Down

0 comments on commit b59c7d0

Please sign in to comment.