Skip to content

Kafka as source or destination for cardano blockchain sync

Notifications You must be signed in to change notification settings

cardanoapi/libcardano-kafka

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LibCardano Kafka

EXAMPLE USAGE create kafka instance with hosts and topic

const k = new Kafka(["172.31.0.6:3004:9092"], 'blockchain')

connect to node

const blockchain = createInMemoryClientWithPeer("sanchonet-node.play.dev.cardano.org:3001", 4, false)

send blocks as rollBack or rollForward

blockchain.pipeline("extendBlock", (block, cb) => {
    setImmediate(cb)
    const chainTip: ChainTip = [[block.slotNo, block.headerHash], block.blockNo]
    k.rollBack(chainTip)
    k.rollForward(chainTip)
})

to see the sent messages:

k.receiveKafkaMessage();

to see the blockchain info:

k.getBlockInfo()

to use inMemoryBlockchain's rollBack function

async function readBlock() {
    const data = await k.writeBlockchain('blockchain', function () { })
    console.log(data)
}

readBlock().catch((err) => {
    console.log('err');
})

About

Kafka as source or destination for cardano blockchain sync

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published