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

Method HandleMessageSend

fsm/message.go:56–63  ·  view source on GitHub ↗

HandleMessageSend() is the proper handler for a `Send` message

(msg *MessageSend)

Source from the content-addressed store, hash-verified

54
55// HandleMessageSend() is the proper handler for a `Send` message
56func (s *StateMachine) HandleMessageSend(msg *MessageSend) lib.ErrorI {
57 // subtract from sender
58 if err := s.AccountSub(crypto.NewAddressFromBytes(msg.FromAddress), msg.Amount); err != nil {
59 return err
60 }
61 // add to recipient
62 return s.AccountAdd(crypto.NewAddressFromBytes(msg.ToAddress), msg.Amount)
63}
64
65// HandleMessageStake() is the proper handler for a `Stake` message (Validator does not yet exist in the state)
66func (s *StateMachine) HandleMessageStake(msg *MessageStake) lib.ErrorI {

Callers 2

HandleMessageMethod · 0.95
TestHandleMessageSendFunction · 0.80

Calls 3

AccountSubMethod · 0.95
AccountAddMethod · 0.95
NewAddressFromBytesFunction · 0.92

Tested by 1

TestHandleMessageSendFunction · 0.64