Files
zeekayandHanzo Dev b1cc108c9f gofmt
Co-authored-by: Hanzo Dev <[email protected]>
2026-09-08 01:51:51 -07:00

41 lines
1.3 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package throttling
import (
"sync"
"github.com/luxfi/ids"
"github.com/luxfi/log"
validators "github.com/luxfi/validators"
)
// Used by the sybil-safe inbound and outbound message throttlers
type MsgByteThrottlerConfig struct {
VdrAllocSize uint64 `json:"vdrAllocSize"`
AtLargeAllocSize uint64 `json:"atLargeAllocSize"`
NodeMaxAtLargeBytes uint64 `json:"nodeMaxAtLargeBytes"`
}
// Used by the sybil-safe inbound and outbound message throttlers
type commonMsgThrottler struct {
log log.Logger
lock sync.Mutex
vdrs validators.Manager
// Max number of bytes that can be taken from the
// at-large byte allocation by a given node.
nodeMaxAtLargeBytes uint64
// Number of bytes left in the validator byte allocation.
// Initialized to [maxVdrBytes].
remainingVdrBytes uint64
// Number of bytes left in the at-large byte allocation
remainingAtLargeBytes uint64
// Node ID --> Bytes they've taken from the validator allocation
nodeToVdrBytesUsed map[ids.NodeID]uint64
// Node ID --> Bytes they've taken from the at-large allocation
nodeToAtLargeBytesUsed map[ids.NodeID]uint64
// Max number of unprocessed bytes from validators
maxVdrBytes uint64
}