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

Method HandleMessageSubsidy

fsm/message.go:362–378  ·  view source on GitHub ↗

HandleMessageSubsidy() is the proper handler for a `Subsidy` message

(msg *MessageSubsidy)

Source from the content-addressed store, hash-verified

360
361// HandleMessageSubsidy() is the proper handler for a `Subsidy` message
362func (s *StateMachine) HandleMessageSubsidy(msg *MessageSubsidy) lib.ErrorI {
363 // get the retired status of the committee
364 retired, err := s.CommitteeIsRetired(msg.ChainId)
365 if err != nil {
366 return err
367 }
368 // ensure the committee isn't retired
369 if retired {
370 return ErrNonSubsidizedCommittee()
371 }
372 // subtract from sender
373 if err = s.AccountSub(crypto.NewAddressFromBytes(msg.Address), msg.Amount); err != nil {
374 return err
375 }
376 // add to recipient committee
377 return s.PoolAdd(msg.ChainId, msg.Amount)
378}
379
380// HandleMessageCreateOrder() is the proper handler for a `CreateOrder` message
381func (s *StateMachine) HandleMessageCreateOrder(msg *MessageCreateOrder) (err lib.ErrorI) {

Callers 2

HandleMessageMethod · 0.95
TestMessageSubsidyFunction · 0.80

Calls 5

CommitteeIsRetiredMethod · 0.95
AccountSubMethod · 0.95
PoolAddMethod · 0.95
NewAddressFromBytesFunction · 0.92

Tested by 1

TestMessageSubsidyFunction · 0.64