eos

View on GitHub

mongo_db_plugin

[[warning Deprecation Notice]]
  The mongo_db_plugin is deprecated and will no longer be maintained. Please refer to the state_history_plugin and the history-tools for better options to archive blockchain data.

Description

The optional eosio::mongo_db_plugin provides archiving of blockchain data into a MongoDB. It is recommended that the plugin be added to a non-producing node as it is designed to shut down on any failed insert into the MongoDB and it is resource intensive. For best results dedicate a nodeos instance to running this one plugin. The rationale behind this shutdown on error is so that any issues with connectivity or the mongo database can be fixed and nodeos can be restarted without having to resync or replay.

Important Notes

Recommendations

Options

These can be specified from both the command-line or the config.ini file:

  -q [ --mongodb-queue-size ] arg (=256)
                                        The target queue size between nodeos
                                        and MongoDB plugin thread.
  --mongodb-abi-cache-size              The maximum size of the abi cache for
                                        serializing data.
  --mongodb-wipe                        Required with --replay-blockchain,
                                        --hard-replay-blockchain, or
                                        --delete-all-blocks to wipe mongo
                                        db.This option required to prevent
                                        accidental wipe of mongo db. 
                                        Defaults to false.
  --mongodb-block-start arg (=0)        If specified then only abi data pushed
                                        to mongodb until specified block is
                                        reached.
  -m [ --mongodb-uri ] arg              MongoDB URI connection string, see:
                                        https://docs.mongodb.com/master/referen
                                        ce/connection-string/. If not specified
                                        then plugin is disabled. Default
                                        database 'EOS' is used if not specified
                                        in URI. Example: mongodb://127.0.0.1:27
                                        017/EOS
  --mongodb-update-via-block-num arg (=0)
                                        Update blocks/block_state with latest
                                        via block number so that duplicates are
                                        overwritten.                         
  --mongodb-store-blocks                Enables storing blocks in mongodb.
                                        Defaults to true.
  --mongodb-store-block-states          Enables storing block state in mongodb.
                                        Defaults to true.
  --mongodb-store-transactions          Enables storing transactions in mongodb.
                                        Defaults to true.
  --mongodb-store-transaction-traces    Enables storing transaction traces in                                             mongodb.
                                        Defaults to true.
  --mongodb-store-action-traces         Enables storing action traces in mongodb.
                                        Defaults to true.
  --mongodb-filter-on                   Mongodb: Track actions which match
                                        receiver:action:actor. Actor may be blank
                                        to include all. Receiver and Action may
                                        not be blank. Default is * include
                                        everything.
  --mongodb-filter-out                  Mongodb: Do not track actions which match
                                        receiver:action:actor. Action and Actor
                                        both blank excludes all from reciever.                                           Actor blank excludes all from
                                        reciever:action. Receiver may not be
                                        blank.

Notes

Example Filters

mongodb-filter-out = eosio:onblock:
mongodb-filter-out = gu2tembqgage::
mongodb-filter-out = blocktwitter:: 
[[warning Warning]]
  When the mongo_db_plugin is turned on, the target mongodb instance may take a lot of storage space. With all collections enabled and no filters applied, the mongodb data folder can easily occupy hundreds of GBs of data. It is recommended that you tailor the options and utilize the filters as you need in order to maximize storage efficiency.

Collections

The equivalent of /v1/history/get_controlled_acounts with mongo: db.account_controls.find({"controlling_account":"hellozhangyi"}).pretty()

Examples

The mongodb equivalent of /v1/history/get_key_accounts RPC API endpoint:

db.pub_keys.find({"public_key":"EOS7EarnUhcyYqmdnPon8rm7mBCTnBoot6o7fE2WzjvEX2TdggbL3"}).pretty()

Dependencies