diff --git a/blockmanager.go b/blockmanager.go index 1d174f9e..36dd099e 100644 --- a/blockmanager.go +++ b/blockmanager.go @@ -113,6 +113,7 @@ type processBlockResponse struct { // way to call ProcessBlock on the internal block chain instance. type processBlockMsg struct { block *btcutil.Block + flags btcchain.BehaviorFlags reply chan processBlockResponse } @@ -559,13 +560,13 @@ func (b *blockManager) handleBlockMsg(bmsg *blockMsg) { // since it is needed to verify the next round of headers links // properly. isCheckpointBlock := false - fastAdd := false + behaviorFlags := btcchain.BFNone if b.headersFirstMode { firstNodeEl := b.headerList.Front() if firstNodeEl != nil { firstNode := firstNodeEl.Value.(*headerNode) if blockSha.IsEqual(firstNode.sha) { - fastAdd = true + behaviorFlags |= btcchain.BFFastAdd if firstNode.sha.IsEqual(b.nextCheckpoint.Hash) { isCheckpointBlock = true } else { @@ -583,7 +584,7 @@ func (b *blockManager) handleBlockMsg(bmsg *blockMsg) { // Process the block to include validation, best chain selection, orphan // handling, etc. - isOrphan, err := b.blockChain.ProcessBlock(bmsg.block, fastAdd) + isOrphan, err := b.blockChain.ProcessBlock(bmsg.block, behaviorFlags) if err != nil { // When the error is a rule error, it means the block was simply // rejected as opposed to something actually going wrong, so log @@ -1029,7 +1030,7 @@ out: case processBlockMsg: isOrphan, err := b.blockChain.ProcessBlock( - msg.block, false) + msg.block, msg.flags) if err != nil { msg.reply <- processBlockResponse{ isOrphan: false, @@ -1277,9 +1278,9 @@ func (b *blockManager) CalcNextRequiredDifficulty(timestamp time.Time) (uint32, // ProcessBlock makes use of ProcessBlock on an internal instance of a block // chain. It is funneled through the block manager since btcchain is not safe // for concurrent access. -func (b *blockManager) ProcessBlock(block *btcutil.Block) (bool, error) { +func (b *blockManager) ProcessBlock(block *btcutil.Block, flags btcchain.BehaviorFlags) (bool, error) { reply := make(chan processBlockResponse, 1) - b.msgChan <- processBlockMsg{block: block, reply: reply} + b.msgChan <- processBlockMsg{block: block, flags: flags, reply: reply} response := <-reply return response.isOrphan, response.err } diff --git a/cpuminer.go b/cpuminer.go index 44da64c6..2b20f7eb 100644 --- a/cpuminer.go +++ b/cpuminer.go @@ -127,7 +127,7 @@ func (m *CPUMiner) submitBlock(block *btcutil.Block) bool { // Process this block using the same rules as blocks coming from other // nodes. This will in turn relay it to the network like normal. - isOrphan, err := m.server.blockManager.ProcessBlock(block) + isOrphan, err := m.server.blockManager.ProcessBlock(block, btcchain.BFNone) if err != nil { // Anything other than a rule violation is an unexpected error, // so log that error as an internal error. diff --git a/rpcserver.go b/rpcserver.go index 745266e7..e7372118 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -1750,7 +1750,7 @@ func handleGetWorkSubmission(s *rpcServer, hexData string) (interface{}, error) // Process this block using the same rules as blocks coming from other // nodes. This will in turn relay it to the network like normal. - isOrphan, err := s.server.blockManager.ProcessBlock(block) + isOrphan, err := s.server.blockManager.ProcessBlock(block, btcchain.BFNone) if err != nil || isOrphan { // Anything other than a rule violation is an unexpected error, // so return that error as an internal error. @@ -1988,7 +1988,7 @@ func handleSubmitBlock(s *rpcServer, cmd btcjson.Cmd) (interface{}, error) { return nil, err } - _, err = s.server.blockManager.ProcessBlock(block) + _, err = s.server.blockManager.ProcessBlock(block, btcchain.BFNone) if err != nil { return fmt.Sprintf("rejected: %s", err.Error()), nil }