mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
0a5c65e29c
* Add GetAttestationData * Add tests * Add many more tests and refactor * Fix logic * Address PR comments * Address PR comments * Add jsonRestHandler and decouple http logic from rest of the code * Add buildURL tests * Remove handlers_test.go * Improve tests * Implement `ValidatorIndex` of `beaconApiValidatorClient` using Beacon API * Implement getStateValidators * `validatorIndex`: Use `getStateValidators` Co-authored-by: Patrice Vignola <vignola.patrice@gmail.com>
27 lines
457 B
Go
27 lines
457 B
Go
//go:build use_beacon_api
|
|
// +build use_beacon_api
|
|
|
|
package beacon_api
|
|
|
|
import (
|
|
"fmt"
|
|
neturl "net/url"
|
|
"regexp"
|
|
)
|
|
|
|
func validRoot(root string) bool {
|
|
matchesRegex, err := regexp.MatchString("^0x[a-fA-F0-9]{64}$", root)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
return matchesRegex
|
|
}
|
|
|
|
func buildURL(path string, queryParams ...neturl.Values) string {
|
|
if len(queryParams) == 0 {
|
|
return path
|
|
}
|
|
|
|
return fmt.Sprintf("%s?%s", path, queryParams[0].Encode())
|
|
}
|