diff --git a/backend/services/docker-compose.2.0.yml b/backend/services/docker-compose.2.0.yml index 7810b940..f943f117 100644 --- a/backend/services/docker-compose.2.0.yml +++ b/backend/services/docker-compose.2.0.yml @@ -460,6 +460,11 @@ services: BURN_POOL_WALLET_ADDRESS: ${BURN_POOL_WALLET_ADDRESS:-} MINING_POOL_WALLET_USERNAME: ${MINING_POOL_WALLET_USERNAME:-} MINING_POOL_WALLET_ADDRESS: ${MINING_POOL_WALLET_ADDRESS:-} + # fUSDT 注入钱包 (MPC) - 认种自动转积分值到做市商 + FUSDT_INJECTION_WALLET_USERNAME: ${FUSDT_INJECTION_WALLET_USERNAME:-} + FUSDT_INJECTION_WALLET_ADDRESS: ${FUSDT_INJECTION_WALLET_ADDRESS:-} + # CDC 主题配置(Debezium CDC outbox) + CDC_TOPIC_CONTRIBUTION_OUTBOX: ${CDC_TOPIC_CONTRIBUTION_OUTBOX:-cdc.contribution.outbox} # 区块扫描配置 BLOCK_SCAN_INTERVAL_MS: ${BLOCK_SCAN_INTERVAL_MS:-5000} BLOCK_CONFIRMATIONS_REQUIRED: ${BLOCK_CONFIRMATIONS_REQUIRED:-12} diff --git a/backend/services/mining-blockchain-service/src/application/event-handlers/adoption-injection.handler.ts b/backend/services/mining-blockchain-service/src/application/event-handlers/adoption-injection.handler.ts index 02d607db..a5ea81d5 100644 --- a/backend/services/mining-blockchain-service/src/application/event-handlers/adoption-injection.handler.ts +++ b/backend/services/mining-blockchain-service/src/application/event-handlers/adoption-injection.handler.ts @@ -40,6 +40,10 @@ export class AdoptionInjectionHandler implements OnModuleInit { ) {} onModuleInit() { + if (!this.injectionConsumer.isEnabled()) { + this.logger.warn(`[INIT] Adoption Injection Consumer 未启用,Handler 不注册`); + return; + } this.injectionConsumer.onAdoptionInjectionRequested( this.handleInjection.bind(this), ); diff --git a/backend/services/mining-blockchain-service/src/infrastructure/kafka/adoption-injection-consumer.service.ts b/backend/services/mining-blockchain-service/src/infrastructure/kafka/adoption-injection-consumer.service.ts index 44d18cac..ccb8d4fa 100644 --- a/backend/services/mining-blockchain-service/src/infrastructure/kafka/adoption-injection-consumer.service.ts +++ b/backend/services/mining-blockchain-service/src/infrastructure/kafka/adoption-injection-consumer.service.ts @@ -30,6 +30,7 @@ export class AdoptionInjectionConsumerService implements OnModuleInit, OnModuleD private readonly topic: string; private injectionHandler?: AdoptionInjectionEventHandler; + private enabled = false; constructor(private readonly configService: ConfigService) { this.topic = this.configService.get( @@ -38,7 +39,19 @@ export class AdoptionInjectionConsumerService implements OnModuleInit, OnModuleD ); } + isEnabled(): boolean { + return this.enabled; + } + async onModuleInit() { + // 未配置注入钱包时不启用消费者 + const walletUsername = this.configService.get('FUSDT_INJECTION_WALLET_USERNAME'); + const walletAddress = this.configService.get('FUSDT_INJECTION_WALLET_ADDRESS'); + if (!walletUsername || !walletAddress) { + this.logger.warn(`[INIT] fUSDT 注入钱包未配置,Adoption Injection Consumer 不启用`); + return; + } + const brokers = this.configService.get('KAFKA_BROKERS')?.split(',') || ['localhost:9092']; const clientId = this.configService.get('KAFKA_CLIENT_ID') || 'mining-blockchain-service'; const groupId = 'mining-blockchain-adoption-injection'; @@ -81,6 +94,7 @@ export class AdoptionInjectionConsumerService implements OnModuleInit, OnModuleD this.logger.log(`[SUBSCRIBE] Subscribed to ${this.topic}`); await this.startConsuming(); + this.enabled = true; } catch (error) { this.logger.error(`[ERROR] Failed to connect Adoption Injection consumer`, error); }