-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rpc): add new order events rpc subscriptions
This commit replaces the old streaming rpc subscription calls with three new streaming rpc calls: - subscribeAddedOrders: Notifies when orders are added to the order book. - subscribeRemovedOrders: Notifies when orders are removed from the order book. - subscribeSwaps: Notifies when swaps that are initiated by a remote user are completed. It also restructures and updates the `Order` grpc message type. Closes #123.
- Loading branch information
Showing
20 changed files
with
1,300 additions
and
943 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { loadXudClient } from '../command'; | ||
import { Arguments } from 'yargs'; | ||
import { SubscribeAddedOrdersRequest, Order, SubscribeRemovedOrdersRequest, SubscribeSwapsRequest, Swap, OrderRemoval } from '../../proto/xudrpc_pb'; | ||
|
||
export const command = 'streamorders'; | ||
|
||
export const describe = 'stream order added, removed, and swapped events (DEMO)'; | ||
|
||
export const handler = (argv: Arguments) => { | ||
const addedOrdersSubscription = loadXudClient(argv).subscribeAddedOrders(new SubscribeAddedOrdersRequest()); | ||
addedOrdersSubscription.on('data', (order: Order) => { | ||
console.log(`Order added: ${JSON.stringify(order.toObject())}`); | ||
}); | ||
|
||
const removedOrdersSubscription = loadXudClient(argv).subscribeRemovedOrders(new SubscribeRemovedOrdersRequest()); | ||
removedOrdersSubscription.on('data', (orderRemoval: OrderRemoval) => { | ||
console.log(`Order removed: ${JSON.stringify(orderRemoval.toObject())}`); | ||
}); | ||
|
||
const swapsSubscription = loadXudClient(argv).subscribeSwaps(new SubscribeSwapsRequest()); | ||
swapsSubscription.on('data', (swap: Swap) => { | ||
console.log(`Order swapped: ${JSON.stringify(swap.toObject())}`); | ||
}); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
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
Oops, something went wrong.