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

Method UpdateRootChainInfo

controller/controller.go:184–209  ·  view source on GitHub ↗

ROOT CHAIN CALLS BELOW UpdateRootChainInfo() receives updates from the root-chain thread

(info *lib.RootChainInfo)

Source from the content-addressed store, hash-verified

182
183// UpdateRootChainInfo() receives updates from the root-chain thread
184func (c *Controller) UpdateRootChainInfo(info *lib.RootChainInfo) {
185 c.log.Debugf("Updating root chain info")
186 // ensure this root chain is active
187 activeRootChainId, _ := c.FSM.GetRootChainId()
188 // if inactive
189 if activeRootChainId != info.RootChainId {
190 c.log.Debugf("Detected inactive root-chain update at rootChainId=%d", info.RootChainId)
191 return
192 }
193 // set timestamp if included
194 var timestamp time.Time
195 // if timestamp is not 0
196 if info.Timestamp != 0 {
197 timestamp = time.UnixMicro(int64(info.Timestamp))
198 }
199 // if the last validator set is empty
200 if info.LastValidatorSet == nil || len(info.LastValidatorSet.ValidatorSet) == 0 {
201 // signal to reset consensus and start a new height
202 c.Consensus.ResetBFT <- bft.ResetBFT{IsRootChainUpdate: false, StartTime: timestamp}
203 } else {
204 // signal to reset consensus
205 c.Consensus.ResetBFT <- bft.ResetBFT{IsRootChainUpdate: true, StartTime: timestamp}
206 }
207 // update the peer 'must connect'
208 c.UpdateP2PMustConnect(info.ValidatorSet)
209}
210
211// LoadCommittee() gets the ValidatorSet that is authorized to come to Consensus agreement on the Proposal for a specific height/chainId
212func (c *Controller) LoadCommittee(rootChainId, rootHeight uint64) (lib.ValidatorSet, lib.ErrorI) {

Callers

nothing calls this directly

Calls 3

UpdateP2PMustConnectMethod · 0.95
DebugfMethod · 0.65
GetRootChainIdMethod · 0.45

Tested by

no test coverage detected