godprotocol 2.3.16 → 2.3.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Godprotocol.js CHANGED
@@ -42,6 +42,10 @@ class GodProtocol {
42
42
  return await this.route_table.platform_db();
43
43
  };
44
44
 
45
+ version_db = async (version) => {
46
+ return await this.route_table.version_db(version);
47
+ };
48
+
45
49
  load_services = async (services) => {
46
50
  await this.route_table.load_services(services);
47
51
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "godprotocol",
3
- "version": "2.3.16",
3
+ "version": "2.3.18",
4
4
  "description": "A distributed computing environment for Web 4.0 — integrating AI, decentralisation, and virtual computation.",
5
5
  "main": "Index.js",
6
6
  "type": "module",
@@ -27,6 +27,8 @@ class Route_table extends Headers {
27
27
 
28
28
  this.active_version = version;
29
29
 
30
+ this.db_name = ver.config?.db_name === true ? version : ver.config?.db_name;
31
+
30
32
  this.db_prefix =
31
33
  ver.config?.db_prefix === true ? version : ver.config?.db_prefix;
32
34
 
@@ -34,7 +34,7 @@ class Services {
34
34
  constructor() {
35
35
  this.services = new Object();
36
36
 
37
- this.db_prefixes = new Object();
37
+ this.dbs = new Object();
38
38
  this.load_services(gp_services);
39
39
  }
40
40
 
@@ -153,24 +153,26 @@ class Services {
153
153
  };
154
154
  };
155
155
 
156
- platform_db = async () => {
156
+ version_db = async (ver) => {
157
+ let version = await this.get_version(ver);
158
+ if (!version) return;
159
+
160
+ return await this.platform_db();
161
+ };
162
+
163
+ platform_db = async (name) => {
157
164
  let prefix = this.db_prefix;
158
- let db;
165
+ name = name || this.db_name || this.db_config.name;
166
+
159
167
  if (prefix) {
160
- db = this.db_prefixes[prefix];
161
- if (!db) {
162
- let conf = { ...this.db_config };
163
- conf.name = `${prefix}:${this.db_config.name}`;
168
+ name = `${prefix}:${name}`;
169
+ }
164
170
 
165
- db = new DB(conf, this);
166
- this.db_prefixes[prefix] = db;
167
- }
168
- } else {
169
- db = this.db;
170
- if (!db) {
171
- db = new DB(this.db_config, this);
172
- this.db = db;
173
- }
171
+ let db = this.dbs[name];
172
+ if (!db) {
173
+ db = new DB({ ...this.db_config, name }, this);
174
+
175
+ this.dbs[name] = db;
174
176
  }
175
177
 
176
178
  return db;