Skip to content

Commit 83e2eca

Browse files
jordanmackgitbook-bot
authored andcommitted
GITBOOK-549: change request with no subject merged in GitBook
1 parent b72bb61 commit 83e2eca

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

transactions/cell-management.md

+15-10
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,21 @@ An indexer is a piece of software that helps speed up the process of locating ce
88

99
![](../.gitbook/assets/ckb-indexer.png)
1010

11-
An indexer runs as separate node that continuously monitors a Nervos CKB node for new block data. As new blocks are found, the cell information is extracted and organized internally by the indexer until needed. Dapp frontends and backends can then interface directly with the indexer to query for information about cells.
11+
An indexer monitors for new block data, and then extracts and organizes the cell information so it can be more quickly located when needed. Dapp frontends and backends can then interface directly with the indexer to query for information about cells.
12+
13+
The way that indexers have been implemented changed over time, so you may see them referenced as a separate stand-alone node or as part of the CKB node. In the newest generation of node software, the CKB node includes the indexer functionality, and it is enabled in `ckb.toml`.
1214

1315
{% code lineNumbers="true" %}
1416
```javascript
15-
const {initializeConfig} = require("@ckb-lumos/config-manager");
16-
const {Indexer} = require("@ckb-lumos/ckb-indexer");
17-
const config = require("./config.json");
17+
import fs from "fs";
18+
import {initializeConfig} from "@ckb-lumos/config-manager";
19+
import {Indexer} from "@ckb-lumos/ckb-indexer";
20+
const CONFIG = JSON.parse(fs.readFileSync("../config.json"));
1821

1922
const NODE_URL = "http://127.0.0.1:8114/";
20-
const INDEXER_URL = "http://127.0.0.1:8116/";
23+
const INDEXER_URL = "http://127.0.0.1:8114/";
2124

22-
initializeConfig(config);
25+
initializeConfig(CONFIG);
2326
const indexer = new Indexer(INDEXER_URL, NODE_URL);
2427

2528
(async function()
@@ -29,11 +32,13 @@ const indexer = new Indexer(INDEXER_URL, NODE_URL);
2932
```
3033
{% endcode %}
3134

32-
On line 8 we start with `initializeConfig(config)`. This uses the `config.json` file in your current working directory to initialize Lumos.
35+
On lines 6 and 7 we define the CKB node RPC URL and the CKB Indexer RPC URL. These are the same value because the new versions of the CKB node now include the indexer functionality, where it had previously been a separate server.
36+
37+
On line 9 we start with `initializeConfig(CONFIG)`. This uses the `config.json` file in your current working directory to initialize Lumos.
3338

34-
On line 9 we create a new instance of `Indexer` which will pass requests to the CKB Indexer node JSON RPC which we specified.
39+
On line 10 we create a new instance of `Indexer` which will pass requests to the CKB Indexer node JSON RPC which we specified.
3540

36-
Finally, on line 13 we use `indexer` to retrieve and display the most recent tip block on the console.
41+
Finally, on line 14 we use `indexer` to retrieve and display the most recent tip block on the console.
3742

3843
### Automated Cell Collection
3944

@@ -102,7 +107,7 @@ The rest of the code should be fairly easy to understand. It continuously gather
102107

103108
### Capacity Management
104109

105-
Let's say that Charlie wants to send Bob 100 CKBytes. If Charlie had a cell that contained exactly enough CKBytes, this would be a very straight forward transaction.
110+
Let's say that Charlie wants to send Bob 100 CKBytes. If Charlie had a cell that contained exactly enough CKBytes, this would be a very straightforward transaction.
106111

107112
![](../.gitbook/assets/cell-capacity-management.png)
108113

0 commit comments

Comments
 (0)