(k proto.AccountAddress, v *types.Account)
| 120 | } |
| 121 | |
| 122 | func (s *metaState) storeBaseAccount(k proto.AccountAddress, v *types.Account) (err error) { |
| 123 | log.WithFields(log.Fields{ |
| 124 | "addr": k, |
| 125 | "account": v, |
| 126 | }).Debug("store account") |
| 127 | // Since a transfer tx may create an empty receiver account, this method should try to cover |
| 128 | // the side effect. |
| 129 | if ao, ok := s.loadOrStoreAccountObject(k, v); ok { |
| 130 | if ao.NextNonce != 0 { |
| 131 | err = ErrAccountExists |
| 132 | return |
| 133 | } |
| 134 | var ( |
| 135 | cb = ao.TokenBalance[types.Wave] |
| 136 | sb = ao.TokenBalance[types.Particle] |
| 137 | ) |
| 138 | if err = safeAdd(&cb, &v.TokenBalance[types.Wave]); err != nil { |
| 139 | return |
| 140 | } |
| 141 | if err = safeAdd(&sb, &v.TokenBalance[types.Particle]); err != nil { |
| 142 | return |
| 143 | } |
| 144 | ao.TokenBalance[types.Wave] = cb |
| 145 | ao.TokenBalance[types.Particle] = sb |
| 146 | } |
| 147 | return |
| 148 | } |
| 149 | |
| 150 | func (s *metaState) loadSQLChainObject(k proto.DatabaseID) (o *types.SQLChainProfile, loaded bool) { |
| 151 | var old *types.SQLChainProfile |
no test coverage detected