Skip to content

Commit

Permalink
Merge pull request #576 from iotaledger/fix/wrong-slot-accepted-trans…
Browse files Browse the repository at this point in the history
…actions

Fix wrong included slot in INX accepted transactions stream
  • Loading branch information
muXxer authored Nov 28, 2023
2 parents 6425aca + 12fdeac commit b83d5f4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions components/inx/server_utxo.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@ import (
iotago "github.com/iotaledger/iota.go/v4"
)

func NewLedgerOutput(o *utxoledger.Output) (*inx.LedgerOutput, error) {
func NewLedgerOutput(o *utxoledger.Output, slotIncluded ...iotago.SlotIndex) (*inx.LedgerOutput, error) {
latestCommitment := deps.Protocol.MainEngineInstance().SyncManager.LatestCommitment()

includedSlot := o.SlotBooked()
if len(slotIncluded) > 0 {
includedSlot = slotIncluded[0]
}

l := &inx.LedgerOutput{
OutputId: inx.NewOutputId(o.OutputID()),
BlockId: inx.NewBlockId(o.BlockID()),
SlotBooked: uint32(o.SlotBooked()),
SlotBooked: uint32(includedSlot),
Output: &inx.RawOutput{
Data: o.Bytes(),
},
Expand All @@ -32,7 +37,6 @@ func NewLedgerOutput(o *utxoledger.Output) (*inx.LedgerOutput, error) {
},
}

includedSlot := o.SlotBooked()
if includedSlot > 0 &&
includedSlot <= latestCommitment.Slot() &&
includedSlot >= deps.Protocol.CommittedAPI().ProtocolParameters().GenesisSlot() {
Expand Down Expand Up @@ -394,7 +398,8 @@ func (s *Server) ListenToAcceptedTransactions(_ *inx.NoParams, srv inx.INX_Liste
return nil
}

inxOutput, err := NewLedgerOutput(output)
// we need to pass the slot of the accepted transaction here, because the "SlotBooked" in the output is 0.
inxOutput, err := NewLedgerOutput(output, slot)
if err != nil {
return err
}
Expand Down

0 comments on commit b83d5f4

Please sign in to comment.