@@ -83,23 +83,23 @@ extension Web3 {
83
83
}
84
84
}
85
85
86
- private func suggestGasValues( ) throws -> FeeHistory {
86
+ private func suggestGasValues( ) async throws -> FeeHistory {
87
87
// This is some kind of cache.
88
88
// It stores about 9 seconds, than it rewrites it with newer data.
89
89
// TODO: Disabled until 3.0 version, coz `distance` available from iOS 13.
90
90
// guard feeHistory == nil, forceDropCache, feeHistory!.timestamp.distance(to: Date()) > cacheTimeout else { return feeHistory! }
91
91
92
- return try eth. feeHistory ( blockCount: blockCount, block: block. hexValue, percentiles: percentiles)
92
+ return try await eth. feeHistory ( blockCount: blockCount, block: block. hexValue, percentiles: percentiles)
93
93
}
94
94
95
95
/// Suggesting tip values
96
96
/// - Returns: `[percentile_1, percentile_2, percentile_3, ...].count == self.percentile.count`
97
97
/// by default there's 3 percentile.
98
- private func suggestTipValue( ) throws -> [ BigUInt ] {
98
+ private func suggestTipValue( ) async throws -> [ BigUInt ] {
99
99
var rearrengedArray : [ [ BigUInt ] ] = [ ]
100
100
101
101
/// reaarange `[[min, middle, max]]` to `[[min], [middle], [max]]`
102
- try suggestGasValues ( ) . reward
102
+ try await suggestGasValues ( ) . reward
103
103
. forEach { percentiles in
104
104
percentiles. enumerated ( ) . forEach { ( index, percentile) in
105
105
/// if `rearrengedArray` have not that enough items
@@ -116,23 +116,25 @@ extension Web3 {
116
116
return soft ( twoDimentsion: rearrengedArray)
117
117
}
118
118
119
- private func suggestBaseFee( ) throws -> [ BigUInt ] {
120
- self . feeHistory = try suggestGasValues ( )
119
+ private func suggestBaseFee( ) async throws -> [ BigUInt ] {
120
+ self . feeHistory = try await suggestGasValues ( )
121
121
return calculatePercentiles ( for: feeHistory!. baseFeePerGas)
122
122
}
123
123
124
- private func suggestGasFeeLegacy( ) throws -> [ BigUInt ] {
124
+ private func suggestGasFeeLegacy( ) async throws -> [ BigUInt ] {
125
125
var latestBlockNumber : BigUInt = 0
126
126
switch block {
127
- case . latest: latestBlockNumber = try eth. getBlockNumber ( )
127
+ case . latest: latestBlockNumber = try await eth. getBlockNumber ( )
128
128
case let . exact( number) : latestBlockNumber = number
129
129
}
130
130
131
131
guard latestBlockNumber != 0 else { return [ ] }
132
132
133
133
// TODO: Make me work with cache
134
134
let lastNthBlockGasPrice = try ( latestBlockNumber - blockCount ... latestBlockNumber)
135
- . map { try eth. getBlockByNumber ( $0, fullTransactions: true ) }
135
+ . map {
136
+ try eth. getBlockByNumber ( $0, fullTransactions: true )
137
+ }
136
138
. flatMap { b -> [ EthereumTransaction ] in
137
139
b. transactions. compactMap { t -> EthereumTransaction ? in
138
140
guard case let . transaction( transaction) = t else { return nil }
0 commit comments