core: Change local-handling to use sender-account instead of tx hashes

This commit is contained in:
Martin Holst Swende
2017-06-30 22:43:26 +02:00
parent a0aa071ca6
commit 67aff49822
2 changed files with 49 additions and 60 deletions

View File

@ -422,7 +422,7 @@ func (l *txPricedList) Removed() {
// Discard finds all the transactions below the given price threshold, drops them
// from the priced list and returs them for further removal from the entire pool.
func (l *txPricedList) Cap(threshold *big.Int, local *txSet) types.Transactions {
func (l *txPricedList) Cap(threshold *big.Int, local *accountSet) types.Transactions {
drop := make(types.Transactions, 0, 128) // Remote underpriced transactions to drop
save := make(types.Transactions, 0, 64) // Local underpriced transactions to keep
@ -440,7 +440,7 @@ func (l *txPricedList) Cap(threshold *big.Int, local *txSet) types.Transactions
break
}
// Non stale transaction found, discard unless local
if local.contains(hash) {
if local.contains(tx) {
save = append(save, tx)
} else {
drop = append(drop, tx)
@ -454,9 +454,9 @@ func (l *txPricedList) Cap(threshold *big.Int, local *txSet) types.Transactions
// Underpriced checks whether a transaction is cheaper than (or as cheap as) the
// lowest priced transaction currently being tracked.
func (l *txPricedList) Underpriced(tx *types.Transaction, local *txSet) bool {
func (l *txPricedList) Underpriced(tx *types.Transaction, local *accountSet) bool {
// Local transactions cannot be underpriced
if local.contains(tx.Hash()) {
if local.contains(tx) {
return false
}
// Discard stale price points if found at the heap start
@ -480,7 +480,7 @@ func (l *txPricedList) Underpriced(tx *types.Transaction, local *txSet) bool {
// Discard finds a number of most underpriced transactions, removes them from the
// priced list and returs them for further removal from the entire pool.
func (l *txPricedList) Discard(count int, local *txSet) types.Transactions {
func (l *txPricedList) Discard(count int, local *accountSet) types.Transactions {
drop := make(types.Transactions, 0, count) // Remote underpriced transactions to drop
save := make(types.Transactions, 0, 64) // Local underpriced transactions to keep
@ -494,7 +494,7 @@ func (l *txPricedList) Discard(count int, local *txSet) types.Transactions {
continue
}
// Non stale transaction found, discard unless local
if local.contains(hash) {
if local.contains(tx) {
save = append(save, tx)
} else {
drop = append(drop, tx)