@@ -88,6 +88,7 @@ func (js *jsre) adminBindings() {
88
88
debug .Set ("getBlockRlp" , js .getBlockRlp )
89
89
debug .Set ("setHead" , js .setHead )
90
90
debug .Set ("processBlock" , js .debugBlock )
91
+ debug .Set ("seedhash" , js .seedHash )
91
92
// undocumented temporary
92
93
debug .Set ("waitForBlocks" , js .waitForBlocks )
93
94
}
@@ -118,6 +119,27 @@ func (js *jsre) getBlock(call otto.FunctionCall) (*types.Block, error) {
118
119
return block , nil
119
120
}
120
121
122
+ func (js * jsre ) seedHash (call otto.FunctionCall ) otto.Value {
123
+ if len (call .ArgumentList ) > 0 {
124
+ if call .Argument (0 ).IsNumber () {
125
+ num , _ := call .Argument (0 ).ToInteger ()
126
+ hash , err := ethash .GetSeedHash (uint64 (num ))
127
+ if err != nil {
128
+ fmt .Println (err )
129
+ return otto .UndefinedValue ()
130
+ }
131
+ v , _ := call .Otto .ToValue (fmt .Sprintf ("0x%x" , hash ))
132
+ return v
133
+ } else {
134
+ fmt .Println ("arg not a number" )
135
+ }
136
+ } else {
137
+ fmt .Println ("requires number argument" )
138
+ }
139
+
140
+ return otto .UndefinedValue ()
141
+ }
142
+
121
143
func (js * jsre ) pendingTransactions (call otto.FunctionCall ) otto.Value {
122
144
txs := js .ethereum .TxPool ().GetTransactions ()
123
145
@@ -144,7 +166,8 @@ func (js *jsre) pendingTransactions(call otto.FunctionCall) otto.Value {
144
166
}
145
167
}
146
168
147
- return js .re .ToVal (ltxs )
169
+ v , _ := call .Otto .ToValue (ltxs )
170
+ return v
148
171
}
149
172
150
173
func (js * jsre ) resend (call otto.FunctionCall ) otto.Value {
@@ -175,7 +198,8 @@ func (js *jsre) resend(call otto.FunctionCall) otto.Value {
175
198
}
176
199
js .ethereum .TxPool ().RemoveTransactions (types.Transactions {tx .tx })
177
200
178
- return js .re .ToVal (ret )
201
+ v , _ := call .Otto .ToValue (ret )
202
+ return v
179
203
}
180
204
181
205
fmt .Println ("first argument must be a transaction" )
@@ -198,12 +222,13 @@ func (js *jsre) sign(call otto.FunctionCall) otto.Value {
198
222
fmt .Println (err )
199
223
return otto .UndefinedValue ()
200
224
}
201
- v , err := js .xeth .Sign (signer , data , false )
225
+ signed , err := js .xeth .Sign (signer , data , false )
202
226
if err != nil {
203
227
fmt .Println (err )
204
228
return otto .UndefinedValue ()
205
229
}
206
- return js .re .ToVal (v )
230
+ v , _ := call .Otto .ToValue (signed )
231
+ return v
207
232
}
208
233
209
234
func (js * jsre ) debugBlock (call otto.FunctionCall ) otto.Value {
@@ -217,10 +242,11 @@ func (js *jsre) debugBlock(call otto.FunctionCall) otto.Value {
217
242
vm .Debug = true
218
243
_ , err = js .ethereum .BlockProcessor ().RetryProcess (block )
219
244
if err != nil {
220
- glog . Infoln (err )
245
+ fmt . Println (err )
221
246
}
222
247
vm .Debug = old
223
248
249
+ fmt .Println ("ok" )
224
250
return otto .UndefinedValue ()
225
251
}
226
252
@@ -237,8 +263,8 @@ func (js *jsre) setHead(call otto.FunctionCall) otto.Value {
237
263
238
264
func (js * jsre ) downloadProgress (call otto.FunctionCall ) otto.Value {
239
265
current , max := js .ethereum .Downloader ().Stats ()
240
-
241
- return js . re . ToVal ( fmt . Sprintf ( "%d/%d" , current , max ))
266
+ v , _ := call . Otto . ToValue ( fmt . Sprintf ( "%d/%d" , current , max ))
267
+ return v
242
268
}
243
269
244
270
func (js * jsre ) getBlockRlp (call otto.FunctionCall ) otto.Value {
@@ -248,7 +274,8 @@ func (js *jsre) getBlockRlp(call otto.FunctionCall) otto.Value {
248
274
return otto .UndefinedValue ()
249
275
}
250
276
encoded , _ := rlp .EncodeToBytes (block )
251
- return js .re .ToVal (fmt .Sprintf ("%x" , encoded ))
277
+ v , _ := call .Otto .ToValue (fmt .Sprintf ("%x" , encoded ))
278
+ return v
252
279
}
253
280
254
281
func (js * jsre ) setExtra (call otto.FunctionCall ) otto.Value {
@@ -278,8 +305,9 @@ func (js *jsre) setGasPrice(call otto.FunctionCall) otto.Value {
278
305
return otto .UndefinedValue ()
279
306
}
280
307
281
- func (js * jsre ) hashrate (otto.FunctionCall ) otto.Value {
282
- return js .re .ToVal (js .ethereum .Miner ().HashRate ())
308
+ func (js * jsre ) hashrate (call otto.FunctionCall ) otto.Value {
309
+ v , _ := call .Otto .ToValue (js .ethereum .Miner ().HashRate ())
310
+ return v
283
311
}
284
312
285
313
func (js * jsre ) makeDAG (call otto.FunctionCall ) otto.Value {
@@ -495,15 +523,18 @@ func (js *jsre) newAccount(call otto.FunctionCall) otto.Value {
495
523
fmt .Printf ("Could not create the account: %v" , err )
496
524
return otto .UndefinedValue ()
497
525
}
498
- return js .re .ToVal (acct .Address .Hex ())
526
+ v , _ := call .Otto .ToValue (acct .Address .Hex ())
527
+ return v
499
528
}
500
529
501
530
func (js * jsre ) nodeInfo (call otto.FunctionCall ) otto.Value {
502
- return js .re .ToVal (js .ethereum .NodeInfo ())
531
+ v , _ := call .Otto .ToValue (js .ethereum .NodeInfo ())
532
+ return v
503
533
}
504
534
505
535
func (js * jsre ) peers (call otto.FunctionCall ) otto.Value {
506
- return js .re .ToVal (js .ethereum .PeersInfo ())
536
+ v , _ := call .Otto .ToValue (js .ethereum .PeersInfo ())
537
+ return v
507
538
}
508
539
509
540
func (js * jsre ) importChain (call otto.FunctionCall ) otto.Value {
@@ -562,7 +593,8 @@ func (js *jsre) dumpBlock(call otto.FunctionCall) otto.Value {
562
593
563
594
statedb := state .New (block .Root (), js .ethereum .StateDb ())
564
595
dump := statedb .RawDump ()
565
- return js .re .ToVal (dump )
596
+ v , _ := call .Otto .ToValue (dump )
597
+ return v
566
598
}
567
599
568
600
func (js * jsre ) waitForBlocks (call otto.FunctionCall ) otto.Value {
@@ -611,7 +643,8 @@ func (js *jsre) waitForBlocks(call otto.FunctionCall) otto.Value {
611
643
return otto .UndefinedValue ()
612
644
case height = <- wait :
613
645
}
614
- return js .re .ToVal (height .Uint64 ())
646
+ v , _ := call .Otto .ToValue (height .Uint64 ())
647
+ return v
615
648
}
616
649
617
650
func (js * jsre ) sleep (call otto.FunctionCall ) otto.Value {
@@ -704,8 +737,8 @@ func (js *jsre) register(call otto.FunctionCall) otto.Value {
704
737
return otto .UndefinedValue ()
705
738
}
706
739
707
- return js . re . ToVal (contenthash .Hex ())
708
-
740
+ v , _ := call . Otto . ToValue (contenthash .Hex ())
741
+ return v
709
742
}
710
743
711
744
func (js * jsre ) registerUrl (call otto.FunctionCall ) otto.Value {
@@ -764,7 +797,8 @@ func (js *jsre) getContractInfo(call otto.FunctionCall) otto.Value {
764
797
fmt .Println (err )
765
798
return otto .UndefinedValue ()
766
799
}
767
- return js .re .ToVal (info )
800
+ v , _ := call .Otto .ToValue (info )
801
+ return v
768
802
}
769
803
770
804
func (js * jsre ) startNatSpec (call otto.FunctionCall ) otto.Value {
0 commit comments