RESOLVED: Seems this bug is still hanging around.....

Steve Sokolowski avatar
Steve Sokolowski
Archived posts: 4559
Joined: Aug 27, 2014

Re: RESOLVED: Seems this bug is still hanging around.....

by Steve Sokolowski · · Post #3697

GenTarkin wrote:Well, after digging around some more and experimenting, came up w/ a more advanced fix.
No issues w/ balance - load balance that I can see =)
But basically, now the message is still displayed but I appended (normal for multicoin pools) to it and functionally the network diff & current block hash properly update back to the old block its mining. So, the "found new block messages" shouldnt show anymore because of improperly displayed net diff.

Here's the code, if you search for "if (was_active)" in miner.c
Just add the parts of my code that are different, to miner.c then recompile bfgminer

Code:

                        if (was_active)
                        {
                                struct block_info * const t = calloc(sizeof(struct block_info), 1);
                                memcpy(t->prevblkhash, prevblkhash, sizeof(t->prevblkhash));
                                t->block_id = block_id;
                                t->block_seen_order = new_blocks++;
                                t->first_seen_time = time(NULL);
                                // Pool actively changed block
                                if (pool == current_pool())
                                        restart = true;
                                if (block_id == blkchain->currentblk->block_id)
                                {
                                        // Caught up, only announce if this pool is the one in use
                                        if (restart)
                                        {
                                                set_curblock(goal, t);
                                                set_blockdiff(goal, work);
                                                applog(LOG_NOTICE, "%s %d caught up to new block",
                                                       work->longpoll ? "Longpoll from pool" : "Pool",
                                                       pool->pool_no);
                                        }
                                }
                                else
                                {
                                        // Switched to a block we know, but not the latest... why?
                                        // This might detect pools trying to double-spend or 51%,
                                        // but let's not make any accusations until it's had time
                                        // in the real world.
                                        set_blockdiff(goal, work);
                                        set_curblock(goal, t);
                                        char hexstr[65];
                                        blkhashstr(hexstr, prevblkhash);
                                        applog(LOG_WARNING, "%s %d is issuing work for an old block: %s (Normal if multicoin pool)",
                                               work->longpoll ? "Longpoll from pool" : "Pool",
                                               pool->pool_no,
                                               hexstr);
                                }
                        }
                }
Can you submit this fix as a pull request to the official repo? That way, they should merge it and then the answer I can write on the documentation page is "upgrade to GenTarkin's version of bfgminer."