mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
fa01ee5eba
* WIP * WIP * WIP * Add tests * WIP * Add more tests * Address DeepSource errors * Remove unused param * Add more tests * Address PR comments * Address PR comments * Fix formatting * Remove unused parameter * Fix TestLittleEndianBytesToBigInt Co-authored-by: Radosław Kapka <rkapka@wp.pl>
31 lines
653 B
Go
31 lines
653 B
Go
package beacon_api
|
|
|
|
import (
|
|
"fmt"
|
|
neturl "net/url"
|
|
"regexp"
|
|
"strconv"
|
|
|
|
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
|
)
|
|
|
|
func validRoot(root string) bool {
|
|
matchesRegex, err := regexp.MatchString("^0x[a-fA-F0-9]{64}$", root)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
return matchesRegex
|
|
}
|
|
|
|
func uint64ToString[T uint64 | types.Slot | types.ValidatorIndex | types.CommitteeIndex | types.Epoch](val T) string {
|
|
return strconv.FormatUint(uint64(val), 10)
|
|
}
|
|
|
|
func buildURL(path string, queryParams ...neturl.Values) string {
|
|
if len(queryParams) == 0 {
|
|
return path
|
|
}
|
|
|
|
return fmt.Sprintf("%s?%s", path, queryParams[0].Encode())
|
|
}
|