MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / decideProposal

Function decideProposal

consensus/common_test.go:202–228  ·  view source on GitHub ↗

Create proposal block from cs1 but sign it with vs.

(
	cs1 *State,
	vs *validatorStub,
	height int64,
	round int32,
)

Source from the content-addressed store, hash-verified

200
201// Create proposal block from cs1 but sign it with vs.
202func decideProposal(
203 cs1 *State,
204 vs *validatorStub,
205 height int64,
206 round int32,
207) (proposal *types.Proposal, block *types.Block) {
208 cs1.mtx.Lock()
209 block, blockParts := cs1.createProposalBlock()
210 validRound := cs1.ValidRound
211 chainID := cs1.state.ChainID
212 cs1.mtx.Unlock()
213 if block == nil {
214 panic("Failed to createProposalBlock. Did you forget to add commit for previous block?")
215 }
216
217 // Make proposal
218 polRound, propBlockID := validRound, types.BlockID{Hash: block.Hash(), PartSetHeader: blockParts.Header()}
219 proposal = types.NewProposal(height, round, polRound, propBlockID)
220 p := proposal.ToProto()
221 if err := vs.SignProposal(chainID, p); err != nil {
222 panic(err)
223 }
224
225 proposal.Signature = p.Signature
226
227 return
228}
229
230func addVotes(to *State, votes ...*types.Vote) {
231 for _, vote := range votes {

Calls 8

NewProposalFunction · 0.92
LockMethod · 0.65
UnlockMethod · 0.65
HashMethod · 0.65
SignProposalMethod · 0.65
createProposalBlockMethod · 0.45
HeaderMethod · 0.45
ToProtoMethod · 0.45

Tested by

no test coverage detected