rpc: provide timestamps in getnep5transfers
Set default value for the first timestamp to a week ago.
This commit is contained in:
parent
9aa7b7fc97
commit
fe5e5ff44a
2 changed files with 60 additions and 11 deletions
|
@ -721,6 +721,18 @@ func (s *Server) getNEP5Transfers(ps request.Params) (interface{}, *response.Err
|
|||
return nil, response.ErrInvalidParams
|
||||
}
|
||||
|
||||
p1, p2 := ps.Value(1), ps.Value(2)
|
||||
start, end, err := getTimestamps(p1, p2)
|
||||
if err != nil {
|
||||
return nil, response.NewInvalidParamsError("", err)
|
||||
}
|
||||
if p2 == nil {
|
||||
end = uint32(time.Now().Unix())
|
||||
if p1 == nil {
|
||||
start = uint32(time.Now().Add(-time.Hour * 24 * 7).Unix())
|
||||
}
|
||||
}
|
||||
|
||||
bs := &result.NEP5Transfers{
|
||||
Address: address.Uint160ToString(u),
|
||||
Received: []result.NEP5Transfer{},
|
||||
|
@ -728,6 +740,9 @@ func (s *Server) getNEP5Transfers(ps request.Params) (interface{}, *response.Err
|
|||
}
|
||||
tr := new(state.NEP5Transfer)
|
||||
err = s.chain.ForEachNEP5Transfer(u, tr, func() error {
|
||||
if tr.Timestamp < start || tr.Timestamp > end {
|
||||
return nil
|
||||
}
|
||||
transfer := result.NEP5Transfer{
|
||||
Timestamp: tr.Timestamp,
|
||||
Asset: tr.Asset,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue