core: do not store NEP5 transfer log in memory

Traversing transfer log instead of accumulating and returning it
is faster and takes less memory.
This commit is contained in:
Evgenii Stratonikov 2020-08-06 14:20:36 +03:00
parent c3c88a57cd
commit 807338f97e
4 changed files with 10 additions and 9 deletions

View file

@ -541,9 +541,8 @@ func (s *Server) getNEP5Transfers(ps request.Params) (interface{}, *response.Err
Received: []result.NEP5Transfer{},
Sent: []result.NEP5Transfer{},
}
lg := s.chain.GetNEP5TransferLog(u)
cache := make(map[int32]decimals)
err = lg.ForEach(func(tr *state.NEP5Transfer) error {
err = s.chain.ForEachNEP5Transfer(u, func(tr *state.NEP5Transfer) error {
d, err := s.getDecimals(tr.Asset, cache)
if err != nil {
return nil