Skip to content

Commit c08fa60

Browse files
committed
Merge branch 'develop' of https://github.com/cheqd/cheqd-node into develop
2 parents 48966e0 + 394b086 commit c08fa60

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

installer/installer.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,11 @@ def configure_node_settings(self) -> bool:
12001200
else:
12011201
logging.debug("Log format not set by user. Skipping...")
12021202

1203+
# Remove [mempool] section from app.toml
1204+
if not self.remove_mempool_section(app_toml_path):
1205+
logging.error("Failed to remove [mempool] section from app.toml.")
1206+
return False
1207+
12031208
# Set ownership of configuration directory to cheqd:cheqd
12041209
logging.info(f"Setting ownership of {self.cheqd_config_dir} to {DEFAULT_CHEQD_USER}:{DEFAULT_CHEQD_USER}")
12051210
self.exec(f"chown -R {DEFAULT_CHEQD_USER}:{DEFAULT_CHEQD_USER} {self.cheqd_config_dir}")
@@ -1210,6 +1215,60 @@ def configure_node_settings(self) -> bool:
12101215
logging.exception(f"Failed to configure cheqd-noded settings. Reason: {e}")
12111216
return False
12121217

1218+
def remove_mempool_section(self, app_toml_path: str) -> bool:
1219+
# Remove or comment out the [mempool] section from app.toml
1220+
try:
1221+
if not os.path.exists(app_toml_path):
1222+
logging.debug(f"app.toml not found at {app_toml_path}. Skipping mempool section removal...")
1223+
return True
1224+
1225+
with open(app_toml_path, "r") as file:
1226+
lines = file.readlines()
1227+
1228+
# Find and comment out the [mempool] section
1229+
in_mempool_section = False
1230+
modified_lines = []
1231+
1232+
for line in lines:
1233+
stripped = line.strip()
1234+
1235+
# Check if we're entering the [mempool] section
1236+
if stripped in {"[mempool]", "#[mempool]"}:
1237+
in_mempool_section = True
1238+
# Comment out the section header if not already commented
1239+
if not stripped.startswith("#"):
1240+
# Preserve original indentation
1241+
leading_space = line[:len(line) - len(line.lstrip())]
1242+
modified_lines.append(leading_space + "# " + line.lstrip())
1243+
else:
1244+
modified_lines.append(line)
1245+
continue
1246+
1247+
# Check if we're exiting the [mempool] section (next section starts)
1248+
if in_mempool_section and stripped.startswith("[") and not stripped.startswith("#"):
1249+
in_mempool_section = False
1250+
1251+
# Comment out lines within the [mempool] section
1252+
if in_mempool_section:
1253+
# Only comment out non-empty, non-commented lines
1254+
if stripped and not stripped.startswith("#"):
1255+
# Preserve original indentation
1256+
leading_space = line[:len(line) - len(line.lstrip())]
1257+
modified_lines.append(leading_space + "# " + line.lstrip())
1258+
else:
1259+
modified_lines.append(line)
1260+
else:
1261+
modified_lines.append(line)
1262+
1263+
# Write the modified content back to the file
1264+
with open(app_toml_path, "w") as file:
1265+
file.writelines(modified_lines)
1266+
1267+
logging.info(f"Successfully commented out [mempool] section in {app_toml_path}")
1268+
return True
1269+
except Exception as e:
1270+
logging.exception(f"Failed to comment out [mempool] section in app.toml. Reason: {e}")
1271+
return False
12131272

12141273
def _get_latest_block_height(self, rpc_endpoint: str) -> int:
12151274
try:

0 commit comments

Comments
 (0)