|
51 | 51 |
|
52 | 52 | OnBlockCallback* = |
53 | 53 | proc(data: ForkedTrustedSignedBeaconBlock) {.gcsafe, raises: [].} |
| 54 | + OnBlockGossipCallback* = |
| 55 | + proc(data: ForkedSignedBeaconBlock) {.gcsafe, raises: [].} |
54 | 56 | OnHeadCallback* = |
55 | 57 | proc(data: HeadChangeInfoObject) {.gcsafe, raises: [].} |
56 | 58 | OnReorgCallback* = |
|
233 | 235 |
|
234 | 236 | onBlockAdded*: OnBlockCallback |
235 | 237 | ## On block added callback |
| 238 | + onBlockGossipAdded*: OnBlockGossipCallback |
| 239 | + ## On block gossip added callback |
236 | 240 | onHeadChanged*: OnHeadCallback |
237 | 241 | ## On head changed callback |
238 | 242 | onReorgHappened*: OnReorgCallback |
@@ -341,6 +345,10 @@ type |
341 | 345 | block_root* {.serializedFieldName: "block".}: Eth2Digest |
342 | 346 | optimistic* {.serializedFieldName: "execution_optimistic".}: Option[bool] |
343 | 347 |
|
| 348 | + EventBeaconBlockGossipObject* = object |
| 349 | + slot*: Slot |
| 350 | + block_root* {.serializedFieldName: "block".}: Eth2Digest |
| 351 | + |
344 | 352 | template OnBlockAddedCallback*(kind: static ConsensusFork): auto = |
345 | 353 | when kind == ConsensusFork.Fulu: |
346 | 354 | typedesc[OnFuluBlockAdded] |
@@ -401,6 +409,9 @@ template setFinalizationCb*(dag: ChainDAGRef, cb: OnFinalizedCallback) = |
401 | 409 | template setBlockCb*(dag: ChainDAGRef, cb: OnBlockCallback) = |
402 | 410 | dag.onBlockAdded = cb |
403 | 411 |
|
| 412 | +template setBlockGossipCb*(dag: ChainDAGRef, cb: OnBlockGossipCallback) = |
| 413 | + dag.onBlockGossipAdded = cb |
| 414 | + |
404 | 415 | template setHeadCb*(dag: ChainDAGRef, cb: OnHeadCallback) = |
405 | 416 | dag.onHeadChanged = cb |
406 | 417 |
|
@@ -476,3 +487,11 @@ func init*(t: typedesc[EventBeaconBlockObject], |
476 | 487 | block_root: forkyBlck.root, |
477 | 488 | optimistic: optimistic |
478 | 489 | ) |
| 490 | + |
| 491 | +func init*(t: typedesc[EventBeaconBlockGossipObject], |
| 492 | + v: ForkedSignedBeaconBlock): EventBeaconBlockGossipObject = |
| 493 | + withBlck(v): |
| 494 | + EventBeaconBlockGossipObject( |
| 495 | + slot: forkyBlck.message.slot, |
| 496 | + block_root: forkyBlck.root |
| 497 | + ) |
0 commit comments