Skip to content

Commit 65f6207

Browse files
Call "isBadlyGuarded()" of the node.
1 parent 93c958a commit 65f6207

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

testscommon/txcachemocks/accountStateProviderMock.go

+11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"math/big"
55
"sync"
66

7+
"github.com/multiversx/mx-chain-core-go/data"
78
"github.com/multiversx/mx-chain-storage-go/types"
89
)
910

@@ -13,6 +14,7 @@ type AccountStateProviderMock struct {
1314

1415
AccountStateByAddress map[string]*types.AccountState
1516
GetAccountStateCalled func(address []byte) (*types.AccountState, error)
17+
IsBadlyGuardedCalled func(tx data.TransactionHandler) bool
1618
}
1719

1820
// NewAccountStateProviderMock -
@@ -67,6 +69,15 @@ func (mock *AccountStateProviderMock) GetAccountState(address []byte) (*types.Ac
6769
return newDefaultAccountState(), nil
6870
}
6971

72+
// IsBadlyGuarded -
73+
func (mock *AccountStateProviderMock) IsBadlyGuarded(tx data.TransactionHandler) bool {
74+
if mock.IsBadlyGuardedCalled != nil {
75+
return mock.IsBadlyGuardedCalled(tx)
76+
}
77+
78+
return false
79+
}
80+
7081
// IsInterfaceNil -
7182
func (mock *AccountStateProviderMock) IsInterfaceNil() bool {
7283
return mock == nil

txcache/interface.go

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type TxGasHandler interface {
1616
// AccountStateProvider defines the behavior of a component able to provide the state of an account
1717
type AccountStateProvider interface {
1818
GetAccountState(accountKey []byte) (*types.AccountState, error)
19+
IsBadlyGuarded(tx data.TransactionHandler) bool
1920
IsInterfaceNil() bool
2021
}
2122

txcache/selection.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func selectTransactionsFromBunches(accountStateProvider AccountStateProvider, bu
7171
continue
7272
}
7373

74-
shouldSkipTransaction := detectSkippableTransaction(item)
74+
shouldSkipTransaction := detectSkippableTransaction(accountStateProvider, item)
7575
if shouldSkipTransaction {
7676
// Transaction isn't selected, but the sender is still in the game (will contribute with other transactions).
7777
} else {
@@ -104,11 +104,11 @@ func detectSkippableSender(item *transactionsHeapItem) bool {
104104
return false
105105
}
106106

107-
func detectSkippableTransaction(item *transactionsHeapItem) bool {
107+
func detectSkippableTransaction(accountStateProvider AccountStateProvider, item *transactionsHeapItem) bool {
108108
if item.detectLowerNonce() {
109109
return true
110110
}
111-
if item.detectBadlyGuarded() {
111+
if item.detectBadlyGuarded(accountStateProvider) {
112112
return true
113113
}
114114
if item.detectNonceDuplicate() {

txcache/transactionsHeapItem.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,16 @@ func (item *transactionsHeapItem) detectLowerNonce() bool {
157157
return isLowerNonce
158158
}
159159

160-
func (item *transactionsHeapItem) detectBadlyGuarded() bool {
161-
// See MX-16179.
162-
return false
160+
func (item *transactionsHeapItem) detectBadlyGuarded(accountStateProvider AccountStateProvider) bool {
161+
isBadlyGuarded := accountStateProvider.IsBadlyGuarded(item.currentTransaction.Tx)
162+
if isBadlyGuarded {
163+
logSelect.Trace("transactionsHeapItem.detectBadlyGuarded",
164+
"tx", item.currentTransaction.TxHash,
165+
"sender", item.sender,
166+
)
167+
}
168+
169+
return isBadlyGuarded
163170
}
164171

165172
func (item *transactionsHeapItem) detectNonceDuplicate() bool {

0 commit comments

Comments
 (0)