case class BlockHeaderDAO()(implicit ec: ExecutionContext, appConfig: ChainAppConfig) extends CRUD[BlockHeaderDb, DoubleSha256DigestBE] with SlickUtil[BlockHeaderDb, DoubleSha256DigestBE] with Product with Serializable
This class is responsible for all database access related to org.bitcoins.core.protocol.blockchain.BlockHeaders in our chain project
- Alphabetic
- By Inheritance
- BlockHeaderDAO
- Serializable
- Product
- Equals
- SlickUtil
- SlickUtilAction
- CRUD
- CRUDAction
- JdbcProfileComponent
- Logging
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new BlockHeaderDAO()(implicit ec: ExecutionContext, appConfig: ChainAppConfig)
Type Members
- class BlockHeaderTable extends slick.jdbc.JdbcProfile.API.Table[BlockHeaderDb]
A table that stores block headers related to a blockchain
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- implicit val appConfig: ChainAppConfig
- Definition Classes
- BlockHeaderDAO → CRUD → CRUDAction → JdbcProfileComponent
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def bestHeight: Future[Int]
Returns the block height of the block with the most work from our database
- def chainTipsByHeight: Future[Vector[BlockHeaderDb]]
Returns the chainTips in our database calculated by max height, not work.
Returns the chainTips in our database calculated by max height, not work. This should only be used if the chain work has not been calculated
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def count(): Future[Int]
- Definition Classes
- CRUD
- def countAction: slick.jdbc.JdbcProfile.API.DBIOAction[Int, slick.jdbc.JdbcProfile.API.NoStream, Read]
- Definition Classes
- CRUDAction
- def create(t: BlockHeaderDb): Future[BlockHeaderDb]
- Definition Classes
- CRUD
- def createAction(t: BlockHeaderDb): slick.jdbc.JdbcProfile.API.DBIOAction[BlockHeaderDb, slick.jdbc.JdbcProfile.API.NoStream, Write]
- Definition Classes
- CRUDAction
- def createAll(headers: Vector[BlockHeaderDb]): Future[Vector[BlockHeaderDb]]
Creates all of the given BlockHeaderDb in the database
Creates all of the given BlockHeaderDb in the database
- Definition Classes
- BlockHeaderDAO → CRUD
- def createAllAction(ts: Vector[BlockHeaderDb]): slick.jdbc.JdbcProfile.API.DBIOAction[Vector[BlockHeaderDb], slick.jdbc.JdbcProfile.API.NoStream, Write]
- Definition Classes
- SlickUtilAction
- def createAllNoAutoInc(ts: Vector[BlockHeaderDb], database: SafeDatabase)(implicit ec: ExecutionContext): Future[Vector[BlockHeaderDb]]
- Definition Classes
- SlickUtil
- lazy val database: slick.jdbc.JdbcProfile.API.Database
- Definition Classes
- JdbcProfileComponent
- lazy val dbConfig: DatabaseConfig[JdbcProfile]
- Definition Classes
- JdbcProfileComponent
- def debug(mkr: Marker, msg: => Any, t: => Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def debug(msg: => Any, t: => Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def debug(msg: => Any): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def delete(t: BlockHeaderDb): Future[Int]
- Definition Classes
- CRUD
- def deleteAction(t: BlockHeaderDb): slick.jdbc.JdbcProfile.API.DBIOAction[Int, slick.jdbc.JdbcProfile.API.NoStream, Write]
- Definition Classes
- CRUDAction
- def deleteAll(): Future[Int]
- Definition Classes
- CRUD
- def deleteAll(ts: Vector[BlockHeaderDb]): Future[Int]
- Definition Classes
- CRUD
- def deleteAllAction(): slick.jdbc.JdbcProfile.API.DBIOAction[Int, slick.jdbc.JdbcProfile.API.NoStream, Write with Transactional]
- Definition Classes
- CRUDAction
- def deleteAllAction(ts: Vector[BlockHeaderDb]): slick.jdbc.JdbcProfile.API.DBIOAction[Int, slick.jdbc.JdbcProfile.API.NoStream, Write]
- Definition Classes
- CRUDAction
- implicit val ec: ExecutionContext
- Definition Classes
- CRUD → CRUDAction
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def error(mkr: Marker, msg: => Any, t: => Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def error(msg: => Any, t: => Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def error(msg: => Any): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def find(f: (BlockHeaderDb) => Boolean)(implicit ec: ExecutionContext): Future[Option[BlockHeaderDb]]
Finds a block header that satisfies the given predicate, else returns None
- def find(t: BlockHeaderDb): slick.jdbc.JdbcProfile.API.Query[slick.jdbc.JdbcProfile.API.Table[BlockHeaderDb], BlockHeaderDb, Seq]
- Attributes
- protected
- Definition Classes
- CRUDAction
- def findAll(ts: Vector[BlockHeaderDb]): slick.jdbc.JdbcProfile.API.Query[BlockHeaderTable, BlockHeaderDb, Seq]
- Attributes
- protected
- Definition Classes
- BlockHeaderDAO → CRUDAction
- def findAll(): Future[Vector[BlockHeaderDb]]
- Definition Classes
- CRUD
- def findAllAction(): slick.jdbc.JdbcProfile.API.DBIOAction[Vector[BlockHeaderDb], slick.jdbc.JdbcProfile.API.NoStream, Read]
- Definition Classes
- CRUDAction
- def findByHash(hash: DoubleSha256DigestBE): Future[Option[BlockHeaderDb]]
- def findByHashes(hashes: Vector[DoubleSha256DigestBE]): Future[Vector[Option[BlockHeaderDb]]]
Finds the block headers associated with the hashes.
Finds the block headers associated with the hashes. Returns None if we could not find a particular hash in the database
- def findByPrimaryKey(id: DoubleSha256DigestBE): slick.jdbc.JdbcProfile.API.Query[slick.jdbc.JdbcProfile.API.Table[BlockHeaderDb], BlockHeaderDb, Seq]
- Attributes
- protected
- Definition Classes
- CRUDAction
- def findByPrimaryKeyAction(id: DoubleSha256DigestBE): slick.jdbc.JdbcProfile.API.DBIOAction[Option[BlockHeaderDb], slick.jdbc.JdbcProfile.API.NoStream, Read]
- Definition Classes
- CRUDAction
- def findByPrimaryKeys(hashes: Vector[DoubleSha256DigestBE]): slick.jdbc.JdbcProfile.API.Query[BlockHeaderTable, BlockHeaderDb, Seq]
- Definition Classes
- BlockHeaderDAO → CRUDAction
- def findByPrimaryKeysAction(ids: Vector[DoubleSha256DigestBE]): slick.jdbc.JdbcProfile.API.DBIOAction[Vector[BlockHeaderDb], slick.jdbc.JdbcProfile.API.NoStream, Read]
- Definition Classes
- CRUDAction
- def findClosestBeforeTime(time: UInt32): Future[Option[BlockHeaderDb]]
- def findClosestToTime(time: UInt32): Future[BlockHeaderDb]
- def getAncestorAtHeight(child: BlockHeaderDb, height: Int): Future[Option[BlockHeaderDb]]
Retrieves the ancestor for the given block header at the given height
- def getAtChainWork(work: BigInt): Future[Vector[BlockHeaderDb]]
Retrieves a BlockHeaderDb with the given chain work
- def getAtChainWorkQuery(work: BigInt): slick.jdbc.JdbcProfile.StreamingProfileAction[Seq[BlockHeaderDb], BlockHeaderDb, Read]
- def getAtHeight(height: Int): Future[Vector[BlockHeaderDb]]
Retrieves a BlockHeaderDb at the given height
- def getAtHeightQuery(height: Int): slick.jdbc.JdbcProfile.StreamingProfileAction[Seq[BlockHeaderDb], BlockHeaderDb, Read]
- def getBestChainTips: Future[Vector[BlockHeaderDb]]
Returns the block header with the most accumulated work
- def getBetweenHeightAndHash(startHeight: Int, stopHash: DoubleSha256DigestBE): Future[Vector[BlockHeaderDb]]
Gets Block Headers between (inclusive) start height and stop hash, could be out of order
- def getBetweenHeights(from: Int, to: Int): Future[Vector[BlockHeaderDb]]
Gets Block Headers between (inclusive) from and to, could be out of order
- def getBetweenHeightsQuery(from: Int, to: Int): slick.jdbc.JdbcProfile.StreamingProfileAction[Seq[BlockHeaderDb], BlockHeaderDb, Read]
- def getBlockchainFrom(header: BlockHeaderDb)(implicit ec: ExecutionContext): Future[Option[Blockchain]]
Retrieves a blockchain with the best tip being the given header
- def getBlockchains()(implicit ec: ExecutionContext): Future[Vector[Blockchain]]
Returns competing blockchains that are contained in our BlockHeaderDAO Each chain returns the last difficutly interval block headers as defined by the network we are on.
Returns competing blockchains that are contained in our BlockHeaderDAO Each chain returns the last difficutly interval block headers as defined by the network we are on. For instance, on bitcoin mainnet this will be 2016 block headers. If no competing tips are found, we only return one Blockchain]], else we return n chains for the number of competing tips we have
- See also
- def getBlockchainsBetweenHeights(from: Int, to: Int)(implicit ec: ExecutionContext): Future[Vector[Blockchain]]
Retrieves a blockchain with the best tip being the given header
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def getForkedChainTips: Future[Vector[BlockHeaderDb]]
Retrieves all possible chainTips from the database.
Retrieves all possible chainTips from the database. Note this does NOT retrieve the BEST chain tips. If you need those please call getBestChainTips. This method will search backwards appConfig.chain.difficultyChangeInterval blocks looking for all forks that we have in our chainstate.
We will then return all conflicting headers.
Note: This method does NOT try and remove headers that are in the best chain. This means half the returned headers from this method will be in the best chain. To figure out which headers are in the best chain, you will need to walk backwards from getBestChainTips figuring out which headers are a part of the best chain.
- def getFullBlockchainFrom(header: BlockHeaderDb)(implicit ec: ExecutionContext): Future[Blockchain]
Retrieves a full blockchain with the best tip being the given header
- def getLowestNoWorkHeight: Future[Int]
- def getNAncestors(childHash: DoubleSha256DigestBE, n: Int): Future[Vector[BlockHeaderDb]]
Gets ancestor block headers starting with the given block hash (inclusive) These headers are guaranteed to be in order and a valid chain.
- def info(mkr: Marker, msg: => Any, t: => Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def info(msg: => Any, t: => Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def info(msg: => Any): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def isDebugEnabled: Boolean
- Attributes
- protected
- Definition Classes
- Logging
- def isErrorEnabled: Boolean
- Attributes
- protected
- Definition Classes
- Logging
- def isInfoEnabled: Boolean
- Attributes
- protected
- Definition Classes
- Logging
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isTraceEnabled: Boolean
- Attributes
- protected
- Definition Classes
- Logging
- def isWarnEnabled: Boolean
- Attributes
- protected
- Definition Classes
- Logging
- def logger: Logger
- Attributes
- protected
- Definition Classes
- Logging
- def loggerName: String
- Attributes
- protected
- Definition Classes
- Logging
- def maxHeight: Future[Int]
Returns the maximum block height from our database
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- lazy val numThreads: Int
- Definition Classes
- JdbcProfileComponent
- def productElementNames: Iterator[String]
- Definition Classes
- Product
- lazy val profile: JdbcProfile
- Definition Classes
- JdbcProfileComponent
- def read(id: DoubleSha256DigestBE): Future[Option[BlockHeaderDb]]
- Definition Classes
- CRUD
- def safeDatabase: SafeDatabase
- Definition Classes
- CRUD
- val schemaName: Option[String]
- Definition Classes
- CRUD
- def startHikariLogger(interval: Duration): HikariLogging
- Attributes
- protected
- Definition Classes
- JdbcProfileComponent
- def stopHikariLogger(): Unit
- Attributes
- protected
- Definition Classes
- JdbcProfileComponent
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- val table: TableQuery[BlockHeaderTable]
- Definition Classes
- BlockHeaderDAO → CRUDAction
- implicit def tableQuerySafeSubtypeCast[SpecificT <: AbstractTable[_], SomeT <: SpecificT](tableQuery: slick.jdbc.JdbcProfile.API.TableQuery[SomeT]): slick.jdbc.JdbcProfile.API.TableQuery[SpecificT]
- Attributes
- protected
- Definition Classes
- CRUD
- def trace(mkr: Marker, msg: => Any, t: => Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def trace(msg: => Any, t: => Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def trace(msg: => Any): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def update(t: BlockHeaderDb): Future[BlockHeaderDb]
- Definition Classes
- CRUD
- def updateAction(t: BlockHeaderDb): slick.jdbc.JdbcProfile.API.DBIOAction[BlockHeaderDb, slick.jdbc.JdbcProfile.API.NoStream, Write]
- Definition Classes
- CRUDAction
- def updateAll(ts: Vector[BlockHeaderDb]): Future[Vector[BlockHeaderDb]]
- Definition Classes
- CRUD
- def updateAllAction(ts: Vector[BlockHeaderDb]): slick.jdbc.JdbcProfile.API.DBIOAction[Vector[BlockHeaderDb], slick.jdbc.JdbcProfile.API.NoStream, Write]
- Definition Classes
- CRUDAction
- def upsert(t: BlockHeaderDb): Future[BlockHeaderDb]
- Definition Classes
- CRUD
- def upsertAction(t: BlockHeaderDb): slick.jdbc.JdbcProfile.API.DBIOAction[BlockHeaderDb, slick.jdbc.JdbcProfile.API.NoStream, Write with Read]
- Definition Classes
- CRUDAction
- def upsertAll(ts: Vector[BlockHeaderDb]): Future[Vector[BlockHeaderDb]]
- Definition Classes
- CRUD
- def upsertAllAction(ts: Vector[BlockHeaderDb]): slick.jdbc.JdbcProfile.API.DBIOAction[Vector[BlockHeaderDb], slick.jdbc.JdbcProfile.API.NoStream, Write with Read]
- Definition Classes
- CRUDAction
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def warn(mkr: Marker, msg: => Any, t: => Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def warn(msg: => Any, t: => Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def warn(msg: => Any): Unit
- Attributes
- protected
- Definition Classes
- Logging