File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -61,12 +61,22 @@ impl<T: Config> Pallet<T> {
6161 // Ensure the hotkey passes the rate limit.
6262 ensure ! (
6363 Self :: passes_rate_limit_globally(
64- & TransactionType :: SetChildren , // Set children.
6564 & hotkey, // Specific to a hotkey.
65+ netuid, // Specific to a subnet.
66+ & TransactionType :: SetChildren , // Set children.
6667 ) ,
6768 Error :: <T >:: TxRateLimitExceeded
6869 ) ;
6970
71+ // Set last transaction block
72+ let current_block = Self :: get_current_block_as_u64 ( ) ;
73+ Self :: set_last_transaction_block (
74+ & hotkey,
75+ netuid,
76+ & TransactionType :: SetChildren ,
77+ current_block
78+ ) ;
79+
7080 // --- 2. Check that this delegation is not on the root network. Child hotkeys are not valid on root.
7181 ensure ! (
7282 netuid != Self :: get_root_netuid( ) ,
Original file line number Diff line number Diff line change @@ -58,8 +58,11 @@ impl<T: Config> Pallet<T> {
5858 }
5959
6060 /// Check if a transaction should be rate limited globally
61- pub fn passes_rate_limit_globally ( tx_type : & TransactionType , hotkey : & T :: AccountId ) -> bool {
62- let netuid: u16 = u16:: MAX ;
61+ pub fn passes_rate_limit_globally (
62+ hotkey : & T :: AccountId ,
63+ netuid : u16 ,
64+ tx_type : & TransactionType ,
65+ ) -> bool {
6366 let block: u64 = Self :: get_current_block_as_u64 ( ) ;
6467 let limit: u64 = Self :: get_rate_limit ( tx_type) ;
6568 let last_block: u64 = Self :: get_last_transaction_block ( hotkey, netuid, tx_type) ;
You can’t perform that action at this time.
0 commit comments