piotrnar / gocoin

Full bitcoin solution written in Go (golang)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HandleNetBlock does not ensure non-null Block input

l0k18 opened this issue · comments

commented

I'm not sure if it's specifically relevant to bitcoin nodes, but the code did trip a panic over a non-existing value in the .Block value of the parameter of this function while I have been working on a fork

func HandleNetBlock(newbl *network.BlockRcvd) {

It may not be relevant as there may have been some other reason for a block coming through from the connection goroutine from a foreign chain without this value filled in.

Sorry, I don't understand what is the problem.

commented

Well, I don't know exactly how it came to be that something arrived in this function with nil in the Block element of the structure, but I thought that something leading up to that must have failed to assign a value to it and ... well ... it just bombs out suddenly, no error handling nothing, in this case, it took me a few hours to actually find where it was happening.

I understand the issue you're raising is that when you pass a nil pointer to the function, it does not report an error, but causes panic instead - is that correct?

As a general rule, none of the functions in gocoin code check for nil pointer where a valid pointer is expected. This isn't going to change.

Also, I can only provide support and fix issues on the actual code that is on this github repo.
Please don't waste my time with "I changed your code, it crashes now and I don't know why".