MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / getEntityTypeFromID

Function getEntityTypeFromID

metadata.go:21–36  ·  view source on GitHub ↗

getEntityTypeFromID determines the entity type from the ID prefix. It analyzes the prefix of the provided ID and returns the corresponding entity type. Parameters: - id: A string representing the entity ID to analyze. Returns: - string: The determined entity type ("transactions", "ledgers", "balan

(id string)

Source from the content-addressed store, hash-verified

19// - string: The determined entity type ("transactions", "ledgers", "balances", or "identities").
20// - error: An error if the ID format is invalid.
21func getEntityTypeFromID(id string) (string, error) {
22 switch {
23 case strings.HasPrefix(id, "txn_"):
24 return "transactions", nil
25 case strings.HasPrefix(id, "bulk_"):
26 return "transactions", nil
27 case strings.HasPrefix(id, "ldg_"):
28 return "ledgers", nil
29 case strings.HasPrefix(id, "bln_"):
30 return "balances", nil
31 case strings.HasPrefix(id, "idt_"):
32 return "identities", nil
33 default:
34 return "", fmt.Errorf("invalid entity ID format: %s", id)
35 }
36}
37
38// UpdateMetadata updates the metadata for a given entity ID.
39// It first determines the entity type, retrieves current metadata, merges it with new metadata,

Callers 2

UpdateMetadataMethod · 0.85
TestGetEntityTypeFromIDFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestGetEntityTypeFromIDFunction · 0.68