Skip to content

Commit 745d5c9

Browse files
authored
Collapse SetNotarization into PersistNotarization (#286)
Signed-off-by: Yacov Manevich <[email protected]>
1 parent f669be7 commit 745d5c9

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

epoch.go

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,12 +1316,14 @@ func (e *Epoch) writeNotarizationToWal(notarization Notarization) error {
13161316
}
13171317

13181318
func (e *Epoch) persistNotarization(notarization Notarization) error {
1319-
if err := e.writeNotarizationToWal(notarization); err != nil {
1320-
return err
1319+
r, exists := e.rounds[notarization.Vote.Round]
1320+
if !exists {
1321+
return fmt.Errorf("attempted to store notarization of a non existent round %d", notarization.Vote.Round)
13211322
}
13221323

1323-
err := e.storeNotarization(notarization)
1324-
if err != nil {
1324+
r.notarization = &notarization
1325+
1326+
if err := e.writeNotarizationToWal(notarization); err != nil {
13251327
return err
13261328
}
13271329

@@ -1861,7 +1863,6 @@ func (e *Epoch) createNotarizedBlockVerificationTask(block Block, notarization N
18611863
e.Logger.Warn("Unable to get proposed block for the round", zap.Uint64("round", md.Round))
18621864
return md.Digest
18631865
}
1864-
round.notarization = &notarization
18651866

18661867
if err := e.persistNotarization(notarization); err != nil {
18671868
e.haltedError = err
@@ -2534,18 +2535,6 @@ func (e *Epoch) constructFinalizeVoteMessage(md BlockHeader) (FinalizeVote, *Mes
25342535
return vote, finalizationMsg, nil
25352536
}
25362537

2537-
// stores a notarization in the epoch's memory.
2538-
func (e *Epoch) storeNotarization(notarization Notarization) error {
2539-
round := notarization.Vote.Round
2540-
r, exists := e.rounds[round]
2541-
if !exists {
2542-
return fmt.Errorf("attempted to store notarization of a non existent round %d", round)
2543-
}
2544-
2545-
r.notarization = &notarization
2546-
return nil
2547-
}
2548-
25492538
func (e *Epoch) maybeLoadFutureMessages() error {
25502539
for {
25512540
round := e.round

0 commit comments

Comments
 (0)