Skip to content

Commit fd82fab

Browse files
committed
fix: use gouroboros logic for Byron block slot
1 parent 1626711 commit fd82fab

File tree

1 file changed

+13
-32
lines changed

1 file changed

+13
-32
lines changed

input/chainsync/chainsync.go

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,17 @@ import (
2828
)
2929

3030
type ChainSync struct {
31-
oConn *ouroboros.Connection
32-
network string
33-
networkMagic uint32
34-
address string
35-
socketPath string
36-
ntcTcp bool
37-
intersectTip bool
38-
intersectPoints []ocommon.Point
39-
includeCbor bool
40-
errorChan chan error
41-
eventChan chan event.Event
42-
byronEpochBaseSlot uint64
43-
byronEpochSlot uint64
31+
oConn *ouroboros.Connection
32+
network string
33+
networkMagic uint32
34+
address string
35+
socketPath string
36+
ntcTcp bool
37+
intersectTip bool
38+
intersectPoints []ocommon.Point
39+
includeCbor bool
40+
errorChan chan error
41+
eventChan chan event.Event
4442
}
4543

4644
// New returns a new ChainSync object with the specified options applied
@@ -179,25 +177,8 @@ func (c *ChainSync) handleRollForward(blockType uint, blockData interface{}, tip
179177
evt := event.New("chainsync.block", time.Now(), NewBlockEvent(v, c.includeCbor))
180178
c.eventChan <- evt
181179
case ledger.BlockHeader:
182-
var blockSlot uint64
183-
var blockHash []byte
184-
switch blockType {
185-
case ledger.BLOCK_TYPE_BYRON_EBB:
186-
h := blockData.(*ledger.ByronEpochBoundaryBlockHeader)
187-
if c.byronEpochSlot > 0 {
188-
c.byronEpochBaseSlot += c.byronEpochSlot + 1
189-
}
190-
blockSlot = c.byronEpochBaseSlot
191-
blockHash, _ = hex.DecodeString(h.Hash())
192-
case ledger.BLOCK_TYPE_BYRON_MAIN:
193-
h := blockData.(*ledger.ByronMainBlockHeader)
194-
c.byronEpochSlot = uint64(h.ConsensusData.SlotId.Slot)
195-
blockSlot = c.byronEpochBaseSlot + c.byronEpochSlot
196-
blockHash, _ = hex.DecodeString(h.Hash())
197-
default:
198-
blockSlot = v.SlotNumber()
199-
blockHash, _ = hex.DecodeString(v.Hash())
200-
}
180+
blockSlot := v.SlotNumber()
181+
blockHash, _ := hex.DecodeString(v.Hash())
201182
block, err := c.oConn.BlockFetch().Client.GetBlock(ocommon.Point{Slot: blockSlot, Hash: blockHash})
202183
if err != nil {
203184
return err

0 commit comments

Comments
 (0)