Skip to content

Commit

Permalink
chunk entities and swap to mainnet indexer
Browse files Browse the repository at this point in the history
  • Loading branch information
ponderingdemocritus committed Dec 18, 2024
1 parent 7a7b60d commit 05a4b7e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
10 changes: 5 additions & 5 deletions client/.env.preview
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ VITE_PUBLIC_MASTER_PRIVATE_KEY=0x075362a844768f31c8058ce31aec3dd7751686440b4f220
VITE_PUBLIC_WORLD_ADDRESS="0x00fd85ef42eaed3b90d02d2cdc7417d6cae189ff4ba876aa5608551afbf1fb47"
VITE_PUBLIC_ACCOUNT_CLASS_HASH="0x07dc7899aa655b0aae51eadff6d801a58e97dd99cf4666ee59e704249e51adf2"
VITE_PUBLIC_FEE_TOKEN_ADDRESS=0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7
VITE_PUBLIC_TORII=https://api.cartridge.gg/x/sepolia-rc-19/torii
VITE_PUBLIC_NODE_URL=https://api.cartridge.gg/x/starknet/sepolia
VITE_PUBLIC_TORII=https://api.cartridge.gg/x/mainnet-cache-2/torii
VITE_PUBLIC_NODE_URL=https://api.cartridge.gg/x/starknet/mainnet
VITE_PUBLIC_DEV=false
VITE_PUBLIC_GAME_VERSION="v1.0.0-rc7"
VITE_PUBLIC_SHOW_FPS=false
VITE_PUBLIC_GRAPHICS_DEV=false
VITE_PUBLIC_TORII_RELAY=/dns4/api.cartridge.gg/tcp/443/x-parity-wss/%2Fx%2Fsepolia-rc-19%2Ftorii%2Fwss
VITE_PUBLIC_TORII_RELAY=/dns4/api.cartridge.gg/tcp/443/x-parity-wss/%2Fx%mainnet-cache-2%2Ftorii%2Fwss
VITE_SEASON_PASS_ADDRESS=0x23cc88996a5f9c7bcb559fdcffc257c0f75abe60f2a7e5d5cd343f8a95967f7
VITE_REALMS_ADDRESS=0x3205f47bd6f0b5e9cd5c79fcae19e12523a024709776d0a9e8b375adf63468d
VITE_LORDS_ADDRESS=0x0342ad5cc14002c005a5cedcfce2bd3af98d5e7fb79e9bf949b3a91cf145d72e

VITE_PUBLIC_CHAIN=sepolia
VITE_PUBLIC_SLOT=sepolia-rc-19
VITE_PUBLIC_CHAIN=mainnet
VITE_PUBLIC_SLOT=mainnet-cache-2

VITE_SOCIAL_LINK=http://bit.ly/3Zz1mpp

Expand Down
1 change: 0 additions & 1 deletion client/src/dojo/entityWorker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { debounce } from "lodash";

let toriiClient = null;
let entityBatch = {};
let logging = false;
const DEBOUNCE_DELAY = 1000;
Expand Down
19 changes: 13 additions & 6 deletions client/src/dojo/indexedDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,21 @@ async function syncEntitiesFromStorage<S extends Schema>(

request.onsuccess = () => {
const entities = request.result;
const entityMap: Entities = {};

for (const entity of entities) {
const { id, ...data } = entity;
entityMap[id] = data;
}
const CHUNK_SIZE = 50000;

// Process entities in chunks
for (let i = 0; i < entities.length; i += CHUNK_SIZE) {
const chunk = entities.slice(i, i + CHUNK_SIZE);
const chunkMap: Entities = {};

setEntities(entityMap, components, false);
for (const entity of chunk) {
const { id, ...data } = entity;
chunkMap[id] = data;
}

setEntities(chunkMap, components, false);
}

resolve();
};
Expand Down

0 comments on commit 05a4b7e

Please sign in to comment.