|
|
@ -8,6 +8,7 @@ import ( |
|
|
|
"net" |
|
|
|
"net" |
|
|
|
"net/http" |
|
|
|
"net/http" |
|
|
|
"os" |
|
|
|
"os" |
|
|
|
|
|
|
|
"sort" |
|
|
|
"strconv" |
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
|
|
|
|
|
|
|
@ -188,7 +189,7 @@ func (s *Service) GetExplorerBlocks(w http.ResponseWriter, r *http.Request) { |
|
|
|
if withSignersParam == "true" { |
|
|
|
if withSignersParam == "true" { |
|
|
|
withSigners = true |
|
|
|
withSigners = true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
order := r.FormValue("order") |
|
|
|
data := &Data{ |
|
|
|
data := &Data{ |
|
|
|
Blocks: []*Block{}, |
|
|
|
Blocks: []*Block{}, |
|
|
|
} |
|
|
|
} |
|
|
@ -343,10 +344,19 @@ func (s *Service) GetExplorerBlocks(w http.ResponseWriter, r *http.Request) { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
data.Blocks = data.Blocks[offset*page : offset*page+offset] |
|
|
|
data.Blocks = data.Blocks[offset*page : offset*page+offset] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if order == "DESC" { |
|
|
|
|
|
|
|
sort.Slice(data.Blocks[:], func(i, j int) bool { |
|
|
|
|
|
|
|
return data.Blocks[i].Timestamp > data.Blocks[j].Timestamp |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
sort.Slice(data.Blocks[:], func(i, j int) bool { |
|
|
|
|
|
|
|
return data.Blocks[i].Timestamp < data.Blocks[j].Timestamp |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// GetExplorerBlocks rpc end-point.
|
|
|
|
// GetExplorerBlocks rpc end-point.
|
|
|
|
func (s *ServiceAPI) GetExplorerBlocks(ctx context.Context, from, to, page, offset int, withSigners bool) ([]*Block, error) { |
|
|
|
func (s *ServiceAPI) GetExplorerBlocks(ctx context.Context, from, to, page, offset int, withSigners bool, order string) ([]*Block, error) { |
|
|
|
if offset == 0 { |
|
|
|
if offset == 0 { |
|
|
|
offset = paginationOffset |
|
|
|
offset = paginationOffset |
|
|
|
} |
|
|
|
} |
|
|
@ -453,6 +463,15 @@ func (s *ServiceAPI) GetExplorerBlocks(ctx context.Context, from, to, page, offs |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
blocks = blocks[offset*page : offset*page+offset] |
|
|
|
blocks = blocks[offset*page : offset*page+offset] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if order == "DESC" { |
|
|
|
|
|
|
|
sort.Slice(blocks[:], func(i, j int) bool { |
|
|
|
|
|
|
|
return blocks[i].Timestamp > blocks[j].Timestamp |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
sort.Slice(blocks[:], func(i, j int) bool { |
|
|
|
|
|
|
|
return blocks[i].Timestamp < blocks[j].Timestamp |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
return blocks, nil |
|
|
|
return blocks, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -656,6 +675,7 @@ func (s *Service) GetExplorerAddress(w http.ResponseWriter, r *http.Request) { |
|
|
|
txViewParam := r.FormValue("tx_view") |
|
|
|
txViewParam := r.FormValue("tx_view") |
|
|
|
pageParam := r.FormValue("page") |
|
|
|
pageParam := r.FormValue("page") |
|
|
|
offsetParam := r.FormValue("offset") |
|
|
|
offsetParam := r.FormValue("offset") |
|
|
|
|
|
|
|
order := r.FormValue("order") |
|
|
|
txView := txViewNone |
|
|
|
txView := txViewNone |
|
|
|
if txViewParam != "" { |
|
|
|
if txViewParam != "" { |
|
|
|
txView = txViewParam |
|
|
|
txView = txViewParam |
|
|
@ -750,6 +770,15 @@ func (s *Service) GetExplorerAddress(w http.ResponseWriter, r *http.Request) { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
data.Address.TXs = data.Address.TXs[offset*page : offset*page+offset] |
|
|
|
data.Address.TXs = data.Address.TXs[offset*page : offset*page+offset] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if order == "DESC" { |
|
|
|
|
|
|
|
sort.Slice(data.Address.TXs[:], func(i, j int) bool { |
|
|
|
|
|
|
|
return data.Address.TXs[i].Timestamp > data.Address.TXs[j].Timestamp |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
sort.Slice(data.Address.TXs[:], func(i, j int) bool { |
|
|
|
|
|
|
|
return data.Address.TXs[i].Timestamp < data.Address.TXs[j].Timestamp |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// GetExplorerAddress rpc end-point.
|
|
|
|
// GetExplorerAddress rpc end-point.
|
|
|
@ -784,7 +813,6 @@ func (s *ServiceAPI) GetExplorerAddress(ctx context.Context, id, txView string, |
|
|
|
balance, err := s.Service.GetAccountBalance(addr) |
|
|
|
balance, err := s.Service.GetAccountBalance(addr) |
|
|
|
if err == nil { |
|
|
|
if err == nil { |
|
|
|
balanceAddr = balance |
|
|
|
balanceAddr = balance |
|
|
|
address.Balance = balance |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -829,6 +857,15 @@ func (s *ServiceAPI) GetExplorerAddress(ctx context.Context, id, txView string, |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
address.TXs = address.TXs[offset*page : offset*page+offset] |
|
|
|
address.TXs = address.TXs[offset*page : offset*page+offset] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if order == "DESC" { |
|
|
|
|
|
|
|
sort.Slice(address.TXs[:], func(i, j int) bool { |
|
|
|
|
|
|
|
return address.TXs[i].Timestamp > address.TXs[j].Timestamp |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
sort.Slice(address.TXs[:], func(i, j int) bool { |
|
|
|
|
|
|
|
return address.TXs[i].Timestamp < address.TXs[j].Timestamp |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
return address, nil |
|
|
|
return address, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|