Skip to content

Commit 28ddf48

Browse files
committed
Allow large block difficulty, but set it to null for PoA (ethers-io#152).
1 parent 96d420e commit 28ddf48

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

providers/provider.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ function checkNumber(number) {
9292
return utils.bigNumberify(number).toNumber();
9393
}
9494

95+
function checkDifficulty(number) {
96+
var value = utils.bigNumberify(number);
97+
98+
try {
99+
value = value.toNumber();
100+
} catch (error) {
101+
value = null;
102+
}
103+
104+
return value;
105+
}
106+
95107
function checkBoolean(value) {
96108
if (typeof(value) === 'boolean') { return value; }
97109
if (typeof(value) === 'string') {
@@ -141,7 +153,7 @@ var formatBlock = {
141153

142154
timestamp: checkNumber,
143155
nonce: allowNull(utils.hexlify),
144-
difficulty: allowNull(checkNumber),
156+
difficulty: checkDifficulty,
145157

146158
gasLimit: utils.bigNumberify,
147159
gasUsed: utils.bigNumberify,

0 commit comments

Comments
 (0)