Skip to content

Stream-based RLP (recursive length prefix) encoder/decoder

License

Notifications You must be signed in to change notification settings

no2chem/rlp-stream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RLP stream implementation

Build Status

This package provides a streaming implementation of the Recursive Length Prefix (RLP) encoding used in Ethereum, as specified in the Ethereum yellow paper (yellowpaper.io). You can find API documentation here. Typescript definitions are included.

The streaming transform enables efficient reading of large RLP encoded files, such as blockchain dump files produced by geth. You can obtain blockchain dump files by running:

$ geth export <file> <start block> <end block>

And then use the following script to print out each block one at a time as they are encountered:

import {RlpDecoderTransform, RlpItem} from 'rlp-stream';
const asyncChunks = require('async-chunks');

const decoder = new RlpDecoderTransform();
fs.createReadStream(file).pipe(decoder);

for await (const chunk of asyncChunks(decoder)) {
  console.log(JSON.stringify(chunk, null, 2));
}

If your implementation has native for-await support, you don't need async-chunks.

About

Stream-based RLP (recursive length prefix) encoder/decoder

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published