Browse Source

PanicSanity is deprecated

pull/1244/head
Anton Kaliaev 6 years ago
parent
commit
bcf54b0aa3
No known key found for this signature in database GPG Key ID: 7B6881D965918214
2 changed files with 10 additions and 8 deletions
  1. +3
    -1
      blockchain/reactor.go
  2. +7
    -7
      blockchain/store.go

+ 3
- 1
blockchain/reactor.go View File

@ -72,18 +72,20 @@ func NewBlockchainReactor(state sm.State, blockExec *sm.BlockExecutor, store *Bl
fastSync bool) *BlockchainReactor { fastSync bool) *BlockchainReactor {
if state.LastBlockHeight != store.Height() { if state.LastBlockHeight != store.Height() {
cmn.PanicSanity(cmn.Fmt("state (%v) and store (%v) height mismatch", state.LastBlockHeight,
panic(fmt.Sprintf("state (%v) and store (%v) height mismatch", state.LastBlockHeight,
store.Height())) store.Height()))
} }
const cap = 1000 // must be bigger than peers count const cap = 1000 // must be bigger than peers count
requestsCh := make(chan BlockRequest, cap) requestsCh := make(chan BlockRequest, cap)
errorsCh := make(chan peerError, cap) // so we don't block in #Receive#pool.AddBlock errorsCh := make(chan peerError, cap) // so we don't block in #Receive#pool.AddBlock
pool := NewBlockPool( pool := NewBlockPool(
store.Height()+1, store.Height()+1,
requestsCh, requestsCh,
errorsCh, errorsCh,
) )
bcR := &BlockchainReactor{ bcR := &BlockchainReactor{
params: state.ConsensusParams, params: state.ConsensusParams,
initialState: state, initialState: state,


+ 7
- 7
blockchain/store.go View File

@ -76,7 +76,7 @@ func (bs *BlockStore) LoadBlock(height int64) *types.Block {
} }
blockMeta := wire.ReadBinary(&types.BlockMeta{}, r, 0, &n, &err).(*types.BlockMeta) blockMeta := wire.ReadBinary(&types.BlockMeta{}, r, 0, &n, &err).(*types.BlockMeta)
if err != nil { if err != nil {
cmn.PanicCrisis(cmn.Fmt("Error reading block meta: %v", err))
panic(fmt.Sprintf("Error reading block meta: %v", err))
} }
bytez := []byte{} bytez := []byte{}
for i := 0; i < blockMeta.BlockID.PartsHeader.Total; i++ { for i := 0; i < blockMeta.BlockID.PartsHeader.Total; i++ {
@ -85,7 +85,7 @@ func (bs *BlockStore) LoadBlock(height int64) *types.Block {
} }
block := wire.ReadBinary(&types.Block{}, bytes.NewReader(bytez), 0, &n, &err).(*types.Block) block := wire.ReadBinary(&types.Block{}, bytes.NewReader(bytez), 0, &n, &err).(*types.Block)
if err != nil { if err != nil {
cmn.PanicCrisis(cmn.Fmt("Error reading block: %v", err))
panic(fmt.Sprintf("Error reading block: %v", err))
} }
return block return block
} }
@ -102,7 +102,7 @@ func (bs *BlockStore) LoadBlockPart(height int64, index int) *types.Part {
} }
part := wire.ReadBinary(&types.Part{}, r, 0, &n, &err).(*types.Part) part := wire.ReadBinary(&types.Part{}, r, 0, &n, &err).(*types.Part)
if err != nil { if err != nil {
cmn.PanicCrisis(cmn.Fmt("Error reading block part: %v", err))
panic(fmt.Sprintf("Error reading block part: %v", err))
} }
return part return part
} }
@ -118,7 +118,7 @@ func (bs *BlockStore) LoadBlockMeta(height int64) *types.BlockMeta {
} }
blockMeta := wire.ReadBinary(&types.BlockMeta{}, r, 0, &n, &err).(*types.BlockMeta) blockMeta := wire.ReadBinary(&types.BlockMeta{}, r, 0, &n, &err).(*types.BlockMeta)
if err != nil { if err != nil {
cmn.PanicCrisis(cmn.Fmt("Error reading block meta: %v", err))
panic(fmt.Sprintf("Error reading block meta: %v", err))
} }
return blockMeta return blockMeta
} }
@ -136,7 +136,7 @@ func (bs *BlockStore) LoadBlockCommit(height int64) *types.Commit {
} }
commit := wire.ReadBinary(&types.Commit{}, r, 0, &n, &err).(*types.Commit) commit := wire.ReadBinary(&types.Commit{}, r, 0, &n, &err).(*types.Commit)
if err != nil { if err != nil {
cmn.PanicCrisis(cmn.Fmt("Error reading commit: %v", err))
panic(fmt.Sprintf("Error reading commit: %v", err))
} }
return commit return commit
} }
@ -153,7 +153,7 @@ func (bs *BlockStore) LoadSeenCommit(height int64) *types.Commit {
} }
commit := wire.ReadBinary(&types.Commit{}, r, 0, &n, &err).(*types.Commit) commit := wire.ReadBinary(&types.Commit{}, r, 0, &n, &err).(*types.Commit)
if err != nil { if err != nil {
cmn.PanicCrisis(cmn.Fmt("Error reading commit: %v", err))
panic(fmt.Sprintf("Error reading commit: %v", err))
} }
return commit return commit
} }
@ -262,7 +262,7 @@ func LoadBlockStoreStateJSON(db dbm.DB) BlockStoreStateJSON {
bsj := BlockStoreStateJSON{} bsj := BlockStoreStateJSON{}
err := json.Unmarshal(bytes, &bsj) err := json.Unmarshal(bytes, &bsj)
if err != nil { if err != nil {
cmn.PanicCrisis(cmn.Fmt("Could not unmarshal bytes: %X", bytes))
panic(fmt.Sprintf("Could not unmarshal bytes: %X", bytes))
} }
return bsj return bsj
} }

Loading…
Cancel
Save