自托管 Indexer API
本指南将带你设置自托管 Indexer API。
- 需要运行中的 PostgreSQL 实例,并具有有效的用户和数据库。本示例中的用户为
postgres,数据库为indexer。 - 如果希望使用 Docker,必须已安装 Docker。安装指南。
运行服务需要定义配置文件。先使用以下模板:
health_check_port: 8084server_config: processor_config: type: default_processor postgres_connection_string: postgresql://postgres:@localhost:5432/indexer indexer_grpc_data_service_address: 127.0.0.1:50051 indexer_grpc_http2_ping_interval_in_secs: 60 indexer_grpc_http2_ping_timeout_in_secs: 10 auth_token: AUTH_TOKEN接下来可能需要修改其中一些字段的值。下面介绍几个字段。
processor_name
Section titled “processor_name”这是希望运行的处理器。可在此处查看可用处理器。一些示例:
- coin_processor
- ans_processor
- token_v2_processor
postgres_connection_string
Section titled “postgres_connection_string”这是 PostgreSQL 数据库的连接字符串,格式应为 postgresql://<username>:<password>@<host>:<port>/<database>。
indexer_grpc_data_service_address
Section titled “indexer_grpc_data_service_address”这是交易流服务的 URL。若使用 Labs 托管实例,可在此页面找到每个网络的 URL。请确保为要索引的网络选择正确 URL。若在本地运行服务,值应为 127.0.0.1:50051。
auth_token
Section titled “auth_token”这是用于连接交易流服务的身份验证令牌。若使用 Labs 托管实例,可通过 API Gateway 获得 API 密钥。详见此页面。
使用源码运行
Section titled “使用源码运行”克隆仓库:
# SSHgit clone git@github.com:aptos-labs/aptos-indexer-processors-v2.git
# HTTPSgit clone https://github.com/aptos-labs/aptos-indexer-processors-v2.git前往服务目录:
cd aptos-indexer-processorscd rust/processor运行服务:
cargo run --release -- -c config.yaml使用 Docker 运行
Section titled “使用 Docker 运行”要使用 Docker 运行服务,请使用以下命令:
docker run -it --network host --mount type=bind,source=/tmp/config.yaml,target=/config.yaml aptoslabs/indexer-processor-rust -c /config.yaml该命令将容器绑定到主机网络,并将配置文件从主机挂载到容器。本次调用假设主机中的配置文件位于 /tmp/config.yaml。
在 DockerHub 上查看镜像:https://hub.docker.com/r/aptoslabs/indexer-processor-rust/tags。