diff --git a/domain/miningmanager/mempool/mempool_utxo_set.go b/domain/miningmanager/mempool/mempool_utxo_set.go index bbd2e5f97..390fe7afe 100644 --- a/domain/miningmanager/mempool/mempool_utxo_set.go +++ b/domain/miningmanager/mempool/mempool_utxo_set.go @@ -19,18 +19,21 @@ func newMempoolUTXOSet(mp *mempool) *mempoolUTXOSet { } } -func (mpus *mempoolUTXOSet) getParentsInPool(transaction *model.MempoolTransaction) (model.ParentUTXOsInPool, error) { - //parents := model.ParentUTXOsInPool{} +func (mpus *mempoolUTXOSet) getParentsInPool(transaction *model.MempoolTransaction) model.ParentUTXOsInPool { + parentsInPool := model.ParentUTXOsInPool{} - //outpoint := &externalapi.DomainOutpoint{ - // TransactionID: *transaction.TransactionID(), - //} - //for i, input := transaction.Transaction.Inputs{ - // outpoint.Index = i - // utxo, ok := mpus.getOutpoint(outpoint) - //} + outpoint := &externalapi.DomainOutpoint{ + TransactionID: *transaction.TransactionID(), + } + for i := range transaction.Transaction.Inputs { + outpoint.Index = uint32(i) + utxo, ok := mpus.getOutpoint(outpoint) + if ok { + parentsInPool.Set(i, utxo) + } + } - panic("mempoolUTXOSet.getParentsInPool not implemented") // TODO (Mike) + return parentsInPool } func (mpus *mempoolUTXOSet) addTransaction(transaction *model.MempoolTransaction) error { diff --git a/domain/miningmanager/mempool/model/parent_utxos_in_pool.go b/domain/miningmanager/mempool/model/parent_utxos_in_pool.go index b451503f3..c17f149ce 100644 --- a/domain/miningmanager/mempool/model/parent_utxos_in_pool.go +++ b/domain/miningmanager/mempool/model/parent_utxos_in_pool.go @@ -6,11 +6,11 @@ import "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" // The utxos are indexed by transaction output index, for convenient access. type ParentUTXOsInPool map[int]externalapi.UTXOEntry -func (pip ParentUTXOsInPool) GetForIndex(index int) (externalapi.UTXOEntry, bool) { +func (pip ParentUTXOsInPool) Get(index int) (externalapi.UTXOEntry, bool) { utxoEntry, ok := pip[index] return utxoEntry, ok } -func (pip ParentUTXOsInPool) SetIndex(index int, utxoEntry externalapi.UTXOEntry) { +func (pip ParentUTXOsInPool) Set(index int, utxoEntry externalapi.UTXOEntry) { pip[index] = utxoEntry }