MCPcopy Create free account
hub / github.com/erpc/erpc / parseBlockField

Function parseBlockField

data/grpc.go:410–420  ·  view source on GitHub ↗

parseBlockField extracts a top-level string field (e.g. "number" or "timestamp") from a JSON block result. Returns "" when absent or unparsable.

(b []byte, field string)

Source from the content-addressed store, hash-verified

408// parseBlockField extracts a top-level string field (e.g. "number" or
409// "timestamp") from a JSON block result. Returns "" when absent or unparsable.
410func parseBlockField(b []byte, field string) string {
411 if len(b) == 0 {
412 return ""
413 }
414 node, err := sonic.Get(b, field)
415 if err == nil {
416 v, _ := node.String()
417 return v
418 }
419 return ""
420}
421
422func fetchGrpcServers(ctx context.Context, logger *zerolog.Logger, endpoint string) ([]string, error) {
423 // Simple HTTP GET that returns a JSON array of URLs or newline separated text

Callers 1

fetchTaggedBlockMethod · 0.85

Calls 2

GetMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected