Documentation ¶
Overview ¶
Package bdb implements an instance of the database package backed by BoltDB. The structure of the database is: - objectsByHashes (bucket) -- Inventory hash (32 bytes) -> Object data
- objectsByCounters (bucket) -- Getpubkey/Pubkey/Msg/Broadcast/Unknown (bucket) --- Counter value (uint64) -> Inventory hash (32 bytes)
- counterPositions (bucket) -- Getpubkey/Pubkey/Msg/Broadcast/Unknown -> uint64
- encryptedPubkeysByTag (bucket) -- Tag (32 bytes) -> Encrypted pubkey
- publicIdentityByAddress (bucket) -- Address (string starting with BM-) (bucket) --- nonceTrials -> uint64 --- extraBytes -> uint64 --- signingKey -> compressed public key (33 bytes) --- encryptionKey -> compressed public key (33 bytes) --- behavior -> uint32
- misc -- version -> uint8
Index ¶
- func OpenDB(args ...interface{}) (database.Db, error)
- type BoltDB
- func (db *BoltDB) ExistsObject(hash *wire.ShaHash) (bool, error)
- func (db *BoltDB) FetchIdentityByAddress(addr *bmutil.Address) (*identity.Public, error)
- func (db *BoltDB) FetchObjectByCounter(objType wire.ObjectType, counter uint64) (*wire.MsgObject, error)
- func (db *BoltDB) FetchObjectByHash(hash *wire.ShaHash) (*wire.MsgObject, error)
- func (db *BoltDB) FetchObjectsFromCounter(objType wire.ObjectType, counter uint64, count uint64) ([]database.ObjectWithCounter, uint64, error)
- func (db *BoltDB) FetchRandomInvHashes(count uint64) ([]*wire.InvVect, error)
- func (db *BoltDB) GetCounter(objType wire.ObjectType) (uint64, error)
- func (db *BoltDB) InsertObject(obj *wire.MsgObject) (uint64, error)
- func (db *BoltDB) RemoveEncryptedPubKey(tag *wire.ShaHash) error
- func (db *BoltDB) RemoveExpiredObjects() ([]*wire.ShaHash, error)
- func (db *BoltDB) RemoveObject(hash *wire.ShaHash) error
- func (db *BoltDB) RemoveObjectByCounter(objType wire.ObjectType, counter uint64) error
- func (db *BoltDB) RemovePublicIdentity(addr *bmutil.Address) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BoltDB ¶
BoltDB is an implementation of database.Database interface with BoltDB as a backend store.
func (*BoltDB) ExistsObject ¶
ExistsObject returns whether or not an object with the given inventory hash exists in the database.
func (*BoltDB) FetchIdentityByAddress ¶
FetchIdentityByAddress returns identity.Public stored in the form of a PubKey message in the pubkey database.
func (*BoltDB) FetchObjectByCounter ¶
func (db *BoltDB) FetchObjectByCounter(objType wire.ObjectType, counter uint64) (*wire.MsgObject, error)
FetchObjectByCounter returns the corresponding object based on the counter. Note that each object type has a different counter, with unknown objects being consolidated into one counter. Counters are meant for use as a convenience method for fetching new data from database since last check.
func (*BoltDB) FetchObjectByHash ¶
FetchObjectByHash returns an object from the database as a wire.MsgObject.
func (*BoltDB) FetchObjectsFromCounter ¶
func (db *BoltDB) FetchObjectsFromCounter(objType wire.ObjectType, counter uint64, count uint64) ([]database.ObjectWithCounter, uint64, error)
FetchObjectsFromCounter returns a slice of `count' objects which have a counter position starting from `counter'. It also returns the counter value of the last object, which could be useful for more queries to the function.
func (*BoltDB) FetchRandomInvHashes ¶
FetchRandomInvHashes returns the specified number of inventory hashes corresponding to random unexpired objects from the database. It does not guarantee that the number of returned inventory vectors would be `count'.
func (*BoltDB) GetCounter ¶
func (db *BoltDB) GetCounter(objType wire.ObjectType) (uint64, error)
GetCounter returns the highest value of counter that exists for objects of the given type.
func (*BoltDB) InsertObject ¶
InsertObject inserts the given object into the database and returns the counter position. If the object is a PubKey, it inserts it into a separate place where it isn't touched by RemoveObject or RemoveExpiredObjects and has to be removed using RemovePubKey.
func (*BoltDB) RemoveEncryptedPubKey ¶
RemoveEncryptedPubKey removes a v4 PubKey with the specified tag from the encrypted PubKey store. Note that it doesn't touch the general object store and won't remove the public key from there.
func (*BoltDB) RemoveExpiredObjects ¶
RemoveExpiredObjects prunes all objects in the main circulation store whose expiry time has passed (along with a margin of 3 hours). This does not touch the pubkeys stored in the public key collection.
func (*BoltDB) RemoveObject ¶
RemoveObject removes the object with the specified hash from the database. Does not remove PubKeys.
func (*BoltDB) RemoveObjectByCounter ¶
func (db *BoltDB) RemoveObjectByCounter(objType wire.ObjectType, counter uint64) error
RemoveObjectByCounter removes the object with the specified counter value from the database.
func (*BoltDB) RemovePublicIdentity ¶
RemovePublicIdentity removes the public identity corresponding the given address from the database. This includes any v2/v3/previously used v4 identities. Note that it doesn't touch the general object store and won't remove the public key object from there.