mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
fix panic with nil value
This commit is contained in:
parent
2306ceafb2
commit
c688f4b24c
7 changed files with 13 additions and 14 deletions
|
|
@ -147,7 +147,7 @@ func lesTopic(genesisHash common.Hash, protocolVersion uint) discv5.Topic {
|
|||
case lpv2:
|
||||
name = "LES2"
|
||||
default:
|
||||
panic(nil)
|
||||
panic("lesTopic")
|
||||
}
|
||||
return discv5.Topic(name + "@" + common.Bytes2Hex(genesisHash.Bytes()[0:8]))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ func (r *TrieRequest) GetCost(peer *peer) uint64 {
|
|||
case lpv2:
|
||||
return peer.GetRequestCost(GetProofsV2Msg, 1)
|
||||
default:
|
||||
panic(nil)
|
||||
panic("TrieRequest GetCost")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -356,7 +356,7 @@ func (r *ChtRequest) GetCost(peer *peer) uint64 {
|
|||
case lpv2:
|
||||
return peer.GetRequestCost(GetHelperTrieProofsMsg, 1)
|
||||
default:
|
||||
panic(nil)
|
||||
panic("ChtRequest GetCost")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -279,7 +279,7 @@ func (p *peer) RequestProofs(reqID, cost uint64, reqs []ProofReq) error {
|
|||
case lpv2:
|
||||
return sendRequest(p.rw, GetProofsV2Msg, reqID, cost, reqs)
|
||||
default:
|
||||
panic(nil)
|
||||
panic("peer RequestProofs")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -301,7 +301,7 @@ func (p *peer) RequestHelperTrieProofs(reqID, cost uint64, reqs []HelperTrieReq)
|
|||
case lpv2:
|
||||
return sendRequest(p.rw, GetHelperTrieProofsMsg, reqID, cost, reqs)
|
||||
default:
|
||||
panic(nil)
|
||||
panic("peer RequestHelperTrieProofs")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -320,7 +320,7 @@ func (p *peer) SendTxs(reqID, cost uint64, txs types.Transactions) error {
|
|||
case lpv2:
|
||||
return sendRequest(p.rw, SendTxV2Msg, reqID, cost, txs)
|
||||
default:
|
||||
panic(nil)
|
||||
panic("peer SendTxs")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ func (n *wrsNode) insert(item wrsItem, weight int64) int {
|
|||
for n.items[branch] != nil && (n.level == 0 || n.items[branch].(*wrsNode).itemCnt == n.items[branch].(*wrsNode).maxItems) {
|
||||
branch++
|
||||
if branch == wrsBranches {
|
||||
panic(nil)
|
||||
panic("wrsNode insert: branch == wrsBranches")
|
||||
}
|
||||
}
|
||||
n.itemCnt++
|
||||
|
|
@ -169,5 +169,5 @@ func (n *wrsNode) choose(val int64) (wrsItem, int64) {
|
|||
val -= w
|
||||
}
|
||||
}
|
||||
panic(nil)
|
||||
panic("wrsNode choose")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@ func (r *sentReq) tryRequest() {
|
|||
s, ok := r.sentTo[p]
|
||||
r.lock.RUnlock()
|
||||
if !ok {
|
||||
panic(nil)
|
||||
panic("sentReq tryRequest: !ok")
|
||||
}
|
||||
|
||||
defer func() {
|
||||
|
|
|
|||
|
|
@ -22,11 +22,10 @@ import (
|
|||
"math/big"
|
||||
"time"
|
||||
|
||||
"github.com/XinFinOrg/XDPoSChain/core/rawdb"
|
||||
|
||||
"github.com/XinFinOrg/XDPoSChain/common"
|
||||
"github.com/XinFinOrg/XDPoSChain/common/bitutil"
|
||||
"github.com/XinFinOrg/XDPoSChain/core"
|
||||
"github.com/XinFinOrg/XDPoSChain/core/rawdb"
|
||||
"github.com/XinFinOrg/XDPoSChain/core/types"
|
||||
"github.com/XinFinOrg/XDPoSChain/ethdb"
|
||||
"github.com/XinFinOrg/XDPoSChain/log"
|
||||
|
|
@ -165,7 +164,7 @@ func (c *ChtIndexerBackend) Process(header *types.Header) {
|
|||
|
||||
td := core.GetTd(c.diskdb, hash, num)
|
||||
if td == nil {
|
||||
panic(nil)
|
||||
panic("ChtIndexerBackend Process: td == nil")
|
||||
}
|
||||
var encNumber [8]byte
|
||||
binary.BigEndian.PutUint64(encNumber[:], num)
|
||||
|
|
|
|||
|
|
@ -441,7 +441,7 @@ func (s *ticketStore) removeTicketRef(ref ticketRef) {
|
|||
}
|
||||
}
|
||||
if idx == -1 {
|
||||
panic(nil)
|
||||
panic("ticketStore removeTicketRef: idx == -1")
|
||||
}
|
||||
list = append(list[:idx], list[idx+1:]...)
|
||||
if len(list) != 0 {
|
||||
|
|
@ -802,7 +802,7 @@ func (r *topicRadius) chooseLookupBucket(a, b int) int {
|
|||
rnd--
|
||||
}
|
||||
}
|
||||
panic(nil) // should never happen
|
||||
panic("topicRadius chooseLookupBucket") // should never happen
|
||||
}
|
||||
|
||||
func (r *topicRadius) needMoreLookups(a, b int, maxValue float64) bool {
|
||||
|
|
|
|||
Loading…
Reference in a new issue