mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-14 20:03:07 +00:00
add eligibilityEnabled config flag
This commit is contained in:
parent
49b918b852
commit
c4cb4121ed
@ -16,6 +16,7 @@ proc newTestWakuLightpushNode*(
|
||||
switch: Switch,
|
||||
handler: PushMessageHandler,
|
||||
rateLimitSetting: Option[RateLimitSetting] = none[RateLimitSetting](),
|
||||
eligibilityEnabled: bool = false,
|
||||
): Future[WakuLightPush] {.async.} =
|
||||
let
|
||||
peerManager = PeerManager.new(switch)
|
||||
@ -28,7 +29,7 @@ proc newTestWakuLightpushNode*(
|
||||
return proto
|
||||
|
||||
proc newTestWakuLightpushClient*(
|
||||
switch: Switch, reputationEnabled: bool = false
|
||||
): WakuLightPushClient =
|
||||
switch: Switch, reputationEnabled: bool = false
|
||||
): WakuLightPushClient =
|
||||
let peerManager = PeerManager.new(switch, reputationEnabled = reputationEnabled)
|
||||
WakuLightPushClient.new(peerManager, rng)
|
||||
|
||||
@ -513,6 +513,14 @@ hence would have reachability issues.""",
|
||||
name: "reputation"
|
||||
.}: bool
|
||||
|
||||
## Eligibility config
|
||||
eligibilityEnabled* {.
|
||||
desc:
|
||||
"Enable server-side eligibility (proof-of-payment) check for light protocols: true|false",
|
||||
defaultValue: false,
|
||||
name: "eligibility"
|
||||
.}: bool
|
||||
|
||||
## Reliability config
|
||||
reliabilityEnabled* {.
|
||||
desc:
|
||||
|
||||
@ -22,7 +22,7 @@ import
|
||||
../../waku_metadata,
|
||||
./peer_store/peer_storage,
|
||||
./waku_peer_store,
|
||||
../../incentivization/reputation_manager
|
||||
../../incentivization/[reputation_manager, eligibility_manager]
|
||||
|
||||
export waku_peer_store, peer_storage, peers
|
||||
|
||||
@ -97,7 +97,10 @@ type PeerManager* = ref object of RootObj
|
||||
started: bool
|
||||
shardedPeerManagement: bool # temp feature flag
|
||||
onConnectionChange*: ConnectionChangeHandler
|
||||
# clients of light protocols (like Lightpush) may track servers' reputation
|
||||
reputationManager*: Option[ReputationManager]
|
||||
# servers of light protocols (like Lightpush) may track client requests' eligibility
|
||||
eligibilityManager*: Option[EligibilityManager]
|
||||
|
||||
#~~~~~~~~~~~~~~~~~~~#
|
||||
# Helper Functions #
|
||||
@ -1037,6 +1040,7 @@ proc new*(
|
||||
colocationLimit = DefaultColocationLimit,
|
||||
shardedPeerManagement = false,
|
||||
reputationEnabled = false,
|
||||
eligibilityEnabled = false,
|
||||
): PeerManager {.gcsafe.} =
|
||||
let capacity = switch.peerStore.capacity
|
||||
let maxConnections = switch.connManager.inSema.size
|
||||
@ -1117,4 +1121,10 @@ proc new*(
|
||||
else:
|
||||
none(ReputationManager)
|
||||
|
||||
pm.eligibilityManager =
|
||||
if eligibilityEnabled:
|
||||
some(EligibilityManager.new())
|
||||
else:
|
||||
none(EligibilityManager)
|
||||
|
||||
return pm
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user