Refactor Node.chainApiFromDb() to return ChainApi (#5484)

* Refactor Node.chainApiFromDb() to return ChainApi

* Adjust log level for ignoring p2p messages to DEBUG
This commit is contained in:
Chris Stewart 2024-03-20 08:56:50 -05:00 committed by GitHub
parent 3cfe700fad
commit 47c7680d8c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 8 deletions

View File

@ -1,7 +1,7 @@
package org.bitcoins.node
import org.apache.pekko.actor.ActorSystem
import org.bitcoins.chain.blockchain.ChainHandlerCached
import org.bitcoins.chain.blockchain.{ChainHandler}
import org.bitcoins.chain.config.ChainAppConfig
import org.bitcoins.chain.models.{
BlockHeaderDAO,
@ -48,11 +48,12 @@ trait Node
* our [[org.bitcoins.chain.blockchain.Blockchain Blockchain]]
*/
def chainApiFromDb()(implicit
executionContext: ExecutionContext): Future[ChainHandlerCached] = {
ChainHandlerCached.fromDatabase(BlockHeaderDAO(),
CompactFilterHeaderDAO(),
CompactFilterDAO(),
ChainStateDescriptorDAO())
executionContext: ExecutionContext): Future[ChainApi] = {
val c = ChainHandler.fromDatabase(BlockHeaderDAO(),
CompactFilterHeaderDAO(),
CompactFilterDAO(),
ChainStateDescriptorDAO())
Future.successful(c)
}
/** Starts our node */

View File

@ -608,7 +608,7 @@ case class PeerManager(
.map(_._2)
peerDataOpt match {
case None =>
logger.warn(
logger.debug(
s"Ignoring received msg=${payload.commandName} from peer=$peer because it was disconnected, peers=$peers state=${state}")
Future.successful(state)
case Some(peerData) =>

View File

@ -58,7 +58,7 @@ case class DataMessageHandler(
val isQueryTimedOut = state.isQueryTimedOut(appConfig.queryWaitTime)
if (peerData.peer != syncPeer && !isQueryTimedOut) {
//ignore message from peers that we aren't syncing with during IBD
logger.info(
logger.debug(
s"Ignoring message ${payload.commandName} from peer=${peerData.peer} in state=$state because we are syncing with this peer currently. syncPeer=$syncPeer")
Future.successful(this)
} else {