Merge pull request #3857 from LuttyYang/add_number_of_pending_cross-shard

add number of pending cross-shard
pull/3869/head
Haodi 3 years ago committed by GitHub
commit b69d4c09d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      rpc/harmony.go
  2. 20
      rpc/pool.go

@ -86,3 +86,13 @@ func (s *PublicHarmonyService) GetPeerInfo(
// Response output is the same for all versions
return NewStructuredResponse(s.hmy.GetPeerInfo())
}
// GetNumPendingCrossLinks returns length of hmy.BlockChain.ReadPendingCrossLinks()
func (s *PublicHarmonyService) GetNumPendingCrossLinks() (int, error) {
links, err := s.hmy.BlockChain.ReadPendingCrossLinks()
if err != nil {
return 0, err
}
return len(links), nil
}

@ -364,3 +364,23 @@ func (s *PublicPoolService) GetPendingCXReceipts(
}
return formattedReceipts, nil
}
// GetNumPendingCXReceipts ..
func (s *PublicPoolService) GetNumPendingCXReceipts(
ctx context.Context,
) (int, error) {
timer := DoMetricRPCRequest(GetPendingCXReceipts)
defer DoRPCRequestDuration(GetPendingCXReceipts, timer)
// For each cx receipt, format the response (same format for all versions)
formattedReceipts := []StructuredResponse{}
for _, receipts := range s.hmy.GetPendingCXReceipts() {
formattedReceipt, err := NewStructuredResponse(receipts)
if err != nil {
DoMetricRPCQueryInfo(GetPendingCXReceipts, FailedNumber)
return 0, err
}
formattedReceipts = append(formattedReceipts, formattedReceipt)
}
return len(formattedReceipts), nil
}

Loading…
Cancel
Save