formatting

This commit is contained in:
thatben 2025-03-18 15:55:58 +01:00
parent 002bdc7314
commit 6a8a6c252f
No known key found for this signature in database
GPG Key ID: 62C543548433D43E
6 changed files with 28 additions and 35 deletions

View File

@ -26,7 +26,7 @@ proc step(c: ChainMetrics): Future[?!void] {.async: (raises: []).} =
return success()
method start*(c: ChainMetrics): Future[?!void] {.async.} =
info "Starting..."
info "Starting..."
proc onStep(): Future[?!void] {.async: (raises: []), gcsafe.} =
return await c.step()
@ -40,6 +40,9 @@ method stop*(c: ChainMetrics): Future[?!void] {.async.} =
return success()
proc new*(
T: type ChainMetrics, state: State, metrics: Metrics, marketplace: MarketplaceService
T: type ChainMetrics,
state: State,
metrics: Metrics,
marketplace: MarketplaceService,
): ChainMetrics =
ChainMetrics(state: state, metrics: metrics, marketplace: marketplace)

View File

@ -25,8 +25,8 @@ Options:
--revisitDelay=<m> Delay in minutes after which a node can be revisited [default: 60]
--checkDelay=<m> Delay with which the 'revisitDelay' is checked for all known nodes [default: 10]
--expiryDelay=<m> Delay in minutes after which unresponsive nodes are discarded [default: 1440] (24h)
--ethProvider=<a> Address including http(s) or ws of the eth provider
--marketplaceAddress=<a> Eth address of Codex contracts deployment
--ethProvider=<a> Address including http(s) or ws of the eth provider
--marketplaceAddress=<a> Eth address of Codex contracts deployment
--marketplaceEnable=<e> Set to "1" to enable marketplace metrics [default: 1]
"""

View File

@ -9,15 +9,16 @@ import ../state
logScope:
topics = "marketplace"
type
MarketplaceService* = ref object of Component
state: State
market: ?OnChainMarket
type MarketplaceService* = ref object of Component
state: State
market: ?OnChainMarket
method getRecentSlotFillEvents*(m: MarketplaceService): Future[?!seq[SlotFilled]] {.async: (raises: []), base.} =
method getRecentSlotFillEvents*(
m: MarketplaceService
): Future[?!seq[SlotFilled]] {.async: (raises: []), base.} =
# There is (aprox.) 1 block every 10 seconds.
# 10 seconds * 6 * 60 = 3600 = 1 hour.
let blocksAgo = 6 * 60;
let blocksAgo = 6 * 60
if market =? m.market:
try:
@ -39,16 +40,8 @@ method start*(m: MarketplaceService): Future[?!void] {.async.} =
method stop*(m: MarketplaceService): Future[?!void] {.async.} =
return success()
proc new(
T: type MarketplaceService,
state: State
): MarketplaceService =
return MarketplaceService(
state: state,
market: none(OnChainMarket)
)
proc new(T: type MarketplaceService, state: State): MarketplaceService =
return MarketplaceService(state: state, market: none(OnChainMarket))
proc createMarketplace*(state: State): MarketplaceService =
return MarketplaceService.new(
state
)
return MarketplaceService.new(state)

View File

@ -53,8 +53,9 @@ proc createMetrics*(metricsAddress: IpAddress, metricsPort: Port): Metrics =
proc onNok(value: int64) =
nokNodesGauge.set(value)
proc onSlotFill(value: int64) =
slotFillGauge.set(value)
return Metrics(todoNodes: onTodo, okNodes: onOk, nokNodes: onNok, onSlotFill: onSlotFill)
return
Metrics(todoNodes: onTodo, okNodes: onOk, nokNodes: onNok, onSlotFill: onSlotFill)

View File

@ -24,7 +24,7 @@ suite "ChainMetrics":
state = createMockState()
metrics = createMockMetrics()
marketplace = createMockMarketplaceService()
metrics.slotFill = -1
chain = ChainMetrics.new(state, metrics, marketplace)
@ -75,14 +75,9 @@ suite "ChainMetrics":
metrics.slotFill == 0
test "step should setSlotFill to the length of seq returned from getRecentSlotFillEvents":
let fills = @[
SlotFilled(),
SlotFilled(),
SlotFilled(),
SlotFilled()
]
let fills = @[SlotFilled(), SlotFilled(), SlotFilled(), SlotFilled()]
marketplace.recentSlotFillEventsReturn = success(fills)
marketplace.recentSlotFillEventsReturn = success(fills)
await onStep()

View File

@ -7,11 +7,12 @@ import ../../../codexcrawler/services/marketplace/market
logScope:
topics = "marketplace"
type
MockMarketplaceService* = ref object of MarketplaceService
recentSlotFillEventsReturn*: ?!seq[SlotFilled]
type MockMarketplaceService* = ref object of MarketplaceService
recentSlotFillEventsReturn*: ?!seq[SlotFilled]
method getRecentSlotFillEvents*(m: MockMarketplaceService): Future[?!seq[SlotFilled]] {.async: (raises: []).} =
method getRecentSlotFillEvents*(
m: MockMarketplaceService
): Future[?!seq[SlotFilled]] {.async: (raises: []).} =
return m.recentSlotFillEventsReturn
proc createMockMarketplaceService*(): MockMarketplaceService =