Documentation
¶
Index ¶
- Constants
- func NewEnhancedManager(t *testing.T, manager token2.SelectorManager, tokenDB driver.TokenStore) *enhancedManager
- func TestHotTokenContention(t *testing.T, replicas []EnhancedManager)
- func TestInsufficientTokensManyReplicas(t *testing.T, replicas []EnhancedManager)
- func TestInsufficientTokensOneReplica(t *testing.T, replica EnhancedManager)
- func TestSufficientTokensBigDenominationsManyReplicas(t *testing.T, replicas []EnhancedManager)
- func TestSufficientTokensBigDenominationsOneReplica(t *testing.T, replica EnhancedManager)
- func TestSufficientTokensManyReplicas(t *testing.T, replicas []EnhancedManager)
- func TestSufficientTokensOneReplica(t *testing.T, replica EnhancedManager)
- type EnhancedManager
- type MockIterator
- type MockQueryService
- func (q *MockQueryService) Add(key string, t *token2.UnspentToken)
- func (q *MockQueryService) GetStatus(ctx context.Context, txID string) (token.TxStatus, string, error)
- func (q *MockQueryService) GetTokens(ctx context.Context, inputs ...*token2.ID) ([]*token2.Token, error)
- func (q *MockQueryService) GetUnspentToken(_ context.Context, tokenID *token2.ID) *token2.UnspentToken
- func (q *MockQueryService) GetUnspentTokens(_ context.Context, inputs ...*token2.ID) ([]*token2.UnspentToken, error)
- func (q *MockQueryService) SpendableTokensIteratorBy(ctx context.Context, walletID string, typ token2.Type) (driver.SpendableTokensIterator, error)
- func (q *MockQueryService) UnspentTokensIterator(context.Context) (*token.UnspentTokensIterator, error)
- func (q *MockQueryService) UnspentTokensIteratorBy(_ context.Context, walletID string, _ token2.Type) (driver.UnspentTokensIterator, error)
- func (q *MockQueryService) WarmupCache(walletID, tokenType string)
- type MockVault
- type NoLock
- type TokenFilter
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func NewEnhancedManager ¶
func NewEnhancedManager(t *testing.T, manager token2.SelectorManager, tokenDB driver.TokenStore) *enhancedManager
func TestHotTokenContention ¶ added in v0.24.0
func TestHotTokenContention(t *testing.T, replicas []EnhancedManager)
TestHotTokenContention mirrors the incident reported in #2395: a wallet with a few small tokens and one much larger one, and far more concurrent requests than tokens. Every request asks for CHF1, satisfiable either by a small token directly or by the large one — which recycles most of its value back as a freshly-minted token via deleteTokensAndStoreChange, so at any instant there is exactly one "big" token in the pool. That is the hot token every losing goroutine keeps re-targeting after a lost lock race, absent a per-attempt blacklist (mechanism 1 in #2395) or an anti-join against already-locked tokens (mechanism 3).
Unlike the other cases in this file, callers are expected to also inspect lock-conflict counts (see sherdlock's TestHotTokenContention, which wraps the Locker to record them) and assert on their distribution — this function only asserts the functional invariant that must hold regardless of how contention is distributed: total demand exactly matches the wallet balance, so no error here can be a genuine insufficient-funds; any error is spurious, caused by contention.
func TestInsufficientTokensManyReplicas ¶
func TestInsufficientTokensManyReplicas(t *testing.T, replicas []EnhancedManager)
func TestInsufficientTokensOneReplica ¶
func TestInsufficientTokensOneReplica(t *testing.T, replica EnhancedManager)
func TestSufficientTokensBigDenominationsManyReplicas ¶
func TestSufficientTokensBigDenominationsManyReplicas(t *testing.T, replicas []EnhancedManager)
func TestSufficientTokensBigDenominationsOneReplica ¶
func TestSufficientTokensBigDenominationsOneReplica(t *testing.T, replica EnhancedManager)
func TestSufficientTokensManyReplicas ¶
func TestSufficientTokensManyReplicas(t *testing.T, replicas []EnhancedManager)
func TestSufficientTokensOneReplica ¶
func TestSufficientTokensOneReplica(t *testing.T, replica EnhancedManager)
Types ¶
type EnhancedManager ¶
type EnhancedManager interface {
token2.SelectorManager
TokenSum() (token.Quantity, error)
UpdateTokens(spentTokens []*token.ID, addedTokens []token.UnspentToken) error
}
type MockIterator ¶
type MockIterator struct {
// contains filtered or unexported fields
}
func (*MockIterator) Close ¶
func (m *MockIterator) Close()
func (*MockIterator) Next ¶
func (m *MockIterator) Next() (*token2.UnspentToken, error)
type MockQueryService ¶
type MockQueryService struct {
// contains filtered or unexported fields
}
func NewMockQueryService ¶
func NewMockQueryService() *MockQueryService
func (*MockQueryService) Add ¶
func (q *MockQueryService) Add(key string, t *token2.UnspentToken)
func (*MockQueryService) GetUnspentToken ¶
func (q *MockQueryService) GetUnspentToken(_ context.Context, tokenID *token2.ID) *token2.UnspentToken
func (*MockQueryService) GetUnspentTokens ¶
func (q *MockQueryService) GetUnspentTokens(_ context.Context, inputs ...*token2.ID) ([]*token2.UnspentToken, error)
func (*MockQueryService) SpendableTokensIteratorBy ¶
func (q *MockQueryService) SpendableTokensIteratorBy(ctx context.Context, walletID string, typ token2.Type) (driver.SpendableTokensIterator, error)
func (*MockQueryService) UnspentTokensIterator ¶
func (q *MockQueryService) UnspentTokensIterator(context.Context) (*token.UnspentTokensIterator, error)
func (*MockQueryService) UnspentTokensIteratorBy ¶
func (q *MockQueryService) UnspentTokensIteratorBy(_ context.Context, walletID string, _ token2.Type) (driver.UnspentTokensIterator, error)
func (*MockQueryService) WarmupCache ¶
func (q *MockQueryService) WarmupCache(walletID, tokenType string)
type TokenFilter ¶
func (*TokenFilter) ContainsToken ¶
func (c *TokenFilter) ContainsToken(token *token2.UnspentToken) bool
func (*TokenFilter) ID ¶
func (c *TokenFilter) ID() string