Skip to content

Commit

Permalink
fix&workaround bugs. Rpc @getblocktemplet and @submitblock are workin…
Browse files Browse the repository at this point in the history
…g now.
  • Loading branch information
qiwei9743 committed Sep 26, 2018
1 parent 865a89b commit 17000f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions logic/lchain/lchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
// IsInitialBlockDownload Check whether we are doing an initial block download
// (synchronizing from disk or network)
func IsInitialBlockDownload() bool {
return false
return persist.Reindex || !chain.GetInstance().IsAlmostSynced()
}

Expand Down
6 changes: 6 additions & 0 deletions rpc/mining.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ func blockTemplateResult(bt *mining.BlockTemplate, s *set.Set, maxVersionVb uint
setTxIndex[txID] = i
i++

if tx.IsCoinBase() {
continue
}

entry := btcjson.GetBlockTemplateResultTx{}

dataBuf := bytes.NewBuffer(nil)
Expand Down Expand Up @@ -452,6 +456,7 @@ func BIP22ValidationResult(err error) (interface{}, error) {
func handleSubmitBlock(s *Server, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {
c := cmd.(*btcjson.SubmitBlockCmd)

log.Debug("handle submitblock request: %#v", c)
// Unserialize the submitted block.
hexStr := c.HexBlock
if len(hexStr)%2 != 0 {
Expand Down Expand Up @@ -493,6 +498,7 @@ func handleSubmitBlock(s *Server, cmd interface{}, closeChan <-chan struct{}) (i
// nodes. This will in turn relay it to the network like normal.
_, err = service.ProcessBlock(bk)
if err != nil {
log.Error("rejected: %s, blk=%+v txs=%+v", err.Error(), bk, bk.Txs)
return fmt.Sprintf("rejected: %s", err.Error()), nil
}

Expand Down

0 comments on commit 17000f7

Please sign in to comment.