@@ -22,21 +22,21 @@ extension Web3 {
22
22
/// Ethereum scope shortcut
23
23
private var eth : web3 . Eth { web3Provider. eth }
24
24
25
- /// Count of block to calculate statistics
26
- public private( set) var blocksCount : BigUInt
25
+ /// Count of blocks to calculate statistics
26
+ public private( set) var blockCount : BigUInt
27
27
28
28
/// Count of transactions to filter block for tip calculation
29
- public private( set) var transactionsCount : BigUInt
29
+ public private( set) var transactionCount : BigUInt
30
30
31
31
/// Oracle initializer
32
32
/// - Parameters:
33
33
/// - provider: Web3 Ethereum provider
34
- /// - blocksCount: Count of block to caltulate statistics
34
+ /// - blocksCount: Count of block to calculate statistics
35
35
/// - transactionsCount: Count of transacrtions to filter block for tip calculation
36
- public init ( _ provider: web3 , blocksCount : BigUInt = 20 , transactionsCount : BigUInt = 50 ) {
36
+ public init ( _ provider: web3 , blockCount : BigUInt = 20 , transactionCount : BigUInt = 50 ) {
37
37
self . web3Provider = provider
38
- self . blocksCount = blocksCount
39
- self . transactionsCount = transactionsCount
38
+ self . blockCount = blockCount
39
+ self . transactionCount = transactionCount
40
40
}
41
41
42
42
private func calcBaseFee( for block: Block ? ) -> BigUInt {
@@ -70,7 +70,7 @@ extension Web3 {
70
70
// TODO: Make me work with cache
71
71
repeat {
72
72
block = try eth. getBlockByNumber ( latestBlockNumber, fullTransactions: true )
73
- } while block. transactions. count < transactionsCount
73
+ } while block. transactions. count < transactionCount
74
74
75
75
// Storing last block to calculate baseFee of the next block
76
76
latestBlock = block
@@ -92,7 +92,7 @@ extension Web3 {
92
92
// Assigning last block to object var to predict baseFee of the next block
93
93
latestBlock = try eth. getBlockByNumber ( latestBlockNumber)
94
94
// TODO: Make me work with cache
95
- let lastNthBlocksBaseFees = try ( latestBlockNumber - blocksCount ... latestBlockNumber)
95
+ let lastNthBlocksBaseFees = try ( latestBlockNumber - blockCount ... latestBlockNumber)
96
96
. map { try eth. getBlockByNumber ( $0) }
97
97
. filter { !$0. transactions. isEmpty }
98
98
. map { $0. baseFeePerGas }
@@ -106,7 +106,7 @@ extension Web3 {
106
106
// Assigning last block to object var to predict baseFee of the next block
107
107
latestBlock = try eth. getBlockByNumber ( latestBlockNumber)
108
108
// TODO: Make me work with cache
109
- let lastNthBlockGasPrice = try ( latestBlockNumber - blocksCount ... latestBlockNumber)
109
+ let lastNthBlockGasPrice = try ( latestBlockNumber - blockCount ... latestBlockNumber)
110
110
. map { try eth. getBlockByNumber ( $0, fullTransactions: true ) }
111
111
. flatMap { b -> [ EthereumTransaction ] in
112
112
b. transactions. compactMap { t -> EthereumTransaction ? in
@@ -141,7 +141,7 @@ public extension Web3.Oracle {
141
141
///
142
142
/// Normalized means that most high and most low value were droped from calculation.
143
143
///
144
- /// Method will takes in accounting a latest block that have transactions included more than ` transactionsCount` property.
144
+ /// Method calculates the suggested tip based on the most recent block that contains more than transactionsCount transactions
145
145
///
146
146
/// - Parameter statistic: Statistic to apply for tip calculation
147
147
/// - Returns: Suggested tip amount according to statistic, nil if failed to perdict
0 commit comments