()
| 155 | } |
| 156 | |
| 157 | func (self *Server) constructHeartbeatMsg() (*peerHeartbeatMsg, error) { |
| 158 | |
| 159 | blkNum := self.GetCurrentBlockNo() - 1 |
| 160 | block, blockhash := self.blockPool.getSealedBlock(blkNum) |
| 161 | if block == nil { |
| 162 | return nil, fmt.Errorf("failed to get sealed block, current block: %d", self.GetCurrentBlockNo()) |
| 163 | } |
| 164 | |
| 165 | bookkeepers := make([][]byte, 0) |
| 166 | endorsePks := block.Block.Header.Bookkeepers |
| 167 | sigData := block.Block.Header.SigData |
| 168 | if len(endorsePks) == len(sigData) { |
| 169 | for i := 0; i < len(endorsePks); i++ { |
| 170 | bookkeepers = append(bookkeepers, keypair.SerializePublicKey(endorsePks[i])) |
| 171 | } |
| 172 | } else { |
| 173 | log.Errorf("Invalid signature counts in block %d: %d vs %d", blkNum, len(endorsePks), len(sigData)) |
| 174 | sigData = make([][]byte, 0) |
| 175 | } |
| 176 | |
| 177 | msg := &peerHeartbeatMsg{ |
| 178 | CommittedBlockNumber: blkNum, |
| 179 | CommittedBlockHash: blockhash, |
| 180 | CommittedBlockLeader: block.getProposer(), |
| 181 | Endorsers: bookkeepers, |
| 182 | EndorsersSig: sigData, |
| 183 | ChainConfigView: self.config.View, |
| 184 | } |
| 185 | |
| 186 | return msg, nil |
| 187 | } |
| 188 | |
| 189 | func (self *Server) constructBlock(blkNum uint32, prevBlkHash common.Uint256, txs []*types.Transaction, consensusPayload []byte, blocktimestamp uint32) (*types.Block, error) { |
| 190 | txHash := []common.Uint256{} |
no test coverage detected