libcardano v1.4.27
Cardano Node JS
Components:
1.Interceptor
It intercepts connection between two cardano-nodes. The communication is logged with decoded protocol messages.
example:
##
## [[ Node1 ]] ----->> [127.0.0.1:3001 [[Interceptor]]] ----->> [172.31.0.15:3002 [[Node 2]]]
##
yarn interceptor 0.0.0.0:3001 172.31.0.15:3002
2.Client
Attempts connection to remote node and
- maintain connection with it with periodic ping
- log all the communication to/from the server
example:
yarn client preview-node.world.dev.cardano.org:30002
3. Using As a Library
3.1 Following a node for latest transactions.
import { createInMemoryClientWithPeer } from "libcardano/helper";
import { parseRawBlockBody } from "libcardano/cardano/ledger-serialization/transaction";
import * as process from "process";
const blockchain = createInMemoryClientWithPeer(process.argv[2] || "sanchonet-node.play.dev.cardano.org:3001", {
networkMagic: parseInt(process.argv[3]) || 4,
startPoint: "Latest",
});
blockchain.on("extendBlock", (block) => {
const transactions = parseRawBlockBody(block.body);
console.log(
"RollForward :", block.headerHash.toString("hex"),
"blockNo:", block.blockNo,
"slotNo:", block.slotNo,
"txCount:", transactions.length
);
});
blockchain.pipeline("rollback", ([[slot, headerHash], blockNo], _currentTip, cb) => {
console.log("Rollback :", headerHash.toString("hex"), "blockNo:", blockNo, "slotNo:", slot);
setImmediate(cb);
});
7 months ago
7 months ago
9 months ago
9 months ago
9 months ago
7 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 months ago
6 months ago
7 months ago
6 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
8 months ago
8 months ago
8 months ago
8 months ago
7 months ago
7 months ago
7 months ago
9 months ago
11 months ago
10 months ago
10 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
12 months ago
12 months ago
1 year ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago