Skip to content

Conversation

@Ryang-21
Copy link
Collaborator

@Ryang-21 Ryang-21 commented Mar 4, 2025

  • Implements support for multiple pools to be monitored

@Ryang-21 Ryang-21 requested a review from mootz12 March 4, 2025 16:38
@Ryang-21 Ryang-21 marked this pull request as ready for review March 6, 2025 19:53
@Ryang-21 Ryang-21 requested a review from mootz12 March 6, 2025 19:54
@Ryang-21 Ryang-21 force-pushed the multi-pool-support branch from e3f490a to 363fdfd Compare March 10, 2025 18:24
@Ryang-21 Ryang-21 force-pushed the multi-pool-support branch from f8b077f to 1fec978 Compare March 14, 2025 17:58
@Ryang-21 Ryang-21 force-pushed the multi-pool-support branch from 66f8e12 to 34abc43 Compare March 19, 2025 17:22
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be some argument as to create N bidder_submitters, one for each filler entry.

However, the odds this makes any meaningful difference to the ability for a bot to fill auctions is like 0, so IMO for now lets keep it like this. Just wanted to leave a comment here incase we opt to do this in the future.

let cachedUser = this.user_cache.get(poolId + userId);
try {
if (cachedUser) {
if ('timeout' in cachedUser && cachedUser.timeout > Date.now()) throw cachedUser.error;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need to use a timeout

per usage of this class, it caches everything until you rebuild it.

Most of our workflows are on a per ledger basis, so this is OK

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this applies for all the fns in this class

export class SorobanHelper {
network: Network;
private pool_cache: Map<string, Pool | ErrorTimeout>;
private pool_cache: Map<string, Pool | Error>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need an error?

Can't it just be a Map<string, Pool>?

      if (cachedPool) {
        if (cachedPool instanceof Pool) return cachedPool;
        else throw cachedPool;
      }

is a bit confusing to me. IMO it's fine as:

    try {
     let cachedPool = this.pool_cache.get(poolId);
      if (cachedPool !== undefined) {
          return cachedPool;
      }
      let pool: Pool = await PoolV1.load(this.network, poolId);
      this.pool_cache.set(poolId, pool);
      return pool;
    } catch (e: any) {
      logger.error(`Error loading ${poolId} pool:  ${e}`);
      throw e;
    }

If this errors, whatever is being processed is gonna stop anyway and wait to be re-tried. If for some reason it doesn't before SorobanHelper is reconstructed, it probably should try and fetch the pool again.

mootz12
mootz12 previously approved these changes Apr 3, 2025
@Ryang-21 Ryang-21 merged commit e90860b into main Apr 3, 2025
1 of 2 checks passed
@Ryang-21 Ryang-21 deleted the multi-pool-support branch April 3, 2025 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants