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

Blocklevel events are not generated in Golang #1171

Closed
malkani-kamal opened this issue Jan 17, 2024 · 1 comment
Closed

Blocklevel events are not generated in Golang #1171

malkani-kamal opened this issue Jan 17, 2024 · 1 comment

Comments

@malkani-kamal
Copy link

Hi
I was trying to use off_chain_data Repository and trying to listen block level events in Golang. Sorry to inform you that I am not able to receive blocklevel events at all. It is just showing block 0 always and not moving ahead. I have given the sample code. Please let me know if there is any problem with the code or any other setting to be performed at network level.
One more observation is if the code is written in nodejs than I am able to listen block level event but not in Golang.
Please provide the fix for the above mentioned problem.

Sample function
func startBlocklevelEventListening(ctx context.Context, network client.Network) {
blockEvents, blockErr := network.BlockEvents(ctx, client.WithStartBlock(1))
if blockErr != nil {
panic(fmt.Errorf("failed to start chaincode event listening: %w", blockErr))
}
fmt.Println("\n
** Start Block event listening")

go func() {
	for event := range blockEvents {
		hashBytes := event.GetHeader().GetDataHash()
		hashString := fmt.Sprintf("%x", hashBytes)
		blockNumber := event.GetHeader().GetNumber()
		fmt.Printf("\n<-- Block event received: \n   Received block number : %d \n   Received block hash - %s\n", blockNumber, hashString)
	}
}()

}

@bestbeforetoday
Copy link
Member

See this StackOverflow answer to the same question, demonstrating block eventing working with the Golang client application:

https://stackoverflow.com/a/77835368/3680198

@bestbeforetoday bestbeforetoday closed this as not planned Won't fix, can't repro, duplicate, stale May 31, 2024
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

2 participants