@@ -210,22 +210,19 @@ func (self *ethApi) GetTransactionCount(req *shared.Request) (interface{}, error
210
210
}
211
211
212
212
count := self .xeth .AtStateNum (args .BlockNumber ).TxCountAt (args .Address )
213
- return newHexNum ( big . NewInt ( int64 ( count )). Bytes () ), nil
213
+ return fmt . Sprintf ( "%#x" , count ), nil
214
214
}
215
215
216
216
func (self * ethApi ) GetBlockTransactionCountByHash (req * shared.Request ) (interface {}, error ) {
217
217
args := new (HashArgs )
218
218
if err := self .codec .Decode (req .Params , & args ); err != nil {
219
219
return nil , shared .NewDecodeParamError (err .Error ())
220
220
}
221
-
222
- raw := self .xeth .EthBlockByHash (args .Hash )
223
- block := NewBlockRes (raw , self .xeth .Td (raw .Hash ()), false )
221
+ block := self .xeth .EthBlockByHash (args .Hash )
224
222
if block == nil {
225
223
return nil , nil
226
- } else {
227
- return newHexNum (big .NewInt (int64 (len (block .Transactions ))).Bytes ()), nil
228
224
}
225
+ return fmt .Sprintf ("%#x" , len (block .Transactions ())), nil
229
226
}
230
227
231
228
func (self * ethApi ) GetBlockTransactionCountByNumber (req * shared.Request ) (interface {}, error ) {
@@ -234,13 +231,11 @@ func (self *ethApi) GetBlockTransactionCountByNumber(req *shared.Request) (inter
234
231
return nil , shared .NewDecodeParamError (err .Error ())
235
232
}
236
233
237
- raw := self .xeth .EthBlockByNumber (args .BlockNumber )
238
- block := NewBlockRes (raw , self .xeth .Td (raw .Hash ()), false )
234
+ block := self .xeth .EthBlockByNumber (args .BlockNumber )
239
235
if block == nil {
240
236
return nil , nil
241
- } else {
242
- return newHexNum (big .NewInt (int64 (len (block .Transactions ))).Bytes ()), nil
243
237
}
238
+ return fmt .Sprintf ("%#x" , len (block .Transactions ())), nil
244
239
}
245
240
246
241
func (self * ethApi ) GetUncleCountByBlockHash (req * shared.Request ) (interface {}, error ) {
@@ -249,12 +244,11 @@ func (self *ethApi) GetUncleCountByBlockHash(req *shared.Request) (interface{},
249
244
return nil , shared .NewDecodeParamError (err .Error ())
250
245
}
251
246
252
- raw := self .xeth .EthBlockByHash (args .Hash )
253
- block := NewBlockRes (raw , self .xeth .Td (raw .Hash ()), false )
247
+ block := self .xeth .EthBlockByHash (args .Hash )
254
248
if block == nil {
255
249
return nil , nil
256
250
}
257
- return newHexNum ( big . NewInt ( int64 ( len (block .Uncles ))). Bytes ( )), nil
251
+ return fmt . Sprintf ( "%#x" , len (block .Uncles () )), nil
258
252
}
259
253
260
254
func (self * ethApi ) GetUncleCountByBlockNumber (req * shared.Request ) (interface {}, error ) {
@@ -263,12 +257,11 @@ func (self *ethApi) GetUncleCountByBlockNumber(req *shared.Request) (interface{}
263
257
return nil , shared .NewDecodeParamError (err .Error ())
264
258
}
265
259
266
- raw := self .xeth .EthBlockByNumber (args .BlockNumber )
267
- block := NewBlockRes (raw , self .xeth .Td (raw .Hash ()), false )
260
+ block := self .xeth .EthBlockByNumber (args .BlockNumber )
268
261
if block == nil {
269
262
return nil , nil
270
263
}
271
- return newHexNum ( big . NewInt ( int64 ( len (block .Uncles ))). Bytes ( )), nil
264
+ return fmt . Sprintf ( "%#x" , len (block .Uncles () )), nil
272
265
}
273
266
274
267
func (self * ethApi ) GetData (req * shared.Request ) (interface {}, error ) {
@@ -377,8 +370,10 @@ func (self *ethApi) GetBlockByHash(req *shared.Request) (interface{}, error) {
377
370
if err := self .codec .Decode (req .Params , & args ); err != nil {
378
371
return nil , shared .NewDecodeParamError (err .Error ())
379
372
}
380
-
381
373
block := self .xeth .EthBlockByHash (args .BlockHash )
374
+ if block == nil {
375
+ return nil , nil
376
+ }
382
377
return NewBlockRes (block , self .xeth .Td (block .Hash ()), args .IncludeTxs ), nil
383
378
}
384
379
@@ -389,6 +384,9 @@ func (self *ethApi) GetBlockByNumber(req *shared.Request) (interface{}, error) {
389
384
}
390
385
391
386
block := self .xeth .EthBlockByNumber (args .BlockNumber )
387
+ if block == nil {
388
+ return nil , nil
389
+ }
392
390
return NewBlockRes (block , self .xeth .Td (block .Hash ()), args .IncludeTxs ), nil
393
391
}
394
392
@@ -419,10 +417,10 @@ func (self *ethApi) GetTransactionByBlockHashAndIndex(req *shared.Request) (inte
419
417
}
420
418
421
419
raw := self .xeth .EthBlockByHash (args .Hash )
422
- block := NewBlockRes (raw , self .xeth .Td (raw .Hash ()), true )
423
- if block == nil {
420
+ if raw == nil {
424
421
return nil , nil
425
422
}
423
+ block := NewBlockRes (raw , self .xeth .Td (raw .Hash ()), true )
426
424
if args .Index >= int64 (len (block .Transactions )) || args .Index < 0 {
427
425
return nil , nil
428
426
} else {
@@ -437,10 +435,10 @@ func (self *ethApi) GetTransactionByBlockNumberAndIndex(req *shared.Request) (in
437
435
}
438
436
439
437
raw := self .xeth .EthBlockByNumber (args .BlockNumber )
440
- block := NewBlockRes (raw , self .xeth .Td (raw .Hash ()), true )
441
- if block == nil {
438
+ if raw == nil {
442
439
return nil , nil
443
440
}
441
+ block := NewBlockRes (raw , self .xeth .Td (raw .Hash ()), true )
444
442
if args .Index >= int64 (len (block .Transactions )) || args .Index < 0 {
445
443
// return NewValidationError("Index", "does not exist")
446
444
return nil , nil
@@ -455,10 +453,10 @@ func (self *ethApi) GetUncleByBlockHashAndIndex(req *shared.Request) (interface{
455
453
}
456
454
457
455
raw := self .xeth .EthBlockByHash (args .Hash )
458
- block := NewBlockRes (raw , self .xeth .Td (raw .Hash ()), false )
459
- if block == nil {
456
+ if raw == nil {
460
457
return nil , nil
461
458
}
459
+ block := NewBlockRes (raw , self .xeth .Td (raw .Hash ()), false )
462
460
if args .Index >= int64 (len (block .Uncles )) || args .Index < 0 {
463
461
// return NewValidationError("Index", "does not exist")
464
462
return nil , nil
@@ -473,10 +471,10 @@ func (self *ethApi) GetUncleByBlockNumberAndIndex(req *shared.Request) (interfac
473
471
}
474
472
475
473
raw := self .xeth .EthBlockByNumber (args .BlockNumber )
476
- block := NewBlockRes (raw , self .xeth .Td (raw .Hash ()), true )
477
- if block == nil {
474
+ if raw == nil {
478
475
return nil , nil
479
476
}
477
+ block := NewBlockRes (raw , self .xeth .Td (raw .Hash ()), true )
480
478
if args .Index >= int64 (len (block .Uncles )) || args .Index < 0 {
481
479
return nil , nil
482
480
} else {
0 commit comments