@@ -78,6 +78,12 @@ func (js *jsre) adminBindings() {
78
78
miner .Set ("stopAutoDAG" , js .stopAutoDAG )
79
79
miner .Set ("makeDAG" , js .makeDAG )
80
80
81
+ admin .Set ("txPool" , struct {}{})
82
+ t , _ = admin .Get ("txPool" )
83
+ txPool := t .Object ()
84
+ txPool .Set ("pending" , js .allPendingTransactions )
85
+ txPool .Set ("queued" , js .allQueuedTransactions )
86
+
81
87
admin .Set ("debug" , struct {}{})
82
88
t , _ = admin .Get ("debug" )
83
89
debug := t .Object ()
@@ -89,6 +95,7 @@ func (js *jsre) adminBindings() {
89
95
debug .Set ("setHead" , js .setHead )
90
96
debug .Set ("processBlock" , js .debugBlock )
91
97
debug .Set ("seedhash" , js .seedHash )
98
+ debug .Set ("insertBlock" , js .insertBlockRlp )
92
99
// undocumented temporary
93
100
debug .Set ("waitForBlocks" , js .waitForBlocks )
94
101
}
@@ -140,6 +147,32 @@ func (js *jsre) seedHash(call otto.FunctionCall) otto.Value {
140
147
return otto .UndefinedValue ()
141
148
}
142
149
150
+ func (js * jsre ) allPendingTransactions (call otto.FunctionCall ) otto.Value {
151
+ txs := js .ethereum .TxPool ().GetTransactions ()
152
+
153
+ ltxs := make ([]* tx , len (txs ))
154
+ for i , tx := range txs {
155
+ // no need to check err
156
+ ltxs [i ] = newTx (tx )
157
+ }
158
+
159
+ v , _ := call .Otto .ToValue (ltxs )
160
+ return v
161
+ }
162
+
163
+ func (js * jsre ) allQueuedTransactions (call otto.FunctionCall ) otto.Value {
164
+ txs := js .ethereum .TxPool ().GetQueuedTransactions ()
165
+
166
+ ltxs := make ([]* tx , len (txs ))
167
+ for i , tx := range txs {
168
+ // no need to check err
169
+ ltxs [i ] = newTx (tx )
170
+ }
171
+
172
+ v , _ := call .Otto .ToValue (ltxs )
173
+ return v
174
+ }
175
+
143
176
func (js * jsre ) pendingTransactions (call otto.FunctionCall ) otto.Value {
144
177
txs := js .ethereum .TxPool ().GetTransactions ()
145
178
@@ -160,7 +193,6 @@ func (js *jsre) pendingTransactions(call otto.FunctionCall) otto.Value {
160
193
//ltxs := make([]*tx, len(txs))
161
194
var ltxs []* tx
162
195
for _ , tx := range txs {
163
- // no need to check err
164
196
if from , _ := tx .From (); accountSet .Has (from ) {
165
197
ltxs = append (ltxs , newTx (tx ))
166
198
}
@@ -238,16 +270,47 @@ func (js *jsre) debugBlock(call otto.FunctionCall) otto.Value {
238
270
return otto .UndefinedValue ()
239
271
}
240
272
273
+ tstart := time .Now ()
274
+
241
275
old := vm .Debug
242
276
vm .Debug = true
243
277
_ , err = js .ethereum .BlockProcessor ().RetryProcess (block )
244
278
if err != nil {
245
279
fmt .Println (err )
280
+ r , _ := call .Otto .ToValue (map [string ]interface {}{"success" : false , "time" : time .Since (tstart ).Seconds ()})
281
+ return r
246
282
}
247
283
vm .Debug = old
248
284
249
- fmt .Println ("ok" )
250
- return otto .UndefinedValue ()
285
+ r , _ := call .Otto .ToValue (map [string ]interface {}{"success" : true , "time" : time .Since (tstart ).Seconds ()})
286
+ return r
287
+ }
288
+
289
+ func (js * jsre ) insertBlockRlp (call otto.FunctionCall ) otto.Value {
290
+ tstart := time .Now ()
291
+
292
+ var block types.Block
293
+ if call .Argument (0 ).IsString () {
294
+ blockRlp , _ := call .Argument (0 ).ToString ()
295
+ err := rlp .DecodeBytes (common .Hex2Bytes (blockRlp ), & block )
296
+ if err != nil {
297
+ fmt .Println (err )
298
+ return otto .UndefinedValue ()
299
+ }
300
+ }
301
+
302
+ old := vm .Debug
303
+ vm .Debug = true
304
+ _ , err := js .ethereum .BlockProcessor ().RetryProcess (& block )
305
+ if err != nil {
306
+ fmt .Println (err )
307
+ r , _ := call .Otto .ToValue (map [string ]interface {}{"success" : false , "time" : time .Since (tstart ).Seconds ()})
308
+ return r
309
+ }
310
+ vm .Debug = old
311
+
312
+ r , _ := call .Otto .ToValue (map [string ]interface {}{"success" : true , "time" : time .Since (tstart ).Seconds ()})
313
+ return r
251
314
}
252
315
253
316
func (js * jsre ) setHead (call otto.FunctionCall ) otto.Value {
0 commit comments