trac-peer 0.1.30 → 0.1.31

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "trac-peer",
3
3
  "main": "src/index.js",
4
- "version": "0.1.30",
4
+ "version": "0.1.31",
5
5
  "type": "module",
6
6
  "dependencies": {
7
7
  "assert": "npm:bare-node-assert",
package/src/contract.js CHANGED
@@ -146,15 +146,18 @@ class Contract {
146
146
  return result === true;
147
147
  }
148
148
 
149
- register(type){
149
+ addFunction(type){
150
+ if(this.features[type] !== undefined || this.schemata[type] !== undefined) throw new Error('addFunction(type): The type has been registered already.');
150
151
  this.funcs[type] = true;
151
152
  }
152
153
 
153
154
  addSchema(type, schema){
155
+ if(this.funcs[type] !== undefined || this.features[type] !== undefined) throw new Error('addSchema(type, schema): The type has been registered already.');
154
156
  this.schemata[type] = this.protocol.peer.check.validator.compile(schema);
155
157
  }
156
158
 
157
159
  addFeature(type, func) {
160
+ if(this.funcs[type] !== undefined || this.schemata[type] !== undefined) throw new Error('addFeature(type, func): The type has been registered already.');
158
161
  this.features[type] = func;
159
162
  }
160
163
 
package/src/index.js CHANGED
@@ -46,7 +46,6 @@ export class Peer extends ReadyResource {
46
46
  this.protocol_instance = null;
47
47
  this.contract_instance = null;
48
48
  this.channel = b4a.alloc(32).fill(options.channel) || null;
49
- this.tx_channel = b4a.alloc(32).fill(options.tx_channel) || null;
50
49
  this.bee = null;
51
50
  this.replicate = options.replicate !== false;
52
51
  this.connectedNodes = 1;