Development Artifact Cleanup: ✅ BROTHER_NODE REORGANIZATION: Moved development test node to appropriate location - dev/test-nodes/brother_node/: Moved from root directory for better organization - Contains development configuration, test logs, and test chain data - No impact on production systems - purely development/testing artifact ✅ DEVELOPMENT ARTIFACTS IDENTIFIED: - Chain ID: aitbc-brother-chain (test/development chain) - Ports: 8010 (P2P) and 8011 (RPC) - different from production - Environment: .env file with test configuration - Logs: rpc.log and node.log from development testing session (March 15, 2026) ✅ ROOT DIRECTORY CLEANUP: Removed development clutter from production directory - brother_node/ moved to dev/test-nodes/brother_node/ - Root directory now contains only production-ready components - Development artifacts properly organized in dev/ subdirectory DIRECTORY STRUCTURE IMPROVEMENT: 📁 dev/test-nodes/: Development and testing node configurations 🏗️ Root Directory: Clean production structure with only essential components 🧪 Development Isolation: Test environments separated from production BENEFITS: ✅ Clean Production Directory: No development artifacts in root ✅ Better Organization: Development nodes grouped in dev/ subdirectory ✅ Clear Separation: Production vs development environments clearly distinguished ✅ Maintainability: Easier to identify and manage development components RESULT: Successfully moved brother_node development artifact to dev/test-nodes/ subdirectory, cleaning up the root directory while preserving development testing environment for future use.
70 lines
2.0 KiB
TypeScript
Executable File
70 lines
2.0 KiB
TypeScript
Executable File
import { defineProperties } from "../../utils/properties.js";
|
|
|
|
import { Typed } from "../typed.js";
|
|
import { Coder } from "./abstract-coder.js";
|
|
|
|
import { pack, unpack } from "./array.js";
|
|
|
|
import type { Reader, Writer } from "./abstract-coder.js";
|
|
|
|
/**
|
|
* @_ignore
|
|
*/
|
|
export class TupleCoder extends Coder {
|
|
readonly coders!: ReadonlyArray<Coder>;
|
|
|
|
constructor(coders: Array<Coder>, localName: string) {
|
|
let dynamic = false;
|
|
const types: Array<string> = [];
|
|
coders.forEach((coder) => {
|
|
if (coder.dynamic) { dynamic = true; }
|
|
types.push(coder.type);
|
|
});
|
|
const type = ("tuple(" + types.join(",") + ")");
|
|
|
|
super("tuple", type, localName, dynamic);
|
|
defineProperties<TupleCoder>(this, { coders: Object.freeze(coders.slice()) });
|
|
}
|
|
|
|
defaultValue(): any {
|
|
const values: any = [ ];
|
|
this.coders.forEach((coder) => {
|
|
values.push(coder.defaultValue());
|
|
});
|
|
|
|
// We only output named properties for uniquely named coders
|
|
const uniqueNames = this.coders.reduce((accum, coder) => {
|
|
const name = coder.localName;
|
|
if (name) {
|
|
if (!accum[name]) { accum[name] = 0; }
|
|
accum[name]++;
|
|
}
|
|
return accum;
|
|
}, <{ [ name: string ]: number }>{ });
|
|
|
|
// Add named values
|
|
this.coders.forEach((coder: Coder, index: number) => {
|
|
let name = coder.localName;
|
|
if (!name || uniqueNames[name] !== 1) { return; }
|
|
|
|
if (name === "length") { name = "_length"; }
|
|
|
|
if (values[name] != null) { return; }
|
|
|
|
values[name] = values[index];
|
|
});
|
|
|
|
return Object.freeze(values);
|
|
}
|
|
|
|
encode(writer: Writer, _value: Array<any> | { [ name: string ]: any } | Typed): number {
|
|
const value = Typed.dereference(_value, "tuple");
|
|
return pack(writer, this.coders, value);
|
|
}
|
|
|
|
decode(reader: Reader): any {
|
|
return unpack(reader, this.coders);
|
|
}
|
|
}
|
|
|