BlockIndexState, is a mongoose defined schema, where dapp know about the processed blocks,
Demux watch the node block from particular defined block[ eg:153343 https://github.com/EOSIO/demux-js#example, check NodeosActionReader
] block and store the state of block that being watched and continue from that point.
async updateIndexState (state, block, isReplay) {
const { blockInfo } = block
try {
await state.blockIndexState.update({}, {
blockNumber: blockInfo.blockNumber,
blockHash: blockInfo.blockHash,
isReplay
}, { upsert: true }).exec()
} catch (err) {
console.error(err)
}
}
async loadIndexState () {
try {
let blockHash
let blockNumber
const indexState = await BlockIndexState.findOne({}).exec()
if (indexState) {
({ blockHash, blockNumber } = indexState)
}
if (blockNumber && blockHash) {
return { blockNumber, blockHash }
}
return { blockNumber: 0, blockHash: '' }
} catch (err) {
console.error(err)
}
one can clearly see that updateIndexState,loadIndexState alters/reads BlockIndexState
references
https://github.com/EOSIO/eosio-project-demux-example/issues/31