mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-22 14:02:32 +00:00

* [NOD-1223] Delete unused files/packages. * [NOD-1223] Move signal and limits to the os package. * [NOD-1223] Put database and dbaccess into the db package. * [NOD-1223] Fold the logs package into the logger package. * [NOD-1223] Rename domainmessage to appmessage. * [NOD-1223] Rename to/from DomainMessage to AppMessage. * [NOD-1223] Move appmessage to the app packge. * [NOD-1223] Move protocol to the app packge. * [NOD-1223] Move the network package to the infrastructure packge. * [NOD-1223] Rename cmd to executables. * [NOD-1223] Fix go.doc in the logger package.
39 lines
735 B
Go
39 lines
735 B
Go
package dbaccess
|
|
|
|
import "github.com/kaspanet/kaspad/infrastructure/db/database"
|
|
|
|
func clearBucket(dbTx *TxContext, bucket *database.Bucket) error {
|
|
accessor, err := dbTx.accessor()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Collect all of the keys before deleting them. We do this
|
|
// as to not modify the cursor while we're still iterating
|
|
// over it.
|
|
keys := make([]*database.Key, 0)
|
|
cursor, err := accessor.Cursor(bucket)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer cursor.Close()
|
|
|
|
for cursor.Next() {
|
|
key, err := cursor.Key()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
keys = append(keys, key)
|
|
}
|
|
|
|
// Delete all of the keys
|
|
for _, key := range keys {
|
|
err := accessor.Delete(key)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|