@@ -4,7 +4,6 @@ import fs from "fs";
44import cors from "cors" ;
55import dotenv from "dotenv" ;
66import setSelfAdjustingInterval from "self-adjusting-interval" ;
7- import crypto from "crypto" ;
87import { fileURLToPath } from "url" ;
98import Gun from "gun" ;
109import "gun/sea" ;
@@ -16,8 +15,6 @@ import "./utils/bullet-catcher";
1615
1716import multer from "multer" ;
1817import { initRelayUser , getRelayUser } from "./utils/relay-user" ;
19- import * as Reputation from "./utils/relay-reputation" ;
20- import * as FrozenData from "./utils/frozen-data" ;
2118import SQLiteStore from "./utils/sqlite-store" ;
2219import S3Store from "./utils/s3-store" ;
2320import { loggers } from "./utils/logger" ;
@@ -38,7 +35,6 @@ import {
3835import { startWormholeCleanup } from "./utils/wormhole-cleanup" ;
3936import { tokenAuthMiddleware } from "./middleware/token-auth" ;
4037import { secureCompare , hashToken , createProductionErrorHandler } from "./utils/security" ;
41- import { announceRelayPresence , syncGunDBPeers , syncMulePeers } from "./utils/peer-discovery" ;
4238
4339import { GUN_PATHS , getGunNode } from "./utils/gun-paths" ;
4440// Chat service removed
@@ -500,13 +496,8 @@ async function initializeServer() {
500496
501497 const gun = ( Gun as any ) ( gunConfig ) ;
502498
503- < < < << << HEAD
504499 // Initialize Gun Alias Guard to prevent duplicate usernames
505500 gunAliasGuard ( gun ) ;
506-
507-
508- === === =
509- >>> >>> > 0e2 afc9b6825ccb0789c64c14f714e13a829b678
510501 // Store gun instance in express app for access from routes
511502 app . set ( "gunInstance" , gun ) ;
512503 // Store the gun storage adapter for stats access
@@ -707,14 +698,6 @@ See docs/RELAY_KEYS.md for more information.
707698 // Not a valid URL, use as-is
708699 }
709700
710- // Initialize reputation tracking for this relay
711- try {
712- Reputation . initReputationTracking ( gun , host ) ;
713- loggers . server . info ( { host } , `📊 Reputation tracking initialized` ) ;
714- } catch ( e : any ) {
715- loggers . server . warn ( { err : e } , "⚠️ Failed to initialize reputation tracking" ) ;
716- }
717-
718701 // Initialize Network Pin Request Listener (auto-replication)
719702 const autoReplication = replicationConfig . autoReplication ;
720703
@@ -858,13 +841,6 @@ See docs/RELAY_KEYS.md for more information.
858841 status : "completed" ,
859842 } ) ;
860843
861- // Record pin fulfillment for reputation tracking
862- try {
863- await Reputation . recordPinFulfillment ( gun , host , true ) ;
864- } catch ( e : any ) {
865- loggers . server . warn ( { err : e } , "Failed to record pin fulfillment for reputation" ) ;
866- }
867-
868844 // Publish response
869845 const crypto = await import ( "crypto" ) ;
870846 const responseId = crypto . randomBytes ( 8 ) . toString ( "hex" ) ;
@@ -884,15 +860,6 @@ See docs/RELAY_KEYS.md for more information.
884860 status : "failed" ,
885861 } ) ;
886862
887- // Record failed pin fulfillment
888- try {
889- await Reputation . recordPinFulfillment ( gun , host , false ) ;
890- } catch ( e : any ) {
891- // Silent in production
892- if ( loggingConfig . debug ) {
893- loggers . server . warn ( "Failed to record pin fulfillment for reputation:" , e . message ) ;
894- }
895- }
896863 }
897864 } catch ( error : any ) {
898865 if ( loggingConfig . debug ) {
@@ -906,12 +873,6 @@ See docs/RELAY_KEYS.md for more information.
906873 status : "failed" ,
907874 } ) ;
908875
909- // Record failed pin fulfillment for reputation tracking
910- try {
911- await Reputation . recordPinFulfillment ( gun , host , false ) ;
912- } catch ( e : any ) {
913- // Silent in production
914- }
915876 }
916877 } ) ;
917878 } else {
@@ -1190,93 +1151,8 @@ See docs/RELAY_KEYS.md for more information.
11901151 addTimeSeriesPoint ( "connections.active" , activeWires ) ;
11911152 addTimeSeriesPoint ( "memory.heapUsed" , process . memoryUsage ( ) . heapUsed ) ;
11921153
1193- // Record pulse for reputation tracking (own uptime)
1194- try {
1195- await Reputation . recordPulse ( gun , host ) ;
1196- // Periodically update stored score (every 10 minutes = 20 pulses)
1197- if ( Math . random ( ) < 0.05 ) {
1198- // ~5% chance each pulse
1199- await Reputation . updateStoredScore ( gun , host ) ;
1200- }
1201- } catch ( e : any ) {
1202- // Non-critical, don't log every time
1203- }
1204-
1205- // Create frozen (immutable, signed) announcement every ~5 minutes
1206- // Only if relay user is initialized (has keypair for signing)
1207- try {
1208- const relayUser = getRelayUser ( ) ;
1209- if ( relayUser && relayUser . is && Math . random ( ) < 0.1 ) {
1210- // ~10% chance = every ~5 min
1211- const announcement = {
1212- type : "relay-announcement" ,
1213- host,
1214- port,
1215- name : relayConfig . name ,
1216- version : packageConfig . version ,
1217- uptime : process . uptime ( ) ,
1218- connections : pulse . connections ,
1219- ipfs : pulse . ipfs ,
1220- // Use object instead of array for GunDB compatibility
1221- capabilities : {
1222- "ipfs-pin" : true ,
1223- "storage-proof" : true ,
1224- "x402-subscription" : true ,
1225- "storage-deals" : true ,
1226- } ,
1227- } ;
1228-
1229- await FrozenData . createFrozenEntry (
1230- gun ,
1231- announcement ,
1232- ( relayUser as any ) ?. _ ?. sea , // SEA keypair
1233- "relay-announcements" ,
1234- host
1235- ) ;
1236- }
1237- } catch ( e : any ) {
1238- // Non-critical, frozen announcements are optional
1239- if ( loggingConfig . debug ) loggers . server . debug ( { err : e } , "Frozen announcement skipped" ) ;
1240- }
12411154 } , 30000 ) ; // 30 seconds
12421155
1243- // ============================================================================
1244- // GUNDB PEER DISCOVERY
1245- // ============================================================================
1246-
1247- try {
1248- const ownEndpoint = process . env . RELAY_HOST
1249- ? `https://${ process . env . RELAY_HOST } `
1250- : `http://localhost:${ port } ` ;
1251-
1252- // Start GunDB-based peer discovery
1253- syncGunDBPeers ( gun , ownEndpoint ) ;
1254- syncMulePeers ( gun ) ;
1255-
1256- // Announce presence on GunDB
1257- if ( relayKeyPair && relayKeyPair . pub ) {
1258- const relayInfo = {
1259- endpoint : ownEndpoint ,
1260- version : packageConfig . version ,
1261- alias : relayConfig . name ,
1262- } ;
1263-
1264- // Announce immediately
1265- announceRelayPresence ( gun , relayInfo , relayKeyPair . pub ) ;
1266-
1267- // And periodically to update 'lastSeen'
1268- setInterval ( ( ) => {
1269- announceRelayPresence ( gun , relayInfo , relayKeyPair . pub ) ;
1270- } , 60 * 1000 ) ; // Every minute
1271-
1272- loggers . server . info ( { pubKey : relayKeyPair . pub } , "📢 Relay presence announced on GunDB" ) ;
1273- }
1274-
1275- loggers . server . info ( "🔗 Started GunDB peer discovery" ) ;
1276- } catch ( error : any ) {
1277- loggers . server . warn ( { err : error } , "⚠️ Failed to start peer discovery" ) ;
1278- }
1279-
12801156 // Shutdown function
12811157 async function shutdown ( ) {
12821158 loggers . server . info ( "🛑 Shutting down Shogun Relay..." ) ;
0 commit comments