@@ -44,9 +44,11 @@ type ChainSync struct {
44
44
}
45
45
46
46
type ChainSyncStatus struct {
47
- SlotNumber uint64
48
- BlockNumber uint64
49
- BlockHash string
47
+ SlotNumber uint64
48
+ BlockNumber uint64
49
+ BlockHash string
50
+ TipSlotNumber uint64
51
+ TipBlockHash string
50
52
}
51
53
52
54
type StatusUpdateFunc func (ChainSyncStatus )
@@ -187,7 +189,7 @@ func (c *ChainSync) handleRollForward(blockType uint, blockData interface{}, tip
187
189
case ledger.Block :
188
190
evt := event .New ("chainsync.block" , time .Now (), NewBlockEvent (v , c .includeCbor ))
189
191
c .eventChan <- evt
190
- c .updateStatus (v .SlotNumber (), v .BlockNumber (), v .Hash ())
192
+ c .updateStatus (v .SlotNumber (), v .BlockNumber (), v .Hash (), tip . Point . Slot , hex . EncodeToString ( tip . Point . Hash ) )
191
193
case ledger.BlockHeader :
192
194
blockSlot := v .SlotNumber ()
193
195
blockHash , _ := hex .DecodeString (v .Hash ())
@@ -201,15 +203,17 @@ func (c *ChainSync) handleRollForward(blockType uint, blockData interface{}, tip
201
203
txEvt := event .New ("chainsync.transaction" , time .Now (), NewTransactionEvent (block , transaction , c .includeCbor ))
202
204
c .eventChan <- txEvt
203
205
}
204
- c .updateStatus (v .SlotNumber (), v .BlockNumber (), v .Hash ())
206
+ c .updateStatus (v .SlotNumber (), v .BlockNumber (), v .Hash (), tip . Point . Slot , hex . EncodeToString ( tip . Point . Hash ) )
205
207
}
206
208
return nil
207
209
}
208
210
209
- func (c * ChainSync ) updateStatus (slotNumber uint64 , blockNumber uint64 , blockHash string ) {
211
+ func (c * ChainSync ) updateStatus (slotNumber uint64 , blockNumber uint64 , blockHash string , tipSlotNumber uint64 , tipBlockHash string ) {
210
212
c .status .SlotNumber = slotNumber
211
213
c .status .BlockNumber = blockNumber
212
214
c .status .BlockHash = blockHash
215
+ c .status .TipSlotNumber = tipSlotNumber
216
+ c .status .TipBlockHash = tipBlockHash
213
217
if c .statusUpdateFunc != nil {
214
218
c .statusUpdateFunc (* (c .status ))
215
219
}
0 commit comments