mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-07 13:55:17 +00:00
dep: update tm-db to 0.4.0 (#4289)
* dep: update tm-db to 0.4.0 - update 0.4.0 as it is a breaking change and cannot be handled by depndabot Signed-off-by: Marko Baricevic <marbar3778@yahoo.com> * more work towards error handling * error and emtpy bytes handling * work on tests * add changelog entry, change some error handling * address some pr comments * panic in a few more places * move error higher up * redo some error handling * fix some bz == nil to len(bz) == 0 * change statebytes
This commit is contained in:
@@ -72,12 +72,15 @@ func LoadState(db dbm.DB) State {
|
||||
}
|
||||
|
||||
func loadState(db dbm.DB, key []byte) (state State) {
|
||||
buf := db.Get(key)
|
||||
buf, err := db.Get(key)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if len(buf) == 0 {
|
||||
return state
|
||||
}
|
||||
|
||||
err := cdc.UnmarshalBinaryBare(buf, &state)
|
||||
err = cdc.UnmarshalBinaryBare(buf, &state)
|
||||
if err != nil {
|
||||
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
|
||||
tmos.Exit(fmt.Sprintf(`LoadState: Data has been corrupted or its spec has changed:
|
||||
@@ -147,13 +150,16 @@ func (arz *ABCIResponses) ResultsHash() []byte {
|
||||
// This is useful for recovering from crashes where we called app.Commit and before we called
|
||||
// s.Save(). It can also be used to produce Merkle proofs of the result of txs.
|
||||
func LoadABCIResponses(db dbm.DB, height int64) (*ABCIResponses, error) {
|
||||
buf := db.Get(calcABCIResponsesKey(height))
|
||||
buf, err := db.Get(calcABCIResponsesKey(height))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(buf) == 0 {
|
||||
return nil, ErrNoABCIResponsesForHeight{height}
|
||||
}
|
||||
|
||||
abciResponses := new(ABCIResponses)
|
||||
err := cdc.UnmarshalBinaryBare(buf, abciResponses)
|
||||
err = cdc.UnmarshalBinaryBare(buf, abciResponses)
|
||||
if err != nil {
|
||||
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
|
||||
tmos.Exit(fmt.Sprintf(`LoadABCIResponses: Data has been corrupted or its spec has
|
||||
@@ -219,13 +225,16 @@ func lastStoredHeightFor(height, lastHeightChanged int64) int64 {
|
||||
|
||||
// CONTRACT: Returned ValidatorsInfo can be mutated.
|
||||
func loadValidatorsInfo(db dbm.DB, height int64) *ValidatorsInfo {
|
||||
buf := db.Get(calcValidatorsKey(height))
|
||||
buf, err := db.Get(calcValidatorsKey(height))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if len(buf) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
v := new(ValidatorsInfo)
|
||||
err := cdc.UnmarshalBinaryBare(buf, v)
|
||||
err = cdc.UnmarshalBinaryBare(buf, v)
|
||||
if err != nil {
|
||||
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
|
||||
tmos.Exit(fmt.Sprintf(`LoadValidators: Data has been corrupted or its spec has changed:
|
||||
@@ -296,13 +305,16 @@ func LoadConsensusParams(db dbm.DB, height int64) (types.ConsensusParams, error)
|
||||
}
|
||||
|
||||
func loadConsensusParamsInfo(db dbm.DB, height int64) *ConsensusParamsInfo {
|
||||
buf := db.Get(calcConsensusParamsKey(height))
|
||||
buf, err := db.Get(calcConsensusParamsKey(height))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if len(buf) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
paramsInfo := new(ConsensusParamsInfo)
|
||||
err := cdc.UnmarshalBinaryBare(buf, paramsInfo)
|
||||
err = cdc.UnmarshalBinaryBare(buf, paramsInfo)
|
||||
if err != nil {
|
||||
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
|
||||
tmos.Exit(fmt.Sprintf(`LoadConsensusParams: Data has been corrupted or its spec has changed:
|
||||
|
||||
@@ -62,13 +62,16 @@ func (txi *TxIndex) Get(hash []byte) (*types.TxResult, error) {
|
||||
return nil, txindex.ErrorEmptyHash
|
||||
}
|
||||
|
||||
rawBytes := txi.store.Get(hash)
|
||||
rawBytes, err := txi.store.Get(hash)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if rawBytes == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
txResult := new(types.TxResult)
|
||||
err := cdc.UnmarshalBinaryBare(rawBytes, &txResult)
|
||||
err = cdc.UnmarshalBinaryBare(rawBytes, &txResult)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error reading TxResult: %v", err)
|
||||
}
|
||||
@@ -393,7 +396,10 @@ func (txi *TxIndex) match(
|
||||
|
||||
switch {
|
||||
case c.Op == query.OpEqual:
|
||||
it := dbm.IteratePrefix(txi.store, startKeyBz)
|
||||
it, err := dbm.IteratePrefix(txi.store, startKeyBz)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer it.Close()
|
||||
|
||||
for ; it.Valid(); it.Next() {
|
||||
@@ -404,7 +410,10 @@ func (txi *TxIndex) match(
|
||||
// XXX: startKey does not apply here.
|
||||
// For example, if startKey = "account.owner/an/" and search query = "account.owner CONTAINS an"
|
||||
// we can't iterate with prefix "account.owner/an/" because we might miss keys like "account.owner/Ulan/"
|
||||
it := dbm.IteratePrefix(txi.store, startKey(c.CompositeKey))
|
||||
it, err := dbm.IteratePrefix(txi.store, startKey(c.CompositeKey))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer it.Close()
|
||||
|
||||
for ; it.Valid(); it.Next() {
|
||||
@@ -463,7 +472,10 @@ func (txi *TxIndex) matchRange(
|
||||
lowerBound := r.lowerBoundValue()
|
||||
upperBound := r.upperBoundValue()
|
||||
|
||||
it := dbm.IteratePrefix(txi.store, startKey)
|
||||
it, err := dbm.IteratePrefix(txi.store, startKey)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer it.Close()
|
||||
|
||||
LOOP:
|
||||
|
||||
Reference in New Issue
Block a user