-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add default host (optional) - set default startblock - improve stopBlock handling - update example using ETH
- Loading branch information
1 parent
0f3f3df
commit 1eadea5
Showing
7 changed files
with
83 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Substreams, download } from "../src"; | ||
|
||
// User input | ||
const spkg = "https://github.com/pinax-network/subtivity-substreams/releases/download/v0.1.0/subtivity-ethereum-v0.1.0.spkg"; | ||
const outputModule = "map_block_stats"; | ||
const startBlockNum = "300000"; | ||
const stopBlockNum = "+10"; | ||
|
||
// Initialize Substreams | ||
const substreams = new Substreams(outputModule, { | ||
startBlockNum, | ||
stopBlockNum, | ||
authorization: process.env.SUBSTREAMS_API_TOKEN | ||
}); | ||
|
||
(async () => { | ||
// download Substream from IPFS | ||
const {modules, registry} = await download(spkg); | ||
|
||
// Find Protobuf message types from registry | ||
const BlockStats = registry.findMessage("subtivity.v1.BlockStats"); | ||
if ( !BlockStats) throw new Error("Could not find BlockStats message type"); | ||
|
||
substreams.on("mapOutput", output => { | ||
const decoded = BlockStats.fromBinary(output.data.mapOutput.value); | ||
console.log(decoded); | ||
}); | ||
|
||
// start streaming Substream | ||
await substreams.start(modules); | ||
|
||
// end of Substream | ||
console.log("done"); | ||
process.exit(); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters