Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting last block fails #100

Open
silentlight opened this issue Oct 9, 2021 · 6 comments
Open

Getting last block fails #100

silentlight opened this issue Oct 9, 2021 · 6 comments

Comments

@silentlight
Copy link

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.

@qianbin
Copy link
Member

qianbin commented Oct 21, 2021

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

@ehamery
Copy link

ehamery commented May 3, 2022

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?

@qianbin
Copy link
Member

qianbin commented May 3, 2022

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.

@ehamery
Copy link

ehamery commented May 3, 2022

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.

@qianbin
Copy link
Member

qianbin commented May 3, 2022

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?

@ehamery
Copy link

ehamery commented May 5, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants