forked from infosave2007/phpblockchain
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_network_config.php
More file actions
63 lines (49 loc) · 2.05 KB
/
Copy pathsetup_network_config.php
File metadata and controls
63 lines (49 loc) · 2.05 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
<?php
/**
* Setup network configuration for synchronization
*/
require_once 'sync-service/SyncManager.php';
try {
echo "Setting up network configuration for node synchronization...\n";
// Create SyncManager instance to access database
$sync = new SyncManager();
// Check if network.nodes configuration exists
$configExists = false;
// Use reflection to access private PDO property
$reflection = new ReflectionClass($sync);
$pdoProperty = $reflection->getProperty('pdo');
$pdoProperty->setAccessible(true);
$pdo = $pdoProperty->getValue($sync);
// Check if network.nodes config exists
$stmt = $pdo->prepare("SELECT value FROM config WHERE key_name = 'network.nodes'");
$stmt->execute();
$result = $stmt->fetch();
if ($result && !empty($result['value'])) {
echo "Network nodes configuration already exists: " . $result['value'] . "\n";
$configExists = true;
}
if (!$configExists) {
echo "Adding network nodes configuration...\n";
// Add genesis node configuration
$stmt = $pdo->prepare("
INSERT INTO config (key_name, value, description, is_system)
VALUES ('network.nodes', ?, 'List of network nodes for synchronization', 1)
ON DUPLICATE KEY UPDATE value = VALUES(value)
");
$networkNodes = "https://wallet.coursefactory.pro";
$stmt->execute([$networkNodes]);
echo "Network nodes configuration added: $networkNodes\n";
}
// Also ensure we have node selection strategy
$stmt = $pdo->prepare("
INSERT INTO config (key_name, value, description, is_system)
VALUES ('node.selection_strategy', 'fastest_response', 'Node selection strategy for sync', 1)
ON DUPLICATE KEY UPDATE value = VALUES(value)
");
$stmt->execute();
echo "Network configuration setup completed!\n";
echo "You can now run synchronization.\n";
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
exit(1);
}