forked from phpcoinn/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.php
More file actions
157 lines (133 loc) · 5.16 KB
/
utils.php
File metadata and controls
157 lines (133 loc) · 5.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
if (!defined("ADMIN_TAB")) {
exit;
}
global $action, $db, $_config;
if($action == "clean") {
Nodeutil::clean();
header("location: ".APP_URL."/?view=utils");
exit;
}
$main_node = $_config['initial_peer_list'][0];
if($action=="sync") {
$cmd= "php " . ROOT . "/cli/peersync.php $main_node";
Nodeutil::runSingleProcess($cmd);
header("location: ".APP_URL."/?view=utils");
exit;
}
$checkBlocksResponse = false;
if($action == "check_blocks") {
$peer = $_POST['peer'] ?? null;
$invalid_block = Nodeutil::checkBlocksWithPeer($peer);
$checkBlocksResponse = true;
}
if($action == "accounts-hash") {
$accountsHash = Nodeutil::calculateAccountsHash();
}
if($action == 'clear_blocks') {
$height = $_POST['height'] ?? null;
Nodeutil::deleteFromHeight($height);
header("location: ".APP_URL."/?view=utils");
exit;
}
$accountsHash = false;
$blocksHash = false;
if($action == "blocks-hash") {
$height = $_POST['height'] ?? null;
$blocksHash = Nodeutil::calculateBlocksHash($height);
}
if($action == "clear_tmp") {
Util::cleanTmpFolder();
header("location: ".APP_URL."/?view=utils");
exit;
}
?>
<div class="flex-row d-flex flex-wrap align-items-center mb-2">
<a class="btn btn-danger me-2" href="<?php echo APP_URL ?>/?view=utils&action=clean" onclick="if(!confirm('Clean?')) return false">Clean</a>
<div class="text-danger">Deletes all block and transactions in database</div>
</div>
<div class="flex-row d-flex flex-wrap align-items-center mb-2">
<a class="btn btn-info me-2" href="<?php echo APP_URL ?>/?view=utils&action=sync" onclick="if(!confirm('Run sync?')) return false">Run sync</a>
<div>Manualy sync from main node <?php echo $main_node ?></div>
</div>
<div class="flex-row d-flex flex-wrap align-items-center mb-2">
<a class="btn btn-info me-2" href="<?php echo APP_URL ?>/?view=utils&action=clear_tmp" onclick="if(!confirm('Run sync?')) return false">Clear temp folder</a>
<div>Clear tmp folder if syncing of node is stuck</div>
</div>
<div class="mt-4">
<h3 class="font-size-16 mb-2"><i class="mdi mdi-arrow-right text-primary me-1"></i> Check blocks</h3>
<form class="row gx-3 gy-2 align-items-center" method="post" action="">
<input type="hidden" name="action" value="check_blocks"/>
<div class="col-sm-2">
<input type="text" class="form-control" id="peer" name="peer" placeholder="Peer" required="required">
</div>
<div class="col-sm-2">
<button type="submit" class="btn btn-primary">Check</button>
</div>
<div class="col-auto">
<?php if($checkBlocksResponse) { ?>
<?php if(empty($invalid_block)) { ?>
<div class="alert alert-success mb-0">
No invalid block
</div>
<?php } else { ?>
<div class="alert alert-danger mb-0">
Invalid block detected at height <?php echo $invalid_block ?>
</div>
<?php } ?>
<?php } ?>
</div>
</form>
</div>
<hr/>
<div class="mt-4">
<h3 class="font-size-16 mb-2"><i class="mdi mdi-arrow-right text-primary me-1"></i> Clear blocks</h3>
<form class="row gx-3 gy-2 align-items-center" method="post" action="">
<input type="hidden" name="action" value="clear_blocks"/>
<div class="col-sm-2">
<input type="text" class="form-control" id="height" name="height" placeholder="From height" required="required">
</div>
<div class="col-sm-2">
<button type="submit" class="btn btn-danger">Clear</button>
</div>
</form>
</div>
<hr/>
<div class="mt-4">
<h3 class="font-size-16 mb-2"><i class="mdi mdi-arrow-right text-primary me-1"></i>Accounts hash</h3>
<div class="row">
<div class="col-sm-2">
<a href="<?php echo APP_URL ?>/?view=utils&action=accounts-hash" class="btn btn-info">Calculate</a>
</div>
<div class="col-auto">
<?php if($accountsHash) { ?>
<div class="alert alert-success mb-0">
height: <?php echo $accountsHash['height'] ?><br/>
hash: <?php echo $accountsHash['hash'] ?>
</div>
<?php } ?>
</div>
</div>
</div>
<hr/>
<div class="mt-4">
<h3 class="font-size-16 mb-2"><i class="mdi mdi-arrow-right text-primary me-1"></i>Blocks hash</h3>
<form class="row gx-3 gy-2 align-items-center" method="post" action="">
<input type="hidden" name="action" value="blocks-hash"/>
<div class="col-sm-2">
<input type="text" class="form-control" id="height" name="height" placeholder="Height">
</div>
<div class="col-sm-2">
<button type="submit" class="btn btn-info">Calculate</button>
</div>
<div class="col-auto">
<?php if($blocksHash) { ?>
<div class="alert alert-success mb-0">
height: <?php echo $blocksHash['height'] ?><br/>
hash: <?php echo $blocksHash['hash'] ?>
</div>
<?php } ?>
</div>
</form>
</div>
<div class="mb-5"></div>