Open levonpetrosyan93 opened 3 months ago
The changes introduce enhancements to the ClientModel
, SparkModel
, and TransactionTableModel
classes, focusing on improved locking mechanisms and caching strategies. New member variables for caching block data and mintable amounts have been added. The locking approach has shifted from blocking to non-blocking attempts, allowing for early returns if locks cannot be acquired. This aims to enhance performance and responsiveness in multi-threaded scenarios without altering existing method signatures or overall class structures.
Files | Change Summary |
---|---|
src/qt/clientmodel.cpp |
Added cachedNumBlocks and cachedLastBlockDate . Updated locking to TRY_LOCK in multiple methods. |
src/qt/clientmodel.h |
Added mutable std::atomic<int> cachedNumBlocks; and mutable QDateTime cachedLastBlockDate; . |
src/qt/sparkmodel.cpp |
Updated getMintableSparkAmount to use TRY_LOCK . Returns cached amount if locks cannot be acquired. |
src/qt/sparkmodel.h |
Added mutable std::atomic<CAmount> cachedMintableSparkAmount; . |
src/qt/transactiontablemodel.cpp |
Added cachedUpdatedTx . Updated methods to use TRY_LOCK for wallet transactions. |
src/qt/transactiontablemodel.h |
Added #include "uint256.h" for transaction handling. |
sequenceDiagram
participant User
participant ClientModel
participant SparkModel
participant TransactionTableModel
User->>ClientModel: Request block data
ClientModel->>ClientModel: TRY_LOCK for access
alt Lock acquired
ClientModel-->>User: Provide cachedNumBlocks
else Lock not acquired
ClientModel-->>User: Return cached value
end
User->>SparkModel: Request mintable amount
SparkModel->>SparkModel: TRY_LOCK for wallet access
alt Lock acquired
SparkModel-->>User: Provide cachedMintableSparkAmount
else Lock not acquired
SparkModel-->>User: Return cached value
end
User->>TransactionTableModel: Request transaction updates
TransactionTableModel->>TransactionTableModel: TRY_LOCK for wallet transactions
alt Lock acquired
TransactionTableModel-->>User: Provide transaction updates
else Lock not acquired
TransactionTableModel-->>User: Return queued updates
end
🐇 "In the garden where data flows,
New caches sprout where the block chain grows.
With locks that try, and values that stay,
Our models dance in a seamless ballet.
Hoppity hop, let the threads intertwine,
A swift little rabbit, oh how we shine!" 🐇
GUI
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?