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

Method GetAccount

fsm/account.go:16–34  ·  view source on GitHub ↗

* This file defines the account, pool, and supply tracker state interactions */ GetAccount() returns an Account structure for a specific address

(address crypto.AddressI)

Source from the content-addressed store, hash-verified

14
15// GetAccount() returns an Account structure for a specific address
16func (s *StateMachine) GetAccount(address crypto.AddressI) (*Account, lib.ErrorI) {
17 // check cache
18 if acc, found := s.cache.accounts[lib.MemHash(address.Bytes())]; found {
19 return acc, nil
20 }
21 // retrieve the account from the state store
22 bz, err := s.Get(KeyForAccount(address))
23 if err != nil {
24 return nil, err
25 }
26 // convert the account bytes into a structure
27 acc, err := s.unmarshalAccount(bz)
28 if err != nil {
29 return nil, err
30 }
31 // convert the address into bytes and set it
32 acc.Address = address.Bytes()
33 return acc, nil
34}
35
36// GetAccounts() returns all Account structures in the state
37func (s *StateMachine) GetAccounts() (result []*Account, err lib.ErrorI) {

Callers 15

GetAccountBalanceMethod · 0.95
AccountAddMethod · 0.95
AccountSubMethod · 0.95
UpdateTelemetryMethod · 0.80
TestHandleMessageSendFunction · 0.80
TestHandleMessageStakeFunction · 0.80
TestEndBlockFunction · 0.80
TestSetGetAccountFunction · 0.80
TestAccountAddFunction · 0.80
TestAccountSubFunction · 0.80
TestHandleRemoteDexBatchFunction · 0.80

Calls 5

GetMethod · 0.95
unmarshalAccountMethod · 0.95
MemHashFunction · 0.92
KeyForAccountFunction · 0.70
BytesMethod · 0.65

Tested by 10

TestHandleMessageSendFunction · 0.64
TestHandleMessageStakeFunction · 0.64
TestEndBlockFunction · 0.64
TestSetGetAccountFunction · 0.64
TestAccountAddFunction · 0.64
TestAccountSubFunction · 0.64
TestHandleRemoteDexBatchFunction · 0.64
genOpsFunction · 0.64