Skip to content

Commit 5596b66

Browse files
authored
internal/debug: add debug_freeOSMemory (#15122)
1 parent 10181b5 commit 5596b66

2 files changed

Lines changed: 68 additions & 71 deletions

File tree

‎internal/debug/api.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ func (*HandlerT) Stacks() string {
176176
return string(buf)
177177
}
178178

179+
// FreeOSMemory returns unused memory to the OS.
180+
func (*HandlerT) FreeOSMemory() {
181+
debug.FreeOSMemory()
182+
}
183+
179184
func writeProfile(name, file string) error {
180185
p := pprof.Lookup(name)
181186
log.Info("Writing profile records", "count", p.Count(), "type", name, "dump", file)

‎internal/web3ext/web3ext.go‎

Lines changed: 63 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -34,58 +34,56 @@ var Modules = map[string]string{
3434

3535
const Chequebook_JS = `
3636
web3._extend({
37-
property: 'chequebook',
38-
methods:
39-
[
40-
new web3._extend.Method({
41-
name: 'deposit',
42-
call: 'chequebook_deposit',
43-
params: 1,
44-
inputFormatter: [null]
45-
}),
46-
new web3._extend.Property({
37+
property: 'chequebook',
38+
methods: [
39+
new web3._extend.Method({
40+
name: 'deposit',
41+
call: 'chequebook_deposit',
42+
params: 1,
43+
inputFormatter: [null]
44+
}),
45+
new web3._extend.Property({
4746
name: 'balance',
4847
getter: 'chequebook_balance',
49-
outputFormatter: web3._extend.utils.toDecimal
50-
}),
51-
new web3._extend.Method({
52-
name: 'cash',
53-
call: 'chequebook_cash',
54-
params: 1,
55-
inputFormatter: [null]
56-
}),
57-
new web3._extend.Method({
58-
name: 'issue',
59-
call: 'chequebook_issue',
60-
params: 2,
61-
inputFormatter: [null, null]
62-
}),
63-
]
48+
outputFormatter: web3._extend.utils.toDecimal
49+
}),
50+
new web3._extend.Method({
51+
name: 'cash',
52+
call: 'chequebook_cash',
53+
params: 1,
54+
inputFormatter: [null]
55+
}),
56+
new web3._extend.Method({
57+
name: 'issue',
58+
call: 'chequebook_issue',
59+
params: 2,
60+
inputFormatter: [null, null]
61+
}),
62+
]
6463
});
6564
`
6665

6766
const Clique_JS = `
6867
web3._extend({
69-
property: 'clique',
70-
methods:
71-
[
68+
property: 'clique',
69+
methods: [
7270
new web3._extend.Method({
7371
name: 'getSnapshot',
7472
call: 'clique_getSnapshot',
7573
params: 1,
76-
inputFormatter: [null]
74+
inputFormatter: [null]
7775
}),
7876
new web3._extend.Method({
7977
name: 'getSnapshotAtHash',
8078
call: 'clique_getSnapshotAtHash',
8179
params: 1
8280
}),
83-
new web3._extend.Method({
84-
name: 'getSigners',
85-
call: 'clique_getSigners',
86-
params: 1,
87-
inputFormatter: [null]
88-
}),
81+
new web3._extend.Method({
82+
name: 'getSigners',
83+
call: 'clique_getSigners',
84+
params: 1,
85+
inputFormatter: [null]
86+
}),
8987
new web3._extend.Method({
9088
name: 'getSignersAtHash',
9189
call: 'clique_getSignersAtHash',
@@ -100,10 +98,9 @@ web3._extend({
10098
name: 'discard',
10199
call: 'clique_discard',
102100
params: 1
103-
})
104-
],
105-
properties:
106-
[
101+
}),
102+
],
103+
properties: [
107104
new web3._extend.Property({
108105
name: 'proposals',
109106
getter: 'clique_proposals'
@@ -115,8 +112,7 @@ web3._extend({
115112
const Admin_JS = `
116113
web3._extend({
117114
property: 'admin',
118-
methods:
119-
[
115+
methods: [
120116
new web3._extend.Method({
121117
name: 'addPeer',
122118
call: 'admin_addPeer',
@@ -162,10 +158,9 @@ web3._extend({
162158
new web3._extend.Method({
163159
name: 'stopWS',
164160
call: 'admin_stopWS'
165-
})
161+
}),
166162
],
167-
properties:
168-
[
163+
properties: [
169164
new web3._extend.Property({
170165
name: 'nodeInfo',
171166
getter: 'admin_nodeInfo'
@@ -177,16 +172,15 @@ web3._extend({
177172
new web3._extend.Property({
178173
name: 'datadir',
179174
getter: 'admin_datadir'
180-
})
175+
}),
181176
]
182177
});
183178
`
184179

185180
const Debug_JS = `
186181
web3._extend({
187182
property: 'debug',
188-
methods:
189-
[
183+
methods: [
190184
new web3._extend.Method({
191185
name: 'printBlock',
192186
call: 'debug_printBlock',
@@ -268,6 +262,11 @@ web3._extend({
268262
params: 0,
269263
outputFormatter: console.log
270264
}),
265+
new web3._extend.Method({
266+
name: 'freeOSMemory',
267+
call: 'debug_freeOSMemory',
268+
params: 0,
269+
}),
271270
new web3._extend.Method({
272271
name: 'memStats',
273272
call: 'debug_memStats',
@@ -358,8 +357,7 @@ web3._extend({
358357
const Eth_JS = `
359358
web3._extend({
360359
property: 'eth',
361-
methods:
362-
[
360+
methods: [
363361
new web3._extend.Method({
364362
name: 'sign',
365363
call: 'eth_sign',
@@ -396,10 +394,9 @@ web3._extend({
396394
},
397395
params: 2,
398396
inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter, web3._extend.utils.toHex]
399-
})
397+
}),
400398
],
401-
properties:
402-
[
399+
properties: [
403400
new web3._extend.Property({
404401
name: 'pendingTransactions',
405402
getter: 'eth_pendingTransactions',
@@ -411,16 +408,15 @@ web3._extend({
411408
}
412409
return formatted;
413410
}
414-
})
411+
}),
415412
]
416413
});
417414
`
418415

419416
const Miner_JS = `
420417
web3._extend({
421418
property: 'miner',
422-
methods:
423-
[
419+
methods: [
424420
new web3._extend.Method({
425421
name: 'start',
426422
call: 'miner_start',
@@ -451,7 +447,7 @@ web3._extend({
451447
new web3._extend.Method({
452448
name: 'getHashrate',
453449
call: 'miner_getHashrate'
454-
})
450+
}),
455451
],
456452
properties: []
457453
});
@@ -461,21 +457,19 @@ const Net_JS = `
461457
web3._extend({
462458
property: 'net',
463459
methods: [],
464-
properties:
465-
[
460+
properties: [
466461
new web3._extend.Property({
467462
name: 'version',
468463
getter: 'net_version'
469-
})
464+
}),
470465
]
471466
});
472467
`
473468

474469
const Personal_JS = `
475470
web3._extend({
476471
property: 'personal',
477-
methods:
478-
[
472+
methods: [
479473
new web3._extend.Method({
480474
name: 'importRawKey',
481475
call: 'personal_importRawKey',
@@ -501,14 +495,13 @@ web3._extend({
501495
name: 'deriveAccount',
502496
call: 'personal_deriveAccount',
503497
params: 3
504-
})
498+
}),
505499
],
506-
properties:
507-
[
500+
properties: [
508501
new web3._extend.Property({
509502
name: 'listWallets',
510503
getter: 'personal_listWallets'
511-
})
504+
}),
512505
]
513506
})
514507
`
@@ -517,12 +510,11 @@ const RPC_JS = `
517510
web3._extend({
518511
property: 'rpc',
519512
methods: [],
520-
properties:
521-
[
513+
properties: [
522514
new web3._extend.Property({
523515
name: 'modules',
524516
getter: 'rpc_modules'
525-
})
517+
}),
526518
]
527519
});
528520
`
@@ -633,7 +625,7 @@ web3._extend({
633625
name: 'newMessageFilter',
634626
call: 'shh_newMessageFilter',
635627
params: 1
636-
})
628+
}),
637629
],
638630
properties:
639631
[
@@ -669,7 +661,7 @@ web3._extend({
669661
name: 'listmounts',
670662
call: 'swarmfs_listmounts',
671663
params: 0
672-
})
664+
}),
673665
]
674666
});
675667
`
@@ -696,7 +688,7 @@ web3._extend({
696688
status.queued = web3._extend.utils.toDecimal(status.queued);
697689
return status;
698690
}
699-
})
691+
}),
700692
]
701693
});
702694
`

0 commit comments

Comments
 (0)