MCPcopy
hub / github.com/canopy-network/canopy / GossipBlock

Method GossipBlock

controller/block.go:98–111  ·  view source on GitHub ↗

PUBLISHERS BELOW GossipBlock() gossips a certificate (with block) through the P2P network for a specific chainId

(certificate *lib.QuorumCertificate, senderPubToExclude []byte, timestamp uint64)

Source from the content-addressed store, hash-verified

96
97// GossipBlock() gossips a certificate (with block) through the P2P network for a specific chainId
98func (c *Controller) GossipBlock(certificate *lib.QuorumCertificate, senderPubToExclude []byte, timestamp uint64) {
99 // log the start of the gossip block function
100 c.log.Debugf("Gossiping certificate: %s", lib.BytesToString(certificate.ResultsHash))
101 // create the block message to gossip
102 blockMessage := &lib.BlockMessage{
103 ChainId: c.Config.ChainId,
104 BlockAndCertificate: certificate,
105 Time: timestamp,
106 }
107 // send the block message to all peers excluding the sender (gossip)
108 if err := c.P2P.SendToPeers(Block, blockMessage, lib.BytesToString(senderPubToExclude)); err != nil {
109 c.log.Errorf("unable to gossip block with err: %s", err.Error())
110 }
111}
112
113// SelfSendBlock() gossips a QuorumCertificate (with block) through the P2P network for handling
114func (c *Controller) SelfSendBlock(qc *lib.QuorumCertificate, timestamp uint64) {

Callers 1

ListenForBlockMethod · 0.95

Calls 5

BytesToStringFunction · 0.92
SendToPeersMethod · 0.80
DebugfMethod · 0.65
ErrorfMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected