c

org.bitcoins.chain.models

BlockHeaderDAO

case class BlockHeaderDAO()(implicit ec: ExecutionContext, appConfig: ChainAppConfig) extends CRUD[BlockHeaderDb, DoubleSha256DigestBE] with SlickUtil[BlockHeaderDb, DoubleSha256DigestBE] with Product with Serializable

Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. BlockHeaderDAO
  2. Serializable
  3. Product
  4. Equals
  5. SlickUtil
  6. SlickUtilAction
  7. CRUD
  8. CRUDAction
  9. JdbcProfileComponent
  10. BitcoinSLogger
  11. AnyRef
  12. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new BlockHeaderDAO()(implicit ec: ExecutionContext, appConfig: ChainAppConfig)

Type Members

  1. class BlockHeaderTable extends slick.jdbc.JdbcProfile.JdbcAPI.Table[BlockHeaderDb]

    A table that stores block headers related to a blockchain

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. implicit val appConfig: ChainAppConfig
    Definition Classes
    BlockHeaderDAOCRUDCRUDActionJdbcProfileComponent
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def bestHeight: Future[Int]

    Returns the block height of the block with the most work from our database

  7. 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

  8. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  9. def count(): Future[Int]

    Returns number of rows in the table

    Returns number of rows in the table

    Definition Classes
    CRUD
  10. def countAction: slick.jdbc.JdbcProfile.JdbcAPI.DBIOAction[Int, slick.jdbc.JdbcProfile.JdbcAPI.NoStream, Read]
    Definition Classes
    CRUDAction
  11. def create(t: BlockHeaderDb): Future[BlockHeaderDb]

    create a record in the database

    create a record in the database

    t

    \- the record to be inserted

    returns

    the inserted record

    Definition Classes
    CRUD
  12. def createAction(t: BlockHeaderDb): slick.jdbc.JdbcProfile.JdbcAPI.DBIOAction[BlockHeaderDb, slick.jdbc.JdbcProfile.JdbcAPI.NoStream, Write]
    Definition Classes
    CRUDAction
  13. 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
    BlockHeaderDAOCRUD
  14. def createAllAction(ts: Vector[BlockHeaderDb]): slick.jdbc.JdbcProfile.JdbcAPI.DBIOAction[Vector[BlockHeaderDb], slick.jdbc.JdbcProfile.JdbcAPI.NoStream, Write]
    Definition Classes
    SlickUtilAction
  15. def createAllNoAutoInc(ts: Vector[BlockHeaderDb], database: SafeDatabase)(implicit ec: ExecutionContext): Future[Vector[BlockHeaderDb]]

    Creates rows in a database that are not auto incremented

    Creates rows in a database that are not auto incremented

    Definition Classes
    SlickUtil
  16. lazy val database: JdbcDatabaseDef

    The database we are connecting to

    The database we are connecting to

    Definition Classes
    JdbcProfileComponent
  17. lazy val dbConfig: DatabaseConfig[JdbcProfile]

    The configuration details for connecting/using the database for our projects that require database connections

    The configuration details for connecting/using the database for our projects that require database connections

    Definition Classes
    JdbcProfileComponent
  18. def delete(t: BlockHeaderDb): Future[Int]

    delete the corresponding record in the database

    delete the corresponding record in the database

    t

    \- the record to be deleted

    returns

    int - the number of rows affected by the deletion

    Definition Classes
    CRUD
  19. def deleteAction(t: BlockHeaderDb): slick.jdbc.JdbcProfile.JdbcAPI.DBIOAction[Int, slick.jdbc.JdbcProfile.JdbcAPI.NoStream, Write]
    Definition Classes
    CRUDAction
  20. def deleteAll(): Future[Int]

    delete all records from the table

    delete all records from the table

    Definition Classes
    CRUD
  21. def deleteAll(ts: Vector[BlockHeaderDb]): Future[Int]
    Definition Classes
    CRUD
  22. def deleteAllAction(): slick.jdbc.JdbcProfile.JdbcAPI.DBIOAction[Int, slick.jdbc.JdbcProfile.JdbcAPI.NoStream, Write with Transactional]

    WARNING: Deletes all rows in table, use with care

    WARNING: Deletes all rows in table, use with care

    Definition Classes
    CRUDAction
  23. def deleteAllAction(ts: Vector[BlockHeaderDb]): slick.jdbc.JdbcProfile.JdbcAPI.DBIOAction[Int, slick.jdbc.JdbcProfile.JdbcAPI.NoStream, Write]
    Definition Classes
    CRUDAction
  24. implicit val ec: ExecutionContext
    Definition Classes
    CRUDCRUDAction
  25. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  26. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  27. def find(f: (BlockHeaderDb) => Boolean)(implicit ec: ExecutionContext): Future[Option[BlockHeaderDb]]

    Finds a block header that satisfies the given predicate, else returns None

  28. def find(t: BlockHeaderDb): slick.jdbc.JdbcProfile.JdbcAPI.Query[slick.jdbc.JdbcProfile.JdbcAPI.Table[BlockHeaderDb], BlockHeaderDb, Seq]
    Attributes
    protected
    Definition Classes
    CRUDAction
  29. def findAll(ts: Vector[BlockHeaderDb]): slick.jdbc.JdbcProfile.JdbcAPI.Query[BlockHeaderTable, BlockHeaderDb, Seq]
    Attributes
    protected
    Definition Classes
    BlockHeaderDAOCRUDAction
  30. def findAll(): Future[Vector[BlockHeaderDb]]

    Finds all elements in the table

    Finds all elements in the table

    Definition Classes
    CRUD
  31. def findAllAction(): slick.jdbc.JdbcProfile.JdbcAPI.DBIOAction[Vector[BlockHeaderDb], slick.jdbc.JdbcProfile.JdbcAPI.NoStream, Read]
    Definition Classes
    CRUDAction
  32. def findByHash(hash: DoubleSha256DigestBE): Future[Option[BlockHeaderDb]]
  33. 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

  34. def findByPrimaryKey(id: DoubleSha256DigestBE): slick.jdbc.JdbcProfile.JdbcAPI.Query[slick.jdbc.JdbcProfile.JdbcAPI.Table[BlockHeaderDb], BlockHeaderDb, Seq]

    return all rows that have a certain primary key

    return all rows that have a certain primary key

    id

    primary key of the row to return

    returns

    Query object corresponding to the selected rows

    Attributes
    protected
    Definition Classes
    CRUDAction
  35. def findByPrimaryKeyAction(id: DoubleSha256DigestBE): slick.jdbc.JdbcProfile.JdbcAPI.DBIOAction[Option[BlockHeaderDb], slick.jdbc.JdbcProfile.JdbcAPI.NoStream, Read]
    Definition Classes
    CRUDAction
  36. def findByPrimaryKeys(hashes: Vector[DoubleSha256DigestBE]): slick.jdbc.JdbcProfile.JdbcAPI.Query[BlockHeaderTable, BlockHeaderDb, Seq]

    Finds the rows that correlate to the given primary keys

    Finds the rows that correlate to the given primary keys

    Definition Classes
    BlockHeaderDAOCRUDAction
  37. def findByPrimaryKeysAction(ids: Vector[DoubleSha256DigestBE]): slick.jdbc.JdbcProfile.JdbcAPI.DBIOAction[Vector[BlockHeaderDb], slick.jdbc.JdbcProfile.JdbcAPI.NoStream, Read]
    Definition Classes
    CRUDAction
  38. def findClosestBeforeTime(time: UInt32): Future[Option[BlockHeaderDb]]
  39. def findClosestToTime(time: UInt32): Future[BlockHeaderDb]
  40. def getAncestorAtHeight(child: BlockHeaderDb, height: Int): Future[Option[BlockHeaderDb]]

    Retrieves the ancestor for the given block header at the given height

  41. def getAtChainWork(work: BigInt): Future[Vector[BlockHeaderDb]]

    Retrieves a BlockHeaderDb with the given chain work

  42. def getAtChainWorkQuery(work: BigInt): slick.jdbc.JdbcProfile.StreamingProfileAction[Seq[BlockHeaderDb], BlockHeaderDb, Read]
  43. def getAtHeight(height: Int): Future[Vector[BlockHeaderDb]]

    Retrieves a BlockHeaderDb at the given height

  44. def getAtHeightQuery(height: Int): slick.jdbc.JdbcProfile.StreamingProfileAction[Seq[BlockHeaderDb], BlockHeaderDb, Read]
  45. def getBestChainTips: Future[Vector[BlockHeaderDb]]

    Returns the block header with the most accumulated work

  46. def getBetweenHeightAndHash(startHeight: Int, stopHash: DoubleSha256DigestBE): Future[Vector[BlockHeaderDb]]

    Gets Block Headers between (inclusive) start height and stop hash, could be out of order

  47. def getBetweenHeights(from: Int, to: Int): Future[Vector[BlockHeaderDb]]

    Gets Block Headers between (inclusive) from and to, could be out of order

  48. def getBetweenHeightsQuery(from: Int, to: Int): slick.jdbc.JdbcProfile.StreamingProfileAction[Seq[BlockHeaderDb], BlockHeaderDb, Read]
  49. def getBlockchainFrom(header: BlockHeaderDb, startHeight: Int)(implicit ec: ExecutionContext): Future[Option[Blockchain]]
  50. def getBlockchainFrom(header: BlockHeaderDb)(implicit ec: ExecutionContext): Future[Option[Blockchain]]

    Retrieves a blockchain with the best tip being the given header

  51. 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

    Blockchain

  52. def getBlockchainsBetweenHeights(from: Int, to: Int)(implicit ec: ExecutionContext): Future[Vector[Blockchain]]

    Retrieves a blockchain with the best tip being the given header

  53. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  54. 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.

  55. def getFullBlockchainFrom(header: BlockHeaderDb)(implicit ec: ExecutionContext): Future[Blockchain]

    Retrieves a full blockchain with the best tip being the given header

  56. def getLowestNoWorkHeight: Future[Int]
  57. 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.

  58. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  59. def logger: Logger
    Definition Classes
    BitcoinSLogger
  60. def maxHeight: Future[Int]

    Returns the maximum block height from our database

  61. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  62. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  63. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  64. lazy val numThreads: Int
    Definition Classes
    JdbcProfileComponent
  65. def productElementNames: Iterator[String]
    Definition Classes
    Product
  66. lazy val profile: JdbcProfile
    Definition Classes
    JdbcProfileComponent
  67. def read(id: DoubleSha256DigestBE): Future[Option[BlockHeaderDb]]

    read a record from the database

    read a record from the database

    id

    \- the id of the record to be read

    returns

    Option[T] - the record if found, else none

    Definition Classes
    CRUD
  68. def safeDatabase: SafeDatabase

    Binding to the actual database itself, this is what is used to run querys

    Binding to the actual database itself, this is what is used to run querys

    Definition Classes
    CRUD
  69. val schemaName: Option[String]
    Definition Classes
    CRUD
  70. def startHikariLogger(interval: Duration): HikariLogging

    Starts the background logger for hikari

    Starts the background logger for hikari

    interval

    \- how often hikari logs database connection pool information

    Attributes
    protected
    Definition Classes
    JdbcProfileComponent
  71. def stopHikariLogger(): Unit
    Attributes
    protected
    Definition Classes
    JdbcProfileComponent
  72. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  73. val table: TableQuery[BlockHeaderTable]

    The table inside our database we are inserting into

    The table inside our database we are inserting into

    Definition Classes
    BlockHeaderDAOCRUDAction
  74. implicit def tableQuerySafeSubtypeCast[SpecificT <: AbstractTable[_], SomeT <: SpecificT](tableQuery: slick.jdbc.JdbcProfile.JdbcAPI.TableQuery[SomeT]): slick.jdbc.JdbcProfile.JdbcAPI.TableQuery[SpecificT]

    We need to cast from TableQuery's of internal types (e.g.

    We need to cast from TableQuery's of internal types (e.g. AddressDAO#AddressTable) to external versions of them (e.g. AddressDAO().table). You'll notice that although the latter is a subtype of the first, this requires a cast since TableQuery is not covariant in its type parameter.

    However, since Query is covariant in its first type parameter, I believe the cast from TableQuery[T1] to TableQuery[T2] will always be safe so long as T1 is a subtype of T2 AND T1#TableElementType is equal to T2#TableElementType.

    The above conditions are always the case when this is called within DAOs as it is only ever used for things of the form TableQuery[XDAO().table] -> TableQuery[XDAO#XTable].

    Attributes
    protected
    Definition Classes
    CRUD
  75. def update(t: BlockHeaderDb): Future[BlockHeaderDb]

    Update the corresponding record in the database

    Update the corresponding record in the database

    Definition Classes
    CRUD
  76. def updateAction(t: BlockHeaderDb): slick.jdbc.JdbcProfile.JdbcAPI.DBIOAction[BlockHeaderDb, slick.jdbc.JdbcProfile.JdbcAPI.NoStream, Write]
    Definition Classes
    CRUDAction
  77. def updateAll(ts: Vector[BlockHeaderDb]): Future[Vector[BlockHeaderDb]]
    Definition Classes
    CRUD
  78. def updateAllAction(ts: Vector[BlockHeaderDb]): slick.jdbc.JdbcProfile.JdbcAPI.DBIOAction[Vector[BlockHeaderDb], slick.jdbc.JdbcProfile.JdbcAPI.NoStream, Write]

    Updates all of the given ts.

    Updates all of the given ts. Returns all ts that actually existed in the database and got updated This method discards things that did not exist in the database, thus could not be updated

    Definition Classes
    CRUDAction
  79. def upsert(t: BlockHeaderDb): Future[BlockHeaderDb]

    insert the record if it does not exist, update it if it does

    insert the record if it does not exist, update it if it does

    t

    \- the record to inserted / updated

    returns

    t - the record that has been inserted / updated

    Definition Classes
    CRUD
  80. def upsertAction(t: BlockHeaderDb): slick.jdbc.JdbcProfile.JdbcAPI.DBIOAction[BlockHeaderDb, slick.jdbc.JdbcProfile.JdbcAPI.NoStream, Write with Read]
    Definition Classes
    CRUDAction
  81. def upsertAll(ts: Vector[BlockHeaderDb]): Future[Vector[BlockHeaderDb]]

    Upserts all of the given ts in the database, then returns the upserted values

    Upserts all of the given ts in the database, then returns the upserted values

    Definition Classes
    CRUD
  82. def upsertAllAction(ts: Vector[BlockHeaderDb]): slick.jdbc.JdbcProfile.JdbcAPI.DBIOAction[Vector[BlockHeaderDb], slick.jdbc.JdbcProfile.JdbcAPI.NoStream, Write with Read]

    Upsert all of the given ts.

    Upsert all of the given ts. Returns all ts that were inserted or updated

    Definition Classes
    CRUDAction
    See also

    https://scala-slick.org/doc/3.3.3/queries.html#upserting

  83. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  84. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  85. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from BitcoinSLogger

Inherited from AnyRef

Inherited from Any

Ungrouped