2023-04-25 10:48:26 -07:00
|
|
|
package watcher
|
|
|
|
|
2023-05-31 06:29:47 -07:00
|
|
|
func getTotalBlocks(lastBlock, currentBlock, pageSize uint64) uint64 {
|
|
|
|
return (lastBlock-currentBlock)/pageSize + 1
|
2023-04-25 10:48:26 -07:00
|
|
|
}
|
|
|
|
|
2023-05-31 06:29:47 -07:00
|
|
|
func getPage(currentBlock, index, pageSize, lastBlock uint64) (uint64, uint64) {
|
|
|
|
fromBlock := currentBlock + index*pageSize
|
|
|
|
toBlock := fromBlock + pageSize - 1
|
2023-04-25 10:48:26 -07:00
|
|
|
if toBlock > lastBlock {
|
|
|
|
toBlock = lastBlock
|
|
|
|
}
|
|
|
|
return fromBlock, toBlock
|
|
|
|
}
|