File tree 1 file changed +39
-0
lines changed
1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ def calculate_tx_num_sum (filename , start_height , end_height ):
2
+ total_tx_num = 0
3
+ in_target_range = False
4
+
5
+ with open (filename , 'r' ) as file :
6
+ for line in file :
7
+ if 'ProposeBlockTxs:' in line :
8
+ if 'block.height =' in line :
9
+ parts = line .split ('block.height =' )
10
+ if len (parts ) > 1 :
11
+ height_str = parts [1 ].split ()[0 ].strip ()
12
+ try :
13
+ height = int (height_str )
14
+ if start_height <= height <= end_height :
15
+ in_target_range = True
16
+ else :
17
+ in_target_range = False
18
+ except ValueError :
19
+ pass
20
+
21
+ if in_target_range and 'tx num =' in line :
22
+ parts = line .split ('tx num =' )
23
+ if len (parts ) > 1 :
24
+ tx_num_str = parts [1 ].strip ()
25
+ try :
26
+ tx_num = int (tx_num_str )
27
+ total_tx_num += tx_num
28
+ except ValueError :
29
+ pass
30
+
31
+ return total_tx_num
32
+
33
+
34
+ filename = 'output.log'
35
+ start_height = 36
36
+ end_height = 79
37
+ sum_tx_num = calculate_tx_num_sum (filename , start_height , end_height )
38
+ print (
39
+ f"Sum of tx num from block.height { start_height } to { end_height } : { sum_tx_num } " )
You can’t perform that action at this time.
0 commit comments