From 17000f70224b25c422cf32fcd157063f0c33f440 Mon Sep 17 00:00:00 2001 From: qiwei9743 Date: Wed, 26 Sep 2018 16:25:22 +0800 Subject: [PATCH] fix&workaround bugs. Rpc @getblocktemplet and @submitblock are working now. --- logic/lchain/lchain.go | 1 + rpc/mining.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/logic/lchain/lchain.go b/logic/lchain/lchain.go index 2b94010b..5260d353 100644 --- a/logic/lchain/lchain.go +++ b/logic/lchain/lchain.go @@ -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() } diff --git a/rpc/mining.go b/rpc/mining.go index b545b02b..be063229 100644 --- a/rpc/mining.go +++ b/rpc/mining.go @@ -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) @@ -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 { @@ -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 }