mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-11-29 08:28:50 +00:00
Rename isHighPriority to neverExpires
This commit is contained in:
parent
ff10ce145a
commit
b2da9a4a00
@ -27,7 +27,7 @@ func newMempool(consensus externalapi.Consensus, dagParams *dagconfig.Params) *m
|
|||||||
return mp
|
return mp
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mp *mempool) ValidateAndInsertTransaction(transaction *externalapi.DomainTransaction, isHighPriority bool) (
|
func (mp *mempool) ValidateAndInsertTransaction(transaction *externalapi.DomainTransaction, neverExpires bool) (
|
||||||
acceptedTransactions []*externalapi.DomainTransaction, err error) {
|
acceptedTransactions []*externalapi.DomainTransaction, err error) {
|
||||||
|
|
||||||
panic("mempool.ValidateAndInsertTransaction not implemented") // TODO (Mike)
|
panic("mempool.ValidateAndInsertTransaction not implemented") // TODO (Mike)
|
||||||
|
|||||||
@ -6,12 +6,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type idToTransaction map[externalapi.DomainTransactionID]*mempoolTransaction
|
type idToTransaction map[externalapi.DomainTransactionID]*mempoolTransaction
|
||||||
|
type idToOrphan map[externalapi.DomainTransactionID]*orphanTransaction
|
||||||
|
|
||||||
type mempoolTransaction struct {
|
type mempoolTransaction struct {
|
||||||
transaction *externalapi.DomainTransaction
|
transaction *externalapi.DomainTransaction
|
||||||
parentsInPool idToTransaction
|
parentsInPool idToTransaction
|
||||||
isHighPriority bool
|
neverExpires bool
|
||||||
addAtDAAScore uint64
|
addAtDAAScore uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mt *mempoolTransaction) transactionID() *externalapi.DomainTransactionID {
|
func (mt *mempoolTransaction) transactionID() *externalapi.DomainTransactionID {
|
||||||
@ -20,7 +21,7 @@ func (mt *mempoolTransaction) transactionID() *externalapi.DomainTransactionID {
|
|||||||
|
|
||||||
type orphanTransaction struct {
|
type orphanTransaction struct {
|
||||||
transaction *externalapi.DomainTransaction
|
transaction *externalapi.DomainTransaction
|
||||||
isHighPriority bool
|
neverExpires bool
|
||||||
addedAtDAAScore uint64
|
addedAtDAAScore uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,14 @@
|
|||||||
package mempool
|
package mempool
|
||||||
|
|
||||||
import "github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
import (
|
||||||
|
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
||||||
|
)
|
||||||
|
|
||||||
type previousOutpointToOrphans map[externalapi.DomainOutpoint]idToTransaction
|
type previousOutpointToOrphans map[externalapi.DomainOutpoint]idToOrphan
|
||||||
|
|
||||||
type orphansPool struct {
|
type orphansPool struct {
|
||||||
mempool *mempool
|
mempool *mempool
|
||||||
allOrphans idToTransaction
|
allOrphans idToOrphan
|
||||||
orphanByPreviousOutpoint previousOutpointToOrphans
|
orphanByPreviousOutpoint previousOutpointToOrphans
|
||||||
lastExpireScan uint64
|
lastExpireScan uint64
|
||||||
}
|
}
|
||||||
@ -14,14 +16,14 @@ type orphansPool struct {
|
|||||||
func newOrphansPool(mp *mempool) *orphansPool {
|
func newOrphansPool(mp *mempool) *orphansPool {
|
||||||
return &orphansPool{
|
return &orphansPool{
|
||||||
mempool: mp,
|
mempool: mp,
|
||||||
allOrphans: idToTransaction{},
|
allOrphans: idToOrphan{},
|
||||||
orphanByPreviousOutpoint: previousOutpointToOrphans{},
|
orphanByPreviousOutpoint: previousOutpointToOrphans{},
|
||||||
lastExpireScan: 0,
|
lastExpireScan: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (op *orphansPool) maybeAddOrphan(transaction *externalapi.DomainTransaction,
|
func (op *orphansPool) maybeAddOrphan(transaction *externalapi.DomainTransaction,
|
||||||
missingParents []*externalapi.DomainTransactionID, isHighPriority bool) error {
|
missingParents []*externalapi.DomainTransactionID, neverExpires bool) error {
|
||||||
|
|
||||||
panic("orphansPool.maybeAddOrphan not implemented") // TODO (Mike)
|
panic("orphansPool.maybeAddOrphan not implemented") // TODO (Mike)
|
||||||
}
|
}
|
||||||
@ -36,8 +38,37 @@ func (op *orphansPool) unorphanTransaction(orphanTransactionID *externalapi.Doma
|
|||||||
panic("orphansPool.unorphanTransaction not implemented") // TODO (Mike)
|
panic("orphansPool.unorphanTransaction not implemented") // TODO (Mike)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (op *orphansPool) removeOrphan(orphanTransactionID *externalapi.DomainTransactionID) error {
|
func (op *orphansPool) removeOrphan(orphanTransactionID *externalapi.DomainTransactionID, removeRedeemers bool) {
|
||||||
panic("orphansPool.removeOrphan not implemented") // TODO (Mike)
|
var orphanTransaction *orphanTransaction
|
||||||
|
var ok bool
|
||||||
|
if orphanTransaction, ok = op.allOrphans[*orphanTransactionID]; !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove orphan from allOrphans
|
||||||
|
delete(op.allOrphans, *orphanTransactionID)
|
||||||
|
|
||||||
|
// Remove orphan from all relevant entries in orphanByPreviousOutpoint
|
||||||
|
for _, input := range orphanTransaction.transaction.Inputs {
|
||||||
|
if orphans, ok := op.orphanByPreviousOutpoint[input.PreviousOutpoint]; ok {
|
||||||
|
delete(orphans, orphanTransactionID)
|
||||||
|
if len(orphans) == 0 {
|
||||||
|
delete(op.orphanByPreviousOutpoint, input.PreviousOutpoint)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recursively remove redeemers if requested.
|
||||||
|
// Since the size of the orphan pool is very limited - the recursion depth is properly bound.
|
||||||
|
if removeRedeemers {
|
||||||
|
outpoint := externalapi.DomainOutpoint{TransactionID: *orphanTransactionID}
|
||||||
|
for i := range orphanTransaction.transaction.Outputs {
|
||||||
|
outpoint.Index = uint32(i)
|
||||||
|
for _, orphanRedeemer := range op.orphanByPreviousOutpoint[outpoint] {
|
||||||
|
op.removeOrphan(orphanRedeemer.transactionID(), true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (op *orphansPool) expireOrphanTransactions() error {
|
func (op *orphansPool) expireOrphanTransactions() error {
|
||||||
@ -52,7 +83,7 @@ func (op *orphansPool) expireOrphanTransactions() error {
|
|||||||
|
|
||||||
for _, orphanTransaction := range op.allOrphans {
|
for _, orphanTransaction := range op.allOrphans {
|
||||||
// Never expire high priority transactions
|
// Never expire high priority transactions
|
||||||
if orphanTransaction.isHighPriority {
|
if orphanTransaction.neverExpires {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -48,7 +48,7 @@ func (tp *transactionsPool) expireOldTransactions() error {
|
|||||||
|
|
||||||
for _, mempoolTransaction := range tp.allTransactions {
|
for _, mempoolTransaction := range tp.allTransactions {
|
||||||
// Never expire high priority transactions
|
// Never expire high priority transactions
|
||||||
if mempoolTransaction.isHighPriority {
|
if mempoolTransaction.neverExpires {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user