Skip to content

Commit

Permalink
fix: event-server requested ending incorrectly
Browse files Browse the repository at this point in the history
  • Loading branch information
zone117x committed Apr 5, 2024
1 parent 72c1306 commit e5299b9
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/event-stream/event-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ export async function startEventServer(opts: {

app.post(
'/new_block',
asyncHandler(async (req, res, next) => {
asyncHandler(async (req, res) => {
try {
const blockMessage: CoreNodeBlockMessage = JSON.parse(req.body);
await messageHandler.handleBlockMessage(opts.chainId, blockMessage, db);
Expand All @@ -919,7 +919,6 @@ export async function startEventServer(opts: {
}
await handleRawEventRequest(req);
res.status(200).json({ result: 'ok' });
next();
} catch (error) {
logger.error(error, 'error processing core-node /new_block');
res.status(500).json({ error: error });
Expand All @@ -929,13 +928,12 @@ export async function startEventServer(opts: {

app.post(
'/new_burn_block',
asyncHandler(async (req, res, next) => {
asyncHandler(async (req, res) => {
try {
const msg: CoreNodeBurnBlockMessage = JSON.parse(req.body);
await messageHandler.handleBurnBlock(msg, db);
await handleRawEventRequest(req);
res.status(200).json({ result: 'ok' });
next();
} catch (error) {
logger.error(error, 'error processing core-node /new_burn_block');
res.status(500).json({ error: error });
Expand All @@ -945,13 +943,12 @@ export async function startEventServer(opts: {

app.post(
'/new_mempool_tx',
asyncHandler(async (req, res, next) => {
asyncHandler(async (req, res) => {
try {
const rawTxs: string[] = JSON.parse(req.body);
await messageHandler.handleMempoolTxs(rawTxs, db);
await handleRawEventRequest(req);
res.status(200).json({ result: 'ok' });
next();
} catch (error) {
logger.error(error, 'error processing core-node /new_mempool_tx');
res.status(500).json({ error: error });
Expand All @@ -977,13 +974,12 @@ export async function startEventServer(opts: {

app.post(
'/attachments/new',
asyncHandler(async (req, res, next) => {
asyncHandler(async (req, res) => {
try {
const msg: CoreNodeAttachmentMessage[] = JSON.parse(req.body);
await messageHandler.handleNewAttachment(msg, db);
await handleRawEventRequest(req);
res.status(200).json({ result: 'ok' });
next();
} catch (error) {
logger.error(error, 'error processing core-node /attachments/new');
res.status(500).json({ error: error });
Expand All @@ -993,13 +989,12 @@ export async function startEventServer(opts: {

app.post(
'/new_microblocks',
asyncHandler(async (req, res, next) => {
asyncHandler(async (req, res) => {
try {
const msg: CoreNodeMicroblockMessage = JSON.parse(req.body);
await messageHandler.handleMicroblockMessage(opts.chainId, msg, db);
await handleRawEventRequest(req);
res.status(200).json({ result: 'ok' });
next();
} catch (error) {
logger.error(error, 'error processing core-node /new_microblocks');
res.status(500).json({ error: error });
Expand Down

0 comments on commit e5299b9

Please sign in to comment.