dao: adjust usages of Internal DB inconsistency
error
This commit is contained in:
parent
2972569a0a
commit
18c5f638b9
1 changed files with 10 additions and 3 deletions
|
@ -25,6 +25,9 @@ var (
|
||||||
// ErrHasConflicts is returned when transaction is in the list of conflicting
|
// ErrHasConflicts is returned when transaction is in the list of conflicting
|
||||||
// transactions which are already in dao.
|
// transactions which are already in dao.
|
||||||
ErrHasConflicts = errors.New("transaction has conflicts")
|
ErrHasConflicts = errors.New("transaction has conflicts")
|
||||||
|
// ErrInternalDBInconsistency is returned when the format of retrieved DAO
|
||||||
|
// record is unexpected.
|
||||||
|
ErrInternalDBInconsistency = errors.New("internal DB inconsistency")
|
||||||
)
|
)
|
||||||
|
|
||||||
// Simple is memCached wrapper around DB, simple DAO implementation.
|
// Simple is memCached wrapper around DB, simple DAO implementation.
|
||||||
|
@ -252,7 +255,7 @@ func (dao *Simple) GetAppExecResults(hash util.Uint256, trig trigger.Type) ([]st
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
r := io.NewBinReaderFromBuf(bs)
|
r := io.NewBinReaderFromBuf(bs)
|
||||||
switch r.ReadB() {
|
switch pref := r.ReadB(); pref {
|
||||||
case storage.ExecBlock:
|
case storage.ExecBlock:
|
||||||
_, err = block.NewTrimmedFromReader(dao.Version.StateRootInHeader, r)
|
_, err = block.NewTrimmedFromReader(dao.Version.StateRootInHeader, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -265,6 +268,8 @@ func (dao *Simple) GetAppExecResults(hash util.Uint256, trig trigger.Type) ([]st
|
||||||
_ = r.ReadU32LE()
|
_ = r.ReadU32LE()
|
||||||
tx := &transaction.Transaction{}
|
tx := &transaction.Transaction{}
|
||||||
tx.DecodeBinary(r)
|
tx.DecodeBinary(r)
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("%w: unexpected executable prefix %d", ErrInternalDBInconsistency, pref)
|
||||||
}
|
}
|
||||||
if r.Err != nil {
|
if r.Err != nil {
|
||||||
return nil, r.Err
|
return nil, r.Err
|
||||||
|
@ -358,7 +363,8 @@ func (dao *Simple) getBlock(key []byte) (*block.Block, error) {
|
||||||
|
|
||||||
r := io.NewBinReaderFromBuf(b)
|
r := io.NewBinReaderFromBuf(b)
|
||||||
if r.ReadB() != storage.ExecBlock {
|
if r.ReadB() != storage.ExecBlock {
|
||||||
return nil, errors.New("internal DB inconsistency")
|
// It may be a transaction.
|
||||||
|
return nil, storage.ErrKeyNotFound
|
||||||
}
|
}
|
||||||
block, err := block.NewTrimmedFromReader(dao.Version.StateRootInHeader, r)
|
block, err := block.NewTrimmedFromReader(dao.Version.StateRootInHeader, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -522,7 +528,8 @@ func (dao *Simple) GetTransaction(hash util.Uint256) (*transaction.Transaction,
|
||||||
return nil, 0, errors.New("bad transaction bytes")
|
return nil, 0, errors.New("bad transaction bytes")
|
||||||
}
|
}
|
||||||
if b[0] != storage.ExecTransaction {
|
if b[0] != storage.ExecTransaction {
|
||||||
return nil, 0, errors.New("internal DB inconsistency")
|
// It may be a block.
|
||||||
|
return nil, 0, storage.ErrKeyNotFound
|
||||||
}
|
}
|
||||||
if b[5] == transaction.DummyVersion {
|
if b[5] == transaction.DummyVersion {
|
||||||
return nil, 0, storage.ErrKeyNotFound
|
return nil, 0, storage.ErrKeyNotFound
|
||||||
|
|
Loading…
Reference in a new issue