connex icon indicating copy to clipboard operation
connex copied to clipboard

Getting last block fails

Open silentlight opened this issue 3 years ago • 6 comments

Hi all,

When using:

const lastBlock = await this.connex.thor.block().get();

ocassionaly I get genesis block (height = 0).

Do you know what might be wrong.

silentlight avatar Oct 09 '21 19:10 silentlight

if (!this.connex.thor.status.head.number) {
    await this.connex.thor.ticker().next()
}
const lastBlock = await this.connex.thor.block().get()

add lines to check the head number should work

qianbin avatar Oct 21 '21 02:10 qianbin

Have you considered including that check in the block() function? this.connex.thor.status.head.number should never be null or undefined... await this.connex.thor.block().get() sometimes returns null. That is the same issue, isn't it?

ehamery avatar May 03 '22 01:05 ehamery

Have you considered including that check in the block() function? this.connex.thor.status.head.number should never be null or undefined... await this.connex.thor.block().get() sometimes returns null. That is the same issue, isn't it?

await this.connex.thor.block().get() returns null only if the block specified by the given arg revision does not exists.

qianbin avatar May 03 '22 06:05 qianbin

If you do not provide any argument to the block() function, await this.connex.thor.block().get() should return the head block, so it should never be null and it sometimes is. That looks like a bug to me. Same as this.connex.thor.status.head.number being null.

ehamery avatar May 03 '22 07:05 ehamery

If you do not provide any argument to the block() function, await this.connex.thor.block().get() should return the head block, so it should never be null and it sometimes is. That looks like a bug to me. Same as this.connex.thor.status.head.number being null.

You're right. I'll look into the code. Can you provides some context of your code piece?

qianbin avatar May 03 '22 07:05 qianbin

I am basically scanning blocks and once in a while await this.connex.thor.block().get() returns null.

ehamery avatar May 05 '22 00:05 ehamery