Skip to content

Commit

Permalink
fix(agent): crush on real mode account publishing (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
zccz14 authored Oct 30, 2023
1 parent 5fda80a commit 4dbaa50
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 10 additions & 0 deletions common/changes/@yuants/agent/2023-10-30-15-20.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@yuants/agent",
"comment": "crush on real mode account publishing",
"type": "patch"
}
],
"packageName": "@yuants/agent"
}
8 changes: 4 additions & 4 deletions libraries/agent/src/AgentScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,12 @@ export const AgentScene = async (terminal: Terminal, agentConf: IAgentConf) => {
if (agentConf.publish_account) {
const unit = new BasicUnit(kernel);
const mapAccountIdToAccountInfo$: Record<string, Subject<IAccountInfo>> = {};
accountInfoUnit.mapAccountIdToAccountInfo.forEach((accountInfo) => {
const accountInfo$ = (mapAccountIdToAccountInfo$[accountInfo.account_id] = new Subject());
terminal.provideAccountInfo(accountInfo$);
});
unit.onIdle = () => {
for (const accountInfo of accountInfoUnit.mapAccountIdToAccountInfo.values()) {
if (!mapAccountIdToAccountInfo$[accountInfo.account_id]) {
mapAccountIdToAccountInfo$[accountInfo.account_id] = new Subject();
terminal.provideAccountInfo(mapAccountIdToAccountInfo$[accountInfo.account_id]);
}
const accountInfo$ = mapAccountIdToAccountInfo$[accountInfo.account_id];
accountInfo$.next(accountInfo);
}
Expand Down

0 comments on commit 4dbaa50

Please sign in to comment.