Skip to content

Commit

Permalink
Fix wrong included slot in INX accepted transactions stream
Browse files Browse the repository at this point in the history
  • Loading branch information
muXxer committed Nov 28, 2023
1 parent 6425aca commit 12fdeac
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 12fdeac

Please sign in to comment.