-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement silent block broadcasting
fixed event emitter issue fix: Add a delay function for silent block events fix: silent block broadcasting Fix: Use a more explicit event name for indexing blocks feat: implement silent block broadcasting fix: Make event emitter protected feat: implement silent block broadcasting
- Loading branch information
1 parent
861eef8
commit 3f0b282
Showing
14 changed files
with
169 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,3 @@ bitcoinCore: | |
rpcPass: polarpass | ||
rpcUser: polaruser | ||
rpcPort: 18445 | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/block-data-providers/base-block-data-provider.abstract.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const INDEXED_BLOCK_EVENT = 'INDEXED_BLOCK_EVENT'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Injectable, Logger } from '@nestjs/common'; | ||
import { | ||
WebSocketGateway, | ||
WebSocketServer, | ||
OnGatewayConnection, | ||
OnGatewayDisconnect, | ||
} from '@nestjs/websockets'; | ||
import { Server, WebSocket } from 'ws'; | ||
|
||
@Injectable() | ||
@WebSocketGateway() | ||
export class SilentBlocksGateway | ||
implements OnGatewayConnection, OnGatewayDisconnect | ||
{ | ||
private readonly logger = new Logger(SilentBlocksGateway.name); | ||
|
||
@WebSocketServer() server: Server; | ||
|
||
handleConnection(client: WebSocket) { | ||
const remoteAddress = (client as any)._socket.remoteAddress; | ||
this.logger.debug(`Client connected: ${remoteAddress}`); | ||
} | ||
|
||
handleDisconnect(client: WebSocket) { | ||
const remoteAddress = (client as any)._socket.remoteAddress; | ||
this.logger.debug(`Client disconnected: ${remoteAddress}`); | ||
} | ||
|
||
broadcastSilentBlock(silentBlock: Buffer) { | ||
for (const client of this.server.clients) { | ||
if (client.readyState === WebSocket.OPEN) { | ||
client.send(silentBlock); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters