feat(execution): preserve durable recovery on canonical Rust core
This commit is contained in:
parent
5e9655de0b
commit
c01e96e4dd
27 changed files with 3644 additions and 182 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import type { PostgresClient } from '@stock-bot/services';
|
||||
import { refuseCanonicalAccount } from './canonical-paper';
|
||||
import type { Account, Fill, StoredOrder } from './model';
|
||||
import {
|
||||
ExecutionConflictError,
|
||||
|
|
@ -25,6 +26,7 @@ export class PostgresExecutionRepository implements ExecutionRepository {
|
|||
'SELECT state FROM simulation_accounts WHERE id = $1 FOR UPDATE',
|
||||
[id]
|
||||
);
|
||||
refuseCanonicalAccount(result.rows[0].state);
|
||||
const account: Account = result.rows[0].state;
|
||||
if (account.initialCapital !== initial.initialCapital) {
|
||||
throw new ExecutionConflictError(
|
||||
|
|
@ -52,6 +54,7 @@ export class PostgresExecutionRepository implements ExecutionRepository {
|
|||
if (!state.rows[0]) {
|
||||
throw new Error('Execution account is not initialized');
|
||||
}
|
||||
refuseCanonicalAccount(state.rows[0].state);
|
||||
const readOrder = async (column: 'id' | 'client_order_id', key: string) => {
|
||||
const result = await client.query(
|
||||
`SELECT payload FROM simulation_orders WHERE account_id = $1 AND ${column} = $2`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue