Documentation
¶
Index ¶
- Constants
- Variables
- func BigIntToLittleEndianBytes(n *big.Int) []byte
- func BytesToUint32(bytes []byte) uint32
- func BytesToUint64(bytes []byte) uint64
- func EstimateSliceCapacity(total int, span, fullSpan uint64) int
- func MapSlice[T any, R any](in []T, f func(T) R) []R
- func NewKeyFromKeystore(cfg types.KeystoreFileConfig) (*ecdsa.PrivateKey, error)
- func Uint32ToBytes(num uint32) []byte
- func Uint64ToBigEndianBytes(num uint64) []byte
- func Uint64ToLittleEndianBytes(num uint64) []byte
- type Config
- type Logger
- type RESTConfig
- type RateLimit
- type RateLimitConfig
Constants ¶
const ( Uint32ByteSize = 4 Uint64ByteSize = 8 )
const ( // AGGORACLE name to identify the aggoracle component AGGORACLE = "aggoracle" // BRIDGE name to identify the bridge component (have RPC) BRIDGE = "bridge" // PROVER name to identify the prover component PROVER = "prover" // AGGSENDER name to identify the aggsender component AGGSENDER = "aggsender" // L1INFOTREESYNC name to identify the l1infotreesync component L1INFOTREESYNC = "l1infotreesync" // AGGCHAINPROOFGEN name to identify the aggchain-proof-gen component AGGCHAINPROOFGEN = "aggchain-proof-gen" )
const KB = 1 << 10 // 1024
Variables ¶
var (
TimeProvider = time.Now
)
var (
ZeroHash = common.HexToHash("0x0")
)
Functions ¶
func BigIntToLittleEndianBytes ¶
BigIntToLittleEndianBytes converts a big.Int to a 32-byte little-endian representation. big.Int is capped to 32 bytes
func BytesToUint32 ¶
BytesToUint32 converts a byte slice to a uint32. If byte slice is shorter than 4 bytes, it is padded with 0s. In case it is longer than 4 bytes, it panics.
func BytesToUint64 ¶
BytesToUint64 converts a byte slice to a uint64
func EstimateSliceCapacity ¶ added in v0.3.0
EstimateSliceCapacity estimates the capacity of a slice based on the total number of elements, the span of interest, and the full span of the range.
Parameters:
- total: The total number of elements.
- span: The span of interest within the range.
- fullSpan: The full span of the range.
Returns:
- An integer representing the estimated slice capacity. If fullSpan is 0, the function returns 0 to avoid division by zero.
func MapSlice ¶ added in v0.5.0
MapSlice transforms a slice of type T into a slice of type R using the provided mapping function f. It's a generic utility that reduces boilerplate when converting between types.
func NewKeyFromKeystore ¶
func NewKeyFromKeystore(cfg types.KeystoreFileConfig) (*ecdsa.PrivateKey, error)
NewKeyFromKeystore creates a private key from a keystore file
func Uint32ToBytes ¶
Uint32ToBytes converts a uint32 to a byte slice in big-endian order
func Uint64ToBigEndianBytes ¶ added in v0.4.0
Uint64ToBigEndianBytes converts a uint64 to a byte slice in big-endian order
func Uint64ToLittleEndianBytes ¶ added in v0.4.0
Uint64ToLittleEndianBytes converts a uint64 to a byte slice in little-endian order
Types ¶
type Config ¶
type Config struct {
// NetworkID is the networkID of the Aggkit being run
NetworkID uint32 `mapstructure:"NetworkID"`
// L2URL is the URL of the L2 node
L2RPC ethermanconfig.RPCClientConfig `mapstructure:"L2RPC"`
}
Config holds the configuration for the Aggkit.
type Logger ¶ added in v0.2.0
type Logger interface {
Panicf(format string, args ...interface{})
Fatalf(format string, args ...interface{})
Info(args ...interface{})
Infof(format string, args ...interface{})
Error(args ...interface{})
Errorf(format string, args ...interface{})
Warn(args ...interface{})
Warnf(format string, args ...interface{})
Debug(args ...interface{})
Debugf(format string, args ...interface{})
}
Logger is an interface that defines the methods to log messages
type RESTConfig ¶ added in v0.5.0
type RESTConfig struct {
// Host specifies the hostname or IP address on which the REST service will listen.
Host string `mapstructure:"Host"`
// Port defines the port number on which the REST service will be accessible.
Port int `mapstructure:"Port"`
// ReadTimeout is the HTTP server read timeout
// check net/http.server.ReadTimeout and net/http.server.ReadHeaderTimeout
ReadTimeout types.Duration `mapstructure:"ReadTimeout"`
// WriteTimeout is the HTTP server write timeout
// check net/http.server.WriteTimeout
WriteTimeout types.Duration `mapstructure:"WriteTimeout"`
// MaxRequestsPerIPAndSecond defines how many requests a single IP can
// send within a single second
MaxRequestsPerIPAndSecond float64 `mapstructure:"MaxRequestsPerIPAndSecond"`
}
RESTConfig contains the configuration settings for the REST service in the Aggkit application.
func (*RESTConfig) Address ¶ added in v0.5.0
func (c *RESTConfig) Address() string
Address constructs and returns the address as a string in the format "host:port".
type RateLimit ¶ added in v0.0.2
type RateLimit struct {
// contains filtered or unexported fields
}
RateLimit is a rate limiter
func NewRateLimit ¶ added in v0.0.2
func NewRateLimit(cfg RateLimitConfig) *RateLimit
NewRateLimit creates a new RateLimit
type RateLimitConfig ¶ added in v0.0.2
type RateLimitConfig struct {
NumRequests int `mapstructure:"NumRequests"`
Interval types.Duration `mapstructure:"Interval"`
}
RateLimitConfig is the configuration for the rate limit, if NumRequests==0 or Interval==0, the rate limit is disabled
func NewRateLimitConfig ¶ added in v0.0.2
func NewRateLimitConfig(numRequests int, period time.Duration) RateLimitConfig
NewRateLimitConfig creates a new RateLimitConfig
func (RateLimitConfig) Enabled ¶ added in v0.0.2
func (r RateLimitConfig) Enabled() bool
Enabled returns true if the rate limit is enabled
func (RateLimitConfig) String ¶ added in v0.0.2
func (r RateLimitConfig) String() string
String returns a string representation of the RateLimitConfig