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.
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
package dbaccess
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/infrastructure/db/database"
|
|
"github.com/kaspanet/kaspad/util/daghash"
|
|
)
|
|
|
|
var multisetBucket = database.MakeBucket([]byte("multiset"))
|
|
|
|
func multisetKey(hash *daghash.Hash) *database.Key {
|
|
return multisetBucket.Key(hash[:])
|
|
}
|
|
|
|
// MultisetCursor opens a cursor over all the
|
|
// multiset entries.
|
|
func MultisetCursor(context Context) (database.Cursor, error) {
|
|
accessor, err := context.accessor()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return accessor.Cursor(multisetBucket)
|
|
}
|
|
|
|
// StoreMultiset stores the multiset of a block by its hash.
|
|
func StoreMultiset(context Context, blockHash *daghash.Hash, multiset []byte) error {
|
|
accessor, err := context.accessor()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
key := multisetKey(blockHash)
|
|
return accessor.Put(key, multiset)
|
|
}
|
|
|
|
// HasMultiset returns whether the multiset of
|
|
// the given block exists in the database.
|
|
func HasMultiset(context Context, blockHash *daghash.Hash) (bool, error) {
|
|
accessor, err := context.accessor()
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
key := multisetKey(blockHash)
|
|
return accessor.Has(key)
|
|
}
|