mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-30 10:46:41 +00:00

* [NOD-1457] Pass DomainDBContext to all constructors, instead of passing a general dbContext * [NOD-1457] Add NewTx to DomainDBContext * [NOD-1457] Added comment
34 lines
999 B
Go
34 lines
999 B
Go
package database
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/domain/consensus/model"
|
|
"github.com/kaspanet/kaspad/infrastructure/db/dbaccess"
|
|
)
|
|
|
|
// DomainDBContext is a proxy over a dbaccess.DatabaseContext
|
|
type DomainDBContext struct {
|
|
dbContext *dbaccess.DatabaseContext
|
|
}
|
|
|
|
// FetchBlockRelation retrieves the BlockRelation for the given blockHash
|
|
func (ddc *DomainDBContext) FetchBlockRelation(blockHash *model.DomainHash) (*model.BlockRelations, error) {
|
|
// TODO: return dbaccess.FetchBlockRelations(ddc.dbContext, blockHash)
|
|
return nil, nil
|
|
}
|
|
|
|
// NewTx returns an instance of DomainTxContext with a new database transaction
|
|
func (ddc *DomainDBContext) NewTx() (*DomainTxContext, error) {
|
|
txContext, err := ddc.dbContext.NewTx()
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return NewDomainTxContext(txContext), nil
|
|
}
|
|
|
|
// NewDomainDBContext creates a new DomainDBContext
|
|
func NewDomainDBContext(dbContext *dbaccess.DatabaseContext) *DomainDBContext {
|
|
return &DomainDBContext{dbContext: dbContext}
|
|
}
|