LogoLogo
PAO DocsInfrastructure DocsDeveloper DocsPeerplays.com
  • Introduction to Peerplays
  • Concepts
    • Decentralization
    • Consensus Mechanisms Compared
  • Technology
    • Peerplays Technical Summary
    • Intro to Peerplays Tokens
    • Intro to Peerplays Liquidity Pools
      • Service Infrastructure Pools
    • Staking (PowerUp) in Peerplays
    • Gamified User Namespaces and Subject Matter Expert Committees
    • Peer-to-Peer Autonomous Organizations: Flow Diagram
    • Gamified Proof of Stake (GPOS)
      • Wallet User Guide
        • GPOS Panel
        • GPOS Landing Page
        • Power Up
        • Power Down
        • Vote
        • Thank you for voting!
      • FAQ
        • General
        • GPOS Panel
        • Power Up & Power Down
        • Voting
        • Participation Rewards
    • Sidechain Operator Nodes (SONs)
      • New to SONs?
        • What are Sidechain Operating Nodes?
        • How do SONs Work?
        • Why are SONs important?
        • How do SONs impact me?
        • SON Fees & Performance Requirements
        • Peerplays SONs
      • FAQ
      • Running a SON Node
    • NFTs and Marketplace
      • NFT marketplace in Python
      • NFT Operations in Python
      • NFT, Marketplace, HRP, and RBAC related Commands/Use Cases
      • NFT command reference
    • Peerplays DEX
      • User Guide
        • Account Creation
        • Dashboard
          • Bitcoin Transaction
        • Market Activity
        • Peerplays Blocks
        • Settings
        • Wallet
        • Profile
        • GPOS - Voting
        • Logout
  • Witnesses
    • What is a Peerplays Witness?
    • Becoming a Peerplays Witness
    • Hardware Requirements
    • Installation Guides
  • Bookie Oracle Suite (BOS)
    • Introduction to BOS
    • BOS Installation
    • BookieSports
    • Manual Intervention Tool (MINT)
  • Data Proxies
    • Introduction to Data Proxies
    • How Data Proxies Work
    • Data Proxy Set Up
  • Couch Potato
    • Introduction
    • Installation
    • User Guide
  • Random Number Generator (RNG)
    • RNG Technical Summary
    • RNG API
  • API
    • Peerplays Core API
      • Popular API Calls
      • Account History API
      • Asset API
      • Block API
      • Crypto API
      • Database API
      • Network Broadcast API
      • Network Nodes API
      • Orders API
    • Wallet API
      • Account Calls
      • Asset Calls
      • Blockchain Inspection
      • General Calls
      • Governance
      • Privacy Mode
      • Trading Calls
      • Transaction Builder
      • Wallet Calls
    • Bookie API
      • General
      • Tournaments
      • Listeners
    • Python Peerplays
      • Installation
      • Creating the wallet
      • Creating an Account
      • NFT
      • Market Place
      • HRP / RBAC
  • Connecting Elasticsearch to a blockchain node
  • GitLab
    • GitLab Ticket Templates
    • Labels
    • Time Tracking
  • Other Documentation
    • Peerplays Home
    • Infrastructure Docs
    • Developer Docs
    • Site Reliability Engineering
  • Known Issues
    • Peerplays Disaster Recovery Plan
    • Sept 2021 Mainnet Outage - Postmortem Report
  • Kickstart Guide
    • Peerplays Developer
  • Risk Register
    • Introduction
      • Bunker Issue
        • DDOS Attack
        • Hypervisor Compromised
        • Power and Backup Failure
        • Crypto Restriction
      • Core-Block Issue
        • Expensive Servers
        • Witness node - Not reachable
        • Witnesses get DDOS'd
        • Bad Actor infiltrate witness/SONs
      • Credential Security
        • NEX Open Source Vulnerabilities
        • Keyloggers, access to NEX deployment
        • Password manager hacked
        • SONs active keys exposed in configuration
    • Glossary
  • Operation Cost Estimation
    • Project Operations
    • Cost Estimation
Powered by GitBook
On this page
  • get_tournaments_in_state
  • get_registered_tournaments
  • get_tournaments
Export as PDF
  1. API
  2. Bookie API

Tournaments

get_tournaments_in_state

Get a list of tournament ids for upcoming tournaments

Apis.instance().db_api().exec('get_tournaments_in_state', [stateString, accountId])
  • stateString: The tournament state

  • accountId:Account Id

All tournaments for the selected state.

ChainStore.prototype.getTournamentIdsInState = function getTournamentIdsInState(accountId, stateString) {
    var _this7 = this;

    var tournamentIdsForThisAccountAndState = void 0;
    var tournamentIdsForThisAccount = this.tournament_ids_by_state.get(accountId);

    if (tournamentIdsForThisAccount === undefined) {
      tournamentIdsForThisAccountAndState = new _immutable2.default.Set();
      tournamentIdsForThisAccount = new _immutable2.default.Map().set(stateString, tournamentIdsForThisAccountAndState);
      this.tournament_ids_by_state = this.tournament_ids_by_state.set(accountId, tournamentIdsForThisAccount);
    } else {
      tournamentIdsForThisAccountAndState = tournamentIdsForThisAccount.get(stateString);

      if (tournamentIdsForThisAccountAndState !== undefined) {
        return tournamentIdsForThisAccountAndState;
      }

      tournamentIdsForThisAccountAndState = new _immutable2.default.Set();
      tournamentIdsForThisAccount = tournamentIdsForThisAccount.set(stateString, tournamentIdsForThisAccountAndState);
      this.tournament_ids_by_state = this.tournament_ids_by_state.set(accountId, tournamentIdsForThisAccount);
    }

    _ws.Apis.instance().db_api().exec('get_tournaments_in_state', [stateString, 100]).then(function (tournaments) {
      var originalTournamentIdsInState = _this7.tournament_ids_by_state.getIn([accountId, stateString]);
      // call updateObject on each tournament, which will classify it
      tournaments.forEach(function (tournament) {
        /**
         * Fix bug: we cant update tournament_ids_by_state if objects_by_id has a tournament
         */
        if (!originalTournamentIdsInState.get(tournament.id)) {
          _this7.clearObjectCache(tournament.id);
        }

        _this7._updateObject(tournament);
      });

      var tournament_id = _this7.tournament_ids_by_state.getIn([accountId, stateString]);

      if (tournament_id !== originalTournamentIdsInState) {
        _this7.notifySubscribers();
      }
    });
    return tournamentIdsForThisAccountAndState;
  };

get_registered_tournaments

Get a list of registered tournaments by account id.

Apis.instance().db_api().exec('get_registered_tournaments', [accountId, 100])
  • accountId: Account Id.

All registered tournaments for an account.

ChainStore.prototype.getRegisteredTournamentIds = function getRegisteredTournamentIds(accountId) {
    var _this8 = this;

    var tournamentIds = this.registered_tournament_ids_by_player.get(accountId);

    if (tournamentIds !== undefined) {
      return tournamentIds;
    }

    tournamentIds = new _immutable2.default.Set();
    this.registered_tournament_ids_by_player = this.registered_tournament_ids_by_player.set(accountId, tournamentIds);

    _ws.Apis.instance().db_api().exec('get_registered_tournaments', [accountId, 100]).then(function (registered_tournaments) {
      var originalTournamentIds = _this8.registered_tournament_ids_by_player.get(accountId);
      var newTournamentIds = new _immutable2.default.Set(registered_tournaments);

      if (!originalTournamentIds.equals(newTournamentIds)) {
        _this8.registered_tournament_ids_by_player = _this8.registered_tournament_ids_by_player.set(accountId, newTournamentIds);
        _this8.notifySubscribers();
      }
    });

    return tournamentIds;
  };

get_tournaments

Get all tournaments between last_tournament_id and start_tournament_id.

 _ws.Apis.instance().db_api().exec('get_tournaments', [last_tournament_id, limit, start_tournament_id])
  • last_tournament_id: The last tournament id

  • limit: The limit of tournaments to return.

  • start_tournament_id: The starting tournament id.

A list of all tournaments between last_tournament_id and start_tournament_id.

ChainStore.prototype.getTournaments = function getTournaments(last_tournament_id) {
    var _this20 = this;

    var limit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5;
    var start_tournament_id = arguments[2];

    return _ws.Apis.instance().db_api().exec('get_tournaments', [last_tournament_id, limit, start_tournament_id]).then(function (tournaments) {
      var list = _immutable2.default.List();

      _this20.setLastTournamentId(null);

      if (tournaments && tournaments.length) {
        list = list.withMutations(function (l) {
          tournaments.forEach(function (tournament) {
            if (!_this20.objects_by_id.has(tournament.id)) {
              _this20._updateObject(tournament);
            }

            l.unshift(_this20.objects_by_id.get(tournament.id));
          });
        });
      }

      return list;
    });
  };

PreviousGeneralNextListeners

Last updated 1 year ago