Skip to content

Commit 8d64dc8

Browse files
Fixed by PR review.
1 parent b069ed5 commit 8d64dc8

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Sources/web3swift/Web3/Web3+GasOracle.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ extension Web3 {
2222
/// Ethereum scope shortcut
2323
private var eth: web3.Eth { web3Provider.eth }
2424

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
2727

2828
/// Count of transactions to filter block for tip calculation
29-
public private(set) var transactionsCount: BigUInt
29+
public private(set) var transactionCount: BigUInt
3030

3131
/// Oracle initializer
3232
/// - Parameters:
3333
/// - provider: Web3 Ethereum provider
34-
/// - blocksCount: Count of block to caltulate statistics
34+
/// - blocksCount: Count of block to calculate statistics
3535
/// - 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) {
3737
self.web3Provider = provider
38-
self.blocksCount = blocksCount
39-
self.transactionsCount = transactionsCount
38+
self.blockCount = blockCount
39+
self.transactionCount = transactionCount
4040
}
4141

4242
private func calcBaseFee(for block: Block?) -> BigUInt {
@@ -70,7 +70,7 @@ extension Web3 {
7070
// TODO: Make me work with cache
7171
repeat {
7272
block = try eth.getBlockByNumber(latestBlockNumber, fullTransactions: true)
73-
} while block.transactions.count < transactionsCount
73+
} while block.transactions.count < transactionCount
7474

7575
// Storing last block to calculate baseFee of the next block
7676
latestBlock = block
@@ -92,7 +92,7 @@ extension Web3 {
9292
// Assigning last block to object var to predict baseFee of the next block
9393
latestBlock = try eth.getBlockByNumber(latestBlockNumber)
9494
// TODO: Make me work with cache
95-
let lastNthBlocksBaseFees = try (latestBlockNumber - blocksCount ... latestBlockNumber)
95+
let lastNthBlocksBaseFees = try (latestBlockNumber - blockCount ... latestBlockNumber)
9696
.map { try eth.getBlockByNumber($0) }
9797
.filter { !$0.transactions.isEmpty }
9898
.map { $0.baseFeePerGas }
@@ -106,7 +106,7 @@ extension Web3 {
106106
// Assigning last block to object var to predict baseFee of the next block
107107
latestBlock = try eth.getBlockByNumber(latestBlockNumber)
108108
// TODO: Make me work with cache
109-
let lastNthBlockGasPrice = try (latestBlockNumber - blocksCount ... latestBlockNumber)
109+
let lastNthBlockGasPrice = try (latestBlockNumber - blockCount ... latestBlockNumber)
110110
.map { try eth.getBlockByNumber($0, fullTransactions: true) }
111111
.flatMap { b -> [EthereumTransaction] in
112112
b.transactions.compactMap { t -> EthereumTransaction? in
@@ -141,7 +141,7 @@ public extension Web3.Oracle {
141141
///
142142
/// Normalized means that most high and most low value were droped from calculation.
143143
///
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
145145
///
146146
/// - Parameter statistic: Statistic to apply for tip calculation
147147
/// - Returns: Suggested tip amount according to statistic, nil if failed to perdict

0 commit comments

Comments
 (0)