- Add Is() function to errors package wrapping stdlib errors.Is - Uncomment and fix Prometheus metrics gathering in telemetry package using prometheus DefaultGatherer and expfmt.MetricFamilyToText - Update telemetry tests to validate working Prometheus output - Update import paths in README to reflect utils module restructure
Utils
Melodia SDK Unified Utilities Framework
Overview
This package provides unified utilities for the entire Melodia SDK ecosystem, consolidating:
- log - Structured logging interface and implementations
- errors - Standardized error handling and error codes
- math - Mathematical types and operations (from melodiasdk-math)
- rand - Cryptographic random number generation (from hotbeat/libs/rand)
- sync - Concurrency utilities (from hotbeat/libs/sync)
Installation
import "sdk.melodia.network/utils"
Packages
log/- Logging utilitieserrors/- Error handling utilitiesmath/- Mathematical types and operationsrand/- Random number generationsync/- Concurrency utilities
Math Package Details
The math package provides custom mathematical types for arithmetic operations in the Melodia SDK:
Types
- Int - 256-bit signed integer (based on big.Int)
- Uint - 256-bit unsigned integer (based on big.Uint)
- LegacyDec - 18-precision decimal for financial calculations
Usage Examples
import "sdk.melodia.network/math"
// Integer operations
i := math.NewInt(100)
i2 := i.Add(math.NewInt(50))
// Unsigned integer operations
u := math.NewUint(100)
u2 := u.Add(math.NewUint(50))
// Decimal operations
d := math.LegacyNewDecWithPrec(12345, 5) // 0.12345
d2 := d.Add(math.LegacyOneDec())
Key Features
- Safety: Overflow checking and division by zero protection
- Precision: 256-bit integers for blockchain calculations
- Compatibility: Full API compatibility with melodiasdk-math
- Performance: Optimized for high-frequency operations
Migration Status
This package consolidates functionality from:
sdk.melodia.network/melodiasdk/logsdk.melodia.network/melodiasdk/errorssdk.melodia.network/mathsdk.melodia.network/hotbeat/libs/randsdk.melodia.network/hotbeat/libs/sync
License
Description
Languages
Go
63.2%
HTML
36.8%