github.com/koko1123/flow-go-1@v0.29.6/consensus/recovery/participant.go (about) 1 package recovery 2 3 import ( 4 "fmt" 5 6 "github.com/rs/zerolog" 7 8 "github.com/koko1123/flow-go-1/consensus/hotstuff" 9 "github.com/koko1123/flow-go-1/consensus/hotstuff/model" 10 "github.com/koko1123/flow-go-1/model/flow" 11 ) 12 13 // Participant recovers the HotStuff state for a consensus participant. 14 // It reads the pending blocks from storage and pass them to the input Forks 15 // instance to recover its state from before the restart. 16 func Participant( 17 log zerolog.Logger, 18 forks hotstuff.Forks, 19 voteAggregator hotstuff.VoteAggregator, 20 validator hotstuff.Validator, 21 finalized *flow.Header, 22 pending []*flow.Header, 23 ) error { 24 return Recover(log, finalized, pending, validator, func(proposal *model.Proposal) error { 25 // add it to forks 26 err := forks.AddBlock(proposal.Block) 27 if err != nil { 28 return fmt.Errorf("could not add block to forks: %w", err) 29 } 30 31 // recovery the proposer's vote 32 err = voteAggregator.AddBlock(proposal) 33 if err != nil { 34 return fmt.Errorf("could not process proposal %v: %w", proposal.Block.BlockID, err) 35 } 36 37 return nil 38 }) 39 }