@@ -88,6 +88,7 @@ func (js *jsre) adminBindings() {
8888 debug .Set ("getBlockRlp" , js .getBlockRlp )
8989 debug .Set ("setHead" , js .setHead )
9090 debug .Set ("processBlock" , js .debugBlock )
91+ debug .Set ("seedhash" , js .seedHash )
9192 // undocumented temporary
9293 debug .Set ("waitForBlocks" , js .waitForBlocks )
9394}
@@ -118,6 +119,27 @@ func (js *jsre) getBlock(call otto.FunctionCall) (*types.Block, error) {
118119 return block , nil
119120}
120121
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+
121143func (js * jsre ) pendingTransactions (call otto.FunctionCall ) otto.Value {
122144 txs := js .ethereum .TxPool ().GetTransactions ()
123145
@@ -144,7 +166,8 @@ func (js *jsre) pendingTransactions(call otto.FunctionCall) otto.Value {
144166 }
145167 }
146168
147- return js .re .ToVal (ltxs )
169+ v , _ := call .Otto .ToValue (ltxs )
170+ return v
148171}
149172
150173func (js * jsre ) resend (call otto.FunctionCall ) otto.Value {
@@ -175,7 +198,8 @@ func (js *jsre) resend(call otto.FunctionCall) otto.Value {
175198 }
176199 js .ethereum .TxPool ().RemoveTransactions (types.Transactions {tx .tx })
177200
178- return js .re .ToVal (ret )
201+ v , _ := call .Otto .ToValue (ret )
202+ return v
179203 }
180204
181205 fmt .Println ("first argument must be a transaction" )
@@ -198,12 +222,13 @@ func (js *jsre) sign(call otto.FunctionCall) otto.Value {
198222 fmt .Println (err )
199223 return otto .UndefinedValue ()
200224 }
201- v , err := js .xeth .Sign (signer , data , false )
225+ signed , err := js .xeth .Sign (signer , data , false )
202226 if err != nil {
203227 fmt .Println (err )
204228 return otto .UndefinedValue ()
205229 }
206- return js .re .ToVal (v )
230+ v , _ := call .Otto .ToValue (signed )
231+ return v
207232}
208233
209234func (js * jsre ) debugBlock (call otto.FunctionCall ) otto.Value {
@@ -217,10 +242,11 @@ func (js *jsre) debugBlock(call otto.FunctionCall) otto.Value {
217242 vm .Debug = true
218243 _ , err = js .ethereum .BlockProcessor ().RetryProcess (block )
219244 if err != nil {
220- glog . Infoln (err )
245+ fmt . Println (err )
221246 }
222247 vm .Debug = old
223248
249+ fmt .Println ("ok" )
224250 return otto .UndefinedValue ()
225251}
226252
@@ -237,8 +263,8 @@ func (js *jsre) setHead(call otto.FunctionCall) otto.Value {
237263
238264func (js * jsre ) downloadProgress (call otto.FunctionCall ) otto.Value {
239265 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
242268}
243269
244270func (js * jsre ) getBlockRlp (call otto.FunctionCall ) otto.Value {
@@ -248,7 +274,8 @@ func (js *jsre) getBlockRlp(call otto.FunctionCall) otto.Value {
248274 return otto .UndefinedValue ()
249275 }
250276 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
252279}
253280
254281func (js * jsre ) setExtra (call otto.FunctionCall ) otto.Value {
@@ -278,8 +305,9 @@ func (js *jsre) setGasPrice(call otto.FunctionCall) otto.Value {
278305 return otto .UndefinedValue ()
279306}
280307
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
283311}
284312
285313func (js * jsre ) makeDAG (call otto.FunctionCall ) otto.Value {
@@ -495,15 +523,18 @@ func (js *jsre) newAccount(call otto.FunctionCall) otto.Value {
495523 fmt .Printf ("Could not create the account: %v" , err )
496524 return otto .UndefinedValue ()
497525 }
498- return js .re .ToVal (acct .Address .Hex ())
526+ v , _ := call .Otto .ToValue (acct .Address .Hex ())
527+ return v
499528}
500529
501530func (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
503533}
504534
505535func (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
507538}
508539
509540func (js * jsre ) importChain (call otto.FunctionCall ) otto.Value {
@@ -562,7 +593,8 @@ func (js *jsre) dumpBlock(call otto.FunctionCall) otto.Value {
562593
563594 statedb := state .New (block .Root (), js .ethereum .StateDb ())
564595 dump := statedb .RawDump ()
565- return js .re .ToVal (dump )
596+ v , _ := call .Otto .ToValue (dump )
597+ return v
566598}
567599
568600func (js * jsre ) waitForBlocks (call otto.FunctionCall ) otto.Value {
@@ -611,7 +643,8 @@ func (js *jsre) waitForBlocks(call otto.FunctionCall) otto.Value {
611643 return otto .UndefinedValue ()
612644 case height = <- wait :
613645 }
614- return js .re .ToVal (height .Uint64 ())
646+ v , _ := call .Otto .ToValue (height .Uint64 ())
647+ return v
615648}
616649
617650func (js * jsre ) sleep (call otto.FunctionCall ) otto.Value {
@@ -704,8 +737,8 @@ func (js *jsre) register(call otto.FunctionCall) otto.Value {
704737 return otto .UndefinedValue ()
705738 }
706739
707- return js . re . ToVal (contenthash .Hex ())
708-
740+ v , _ := call . Otto . ToValue (contenthash .Hex ())
741+ return v
709742}
710743
711744func (js * jsre ) registerUrl (call otto.FunctionCall ) otto.Value {
@@ -764,7 +797,8 @@ func (js *jsre) getContractInfo(call otto.FunctionCall) otto.Value {
764797 fmt .Println (err )
765798 return otto .UndefinedValue ()
766799 }
767- return js .re .ToVal (info )
800+ v , _ := call .Otto .ToValue (info )
801+ return v
768802}
769803
770804func (js * jsre ) startNatSpec (call otto.FunctionCall ) otto.Value {
0 commit comments