@@ -83,7 +83,9 @@ func (c *ChainSync) Start() error {
83
83
}
84
84
if c .bulkMode && ! c .intersectTip && c .oConn .BlockFetch () != nil {
85
85
var err error
86
- c .bulkRangeStart , c .bulkRangeEnd , err = c .oConn .ChainSync ().Client .GetAvailableBlockRange (c .intersectPoints )
86
+ c .bulkRangeStart , c .bulkRangeEnd , err = c .oConn .ChainSync ().Client .GetAvailableBlockRange (
87
+ c .intersectPoints ,
88
+ )
87
89
if err != nil {
88
90
return err
89
91
}
@@ -142,7 +144,11 @@ func (c *ChainSync) setupConnection() error {
142
144
// If network has well-known public root address/port, use those as our dial default
143
145
if network .PublicRootAddress != "" && network .PublicRootPort > 0 {
144
146
dialFamily = "tcp"
145
- dialAddress = fmt .Sprintf ("%s:%d" , network .PublicRootAddress , network .PublicRootPort )
147
+ dialAddress = fmt .Sprintf (
148
+ "%s:%d" ,
149
+ network .PublicRootAddress ,
150
+ network .PublicRootPort ,
151
+ )
146
152
useNtn = true
147
153
}
148
154
}
@@ -199,13 +205,25 @@ func (c *ChainSync) setupConnection() error {
199
205
return nil
200
206
}
201
207
202
- func (c * ChainSync ) handleRollBackward (point ocommon.Point , tip ochainsync.Tip ) error {
203
- evt := event .New ("chainsync.rollback" , time .Now (), nil , NewRollbackEvent (point ))
208
+ func (c * ChainSync ) handleRollBackward (
209
+ point ocommon.Point ,
210
+ tip ochainsync.Tip ,
211
+ ) error {
212
+ evt := event .New (
213
+ "chainsync.rollback" ,
214
+ time .Now (),
215
+ nil ,
216
+ NewRollbackEvent (point ),
217
+ )
204
218
c .eventChan <- evt
205
219
return nil
206
220
}
207
221
208
- func (c * ChainSync ) handleRollForward (blockType uint , blockData interface {}, tip ochainsync.Tip ) error {
222
+ func (c * ChainSync ) handleRollForward (
223
+ blockType uint ,
224
+ blockData interface {},
225
+ tip ochainsync.Tip ,
226
+ ) error {
209
227
switch v := blockData .(type ) {
210
228
case ledger.Block :
211
229
evt := event .New ("chainsync.block" , time .Now (), NewBlockContext (v , c .networkMagic ), NewBlockEvent (v , c .includeCbor ))
@@ -230,13 +248,34 @@ func (c *ChainSync) handleRollForward(blockType uint, blockData interface{}, tip
230
248
}
231
249
232
250
func (c * ChainSync ) handleBlockFetchBlock (block ledger.Block ) error {
233
- blockEvt := event .New ("chainsync.block" , time .Now (), NewBlockContext (block , c .networkMagic ), NewBlockEvent (block , c .includeCbor ))
251
+ blockEvt := event .New (
252
+ "chainsync.block" ,
253
+ time .Now (),
254
+ NewBlockContext (block , c .networkMagic ),
255
+ NewBlockEvent (block , c .includeCbor ),
256
+ )
234
257
c .eventChan <- blockEvt
235
258
for t , transaction := range block .Transactions () {
236
- txEvt := event .New ("chainsync.transaction" , time .Now (), NewTransactionContext (block , transaction , uint32 (t ), c .networkMagic ), NewTransactionEvent (block , transaction , c .includeCbor ))
259
+ txEvt := event .New (
260
+ "chainsync.transaction" ,
261
+ time .Now (),
262
+ NewTransactionContext (
263
+ block ,
264
+ transaction ,
265
+ uint32 (t ),
266
+ c .networkMagic ,
267
+ ),
268
+ NewTransactionEvent (block , transaction , c .includeCbor ),
269
+ )
237
270
c .eventChan <- txEvt
238
271
}
239
- c .updateStatus (block .SlotNumber (), block .BlockNumber (), block .Hash (), c .bulkRangeEnd .Slot , hex .EncodeToString (c .bulkRangeEnd .Hash ))
272
+ c .updateStatus (
273
+ block .SlotNumber (),
274
+ block .BlockNumber (),
275
+ block .Hash (),
276
+ c .bulkRangeEnd .Slot ,
277
+ hex .EncodeToString (c .bulkRangeEnd .Hash ),
278
+ )
240
279
// Start normal chain-sync if we've reached the last block of our bulk range
241
280
if block .SlotNumber () == c .bulkRangeEnd .Slot {
242
281
if err := c .oConn .ChainSync ().Client .Sync ([]ocommon.Point {c .bulkRangeEnd }); err != nil {
@@ -246,7 +285,13 @@ func (c *ChainSync) handleBlockFetchBlock(block ledger.Block) error {
246
285
return nil
247
286
}
248
287
249
- func (c * ChainSync ) updateStatus (slotNumber uint64 , blockNumber uint64 , blockHash string , tipSlotNumber uint64 , tipBlockHash string ) {
288
+ func (c * ChainSync ) updateStatus (
289
+ slotNumber uint64 ,
290
+ blockNumber uint64 ,
291
+ blockHash string ,
292
+ tipSlotNumber uint64 ,
293
+ tipBlockHash string ,
294
+ ) {
250
295
// Determine if we've reached the chain tip
251
296
if ! c .status .TipReached {
252
297
// Make sure we're past the end slot in any bulk range, since we don't update the tip during bulk sync
0 commit comments