From f04082ccdb24ebf6166934c6ffcb9c2ea26e716e Mon Sep 17 00:00:00 2001 From: Dennis Won Date: Fri, 22 May 2020 12:56:12 -0700 Subject: [PATCH] added comment for the isGreaterThanLatestBlockNum check --- internal/hmyapi/apiv1/blockchain.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/hmyapi/apiv1/blockchain.go b/internal/hmyapi/apiv1/blockchain.go index 41b327bbd..15672d536 100644 --- a/internal/hmyapi/apiv1/blockchain.go +++ b/internal/hmyapi/apiv1/blockchain.go @@ -66,6 +66,9 @@ func (s *PublicBlockChainAPI) isBeaconShard() error { } func (s *PublicBlockChainAPI) isBlockGreaterThanLatest(blockNum rpc.BlockNumber) error { + // rpc.BlockNumber is int64 (latest = -1. pending = -2) and currentBlockNum is uint64. + // Most straightfoward to make sure to return nil error for latest and pending block num + // since they are never greater than latest if blockNum != rpc.PendingBlockNumber && blockNum != rpc.LatestBlockNumber && uint64(blockNum) > s.b.CurrentBlock().NumberU64() {