Skip to content

Commit 58ed367

Browse files
author
h33min.kim
committed
modified Block struct
- modified to allow an optional type of 'totalDifficulty' - because 'totalDifficulty' was removed from Ethereum official Blockschema
1 parent a8f2c01 commit 58ed367

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Sources/Web3Core/Structure/Block/Block.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public struct Block {
2424
public var receiptsRoot: Data
2525
public var miner: EthereumAddress? // MARK: This is NOT optional in web3js
2626
public var difficulty: BigUInt
27-
public var totalDifficulty: BigUInt
27+
public var totalDifficulty: BigUInt? // MARK by JoshKim: Removed from Ethereum official Blockschema (https://github.com/ethereum/execution-apis/commit/9e16d5e76a554c733613a2db631130166e2d8725)
2828
public var extraData: Data
2929
public var size: BigUInt
3030
public var gasLimit: BigUInt
@@ -83,7 +83,7 @@ extension Block: Decodable {
8383
}
8484

8585
self.difficulty = try container.decodeHex(BigUInt.self, forKey: .difficulty)
86-
self.totalDifficulty = try container.decodeHex(BigUInt.self, forKey: .totalDifficulty)
86+
self.totalDifficulty = try? container.decodeHex(BigUInt.self, forKey: .totalDifficulty)
8787
self.extraData = try container.decodeHex(Data.self, forKey: .extraData)
8888
self.size = try container.decodeHex(BigUInt.self, forKey: .size)
8989
self.gasLimit = try container.decodeHex(BigUInt.self, forKey: .gasLimit)

0 commit comments

Comments
 (0)