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

Method ValidateBasic

consensus/reactor.go:1596–1618  ·  view source on GitHub ↗

ValidateBasic performs basic validation.

()

Source from the content-addressed store, hash-verified

1594
1595// ValidateBasic performs basic validation.
1596func (m *NewValidBlockMessage) ValidateBasic() error {
1597 if m.Height < 0 {
1598 return errors.New("negative Height")
1599 }
1600 if m.Round < 0 {
1601 return errors.New("negative Round")
1602 }
1603 if err := m.BlockPartSetHeader.ValidateBasic(); err != nil {
1604 return fmt.Errorf("wrong BlockPartSetHeader: %v", err)
1605 }
1606 if m.BlockParts.Size() == 0 {
1607 return errors.New("empty blockParts")
1608 }
1609 if m.BlockParts.Size() != int(m.BlockPartSetHeader.Total) {
1610 return fmt.Errorf("blockParts bit array size %d not equal to BlockPartSetHeader.Total %d",
1611 m.BlockParts.Size(),
1612 m.BlockPartSetHeader.Total)
1613 }
1614 if m.BlockParts.Size() > int(types.MaxBlockPartsCount) {
1615 return fmt.Errorf("blockParts bit array is too big: %d, max: %d", m.BlockParts.Size(), types.MaxBlockPartsCount)
1616 }
1617 return nil
1618}
1619
1620// String returns a string representation.
1621func (m *NewValidBlockMessage) String() string {

Callers 1

Calls 2

ValidateBasicMethod · 0.65
SizeMethod · 0.65

Tested by 1