File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Sources/Web3Core/Structure/Block Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,12 @@ extension Block: Decodable {
8585 }
8686
8787 self . difficulty = try container. decodeHex ( BigUInt . self, forKey: . difficulty)
88- self . totalDifficulty = ( try ? container. decodeHex ( BigUInt . self, forKey: . totalDifficulty) ) ?? . zero
88+ if ( container. contains ( . totalDifficulty) ) {
89+ // Must throw if value is set but it is invalid
90+ self . totalDifficulty = try container. decodeHex ( BigUInt . self, forKey: . totalDifficulty)
91+ } else {
92+ self . totalDifficulty = . zero
93+ }
8994 self . extraData = try container. decodeHex ( Data . self, forKey: . extraData)
9095 self . size = try container. decodeHex ( BigUInt . self, forKey: . size)
9196 self . gasLimit = try container. decodeHex ( BigUInt . self, forKey: . gasLimit)
You can’t perform that action at this time.
0 commit comments