mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2024-11-19 18:02:54 +01:00
Tweak module logging (#698)
* Split app loggers into their corresponding modules This avoids a bunch of places with awkward implicit resolution. We also make sure that all logging in node, chain and wallet happens with the app loggers, and not BitcoinSLogger * Tune test logging level to WARN
This commit is contained in:
parent
ff051ac7a2
commit
2a0d78d054
@ -0,0 +1,25 @@
|
|||||||
|
package org.bitcoins.server
|
||||||
|
|
||||||
|
import org.slf4j.Logger
|
||||||
|
import org.bitcoins.db.AppConfig
|
||||||
|
import org.bitcoins.db.AppLoggers
|
||||||
|
|
||||||
|
/** Exposes access to the HTTP RPC server logger */
|
||||||
|
private[bitcoins] trait HttpLogger {
|
||||||
|
private var _logger: Logger = _
|
||||||
|
protected[bitcoins] def logger(implicit config: AppConfig) = {
|
||||||
|
if (_logger == null) {
|
||||||
|
_logger = HttpLogger.getLogger
|
||||||
|
}
|
||||||
|
_logger
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private[bitcoins] object HttpLogger extends AppLoggers {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the HTTP RPC server submobule logger
|
||||||
|
*/
|
||||||
|
def getLogger(implicit conf: AppConfig): Logger =
|
||||||
|
getLoggerImpl(LoggerKind.Http)
|
||||||
|
}
|
@ -24,7 +24,7 @@ object Main extends App {
|
|||||||
BitcoinSAppConfig.fromDefaultDatadir()
|
BitcoinSAppConfig.fromDefaultDatadir()
|
||||||
}
|
}
|
||||||
|
|
||||||
private val logger = AppLoggers.getHttpLogger(
|
private val logger = HttpLogger.getLogger(
|
||||||
conf.walletConf // doesn't matter which one we pass in
|
conf.walletConf // doesn't matter which one we pass in
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ import akka.http.scaladsl.server.Directives._
|
|||||||
import de.heikoseeberger.akkahttpupickle.UpickleSupport._
|
import de.heikoseeberger.akkahttpupickle.UpickleSupport._
|
||||||
import akka.http.scaladsl.server.directives.DebuggingDirectives
|
import akka.http.scaladsl.server.directives.DebuggingDirectives
|
||||||
import akka.event.Logging
|
import akka.event.Logging
|
||||||
import org.bitcoins.db.HttpLogger
|
|
||||||
import org.bitcoins.db.AppConfig
|
import org.bitcoins.db.AppConfig
|
||||||
|
|
||||||
case class Server(conf: AppConfig, handlers: Seq[ServerRoute])(
|
case class Server(conf: AppConfig, handlers: Seq[ServerRoute])(
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
package org.bitcoins.chain
|
||||||
|
|
||||||
|
import org.bitcoins.db.AppLoggers
|
||||||
|
import org.bitcoins.chain.config.ChainAppConfig
|
||||||
|
import org.slf4j.Logger
|
||||||
|
|
||||||
|
/** Exposes access to the chain verification logger */
|
||||||
|
private[bitcoins] trait ChainVerificationLogger {
|
||||||
|
private var _logger: Logger = _
|
||||||
|
protected[bitcoins] def logger(implicit config: ChainAppConfig) = {
|
||||||
|
if (_logger == null) {
|
||||||
|
_logger = ChainVerificationLogger.getLogger
|
||||||
|
}
|
||||||
|
_logger
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private[bitcoins] object ChainVerificationLogger extends AppLoggers {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the chain verification submobule logger
|
||||||
|
*/
|
||||||
|
def getLogger(implicit conf: ChainAppConfig): Logger =
|
||||||
|
getLoggerImpl(LoggerKind.ChainVerification)
|
||||||
|
}
|
@ -4,7 +4,7 @@ import org.bitcoins.chain.config.ChainAppConfig
|
|||||||
import org.bitcoins.chain.models.BlockHeaderDb
|
import org.bitcoins.chain.models.BlockHeaderDb
|
||||||
import org.bitcoins.chain.validation.{TipUpdateResult, TipValidation}
|
import org.bitcoins.chain.validation.{TipUpdateResult, TipValidation}
|
||||||
import org.bitcoins.core.protocol.blockchain.BlockHeader
|
import org.bitcoins.core.protocol.blockchain.BlockHeader
|
||||||
import org.bitcoins.db.ChainVerificationLogger
|
import org.bitcoins.chain.ChainVerificationLogger
|
||||||
|
|
||||||
import scala.collection.{IndexedSeqLike, mutable}
|
import scala.collection.{IndexedSeqLike, mutable}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import org.bitcoins.chain.validation.TipUpdateResult.{
|
|||||||
import org.bitcoins.core.crypto.DoubleSha256DigestBE
|
import org.bitcoins.core.crypto.DoubleSha256DigestBE
|
||||||
import org.bitcoins.core.protocol.blockchain.BlockHeader
|
import org.bitcoins.core.protocol.blockchain.BlockHeader
|
||||||
import org.bitcoins.core.util.FutureUtil
|
import org.bitcoins.core.util.FutureUtil
|
||||||
import org.bitcoins.db.ChainVerificationLogger
|
import org.bitcoins.chain.ChainVerificationLogger
|
||||||
|
|
||||||
import scala.concurrent.{ExecutionContext, Future}
|
import scala.concurrent.{ExecutionContext, Future}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import org.bitcoins.core.protocol.blockchain.BlockHeader
|
|||||||
|
|
||||||
import scala.concurrent.{ExecutionContext, Future}
|
import scala.concurrent.{ExecutionContext, Future}
|
||||||
import org.bitcoins.chain.config.ChainAppConfig
|
import org.bitcoins.chain.config.ChainAppConfig
|
||||||
import org.bitcoins.db.ChainVerificationLogger
|
import org.bitcoins.chain.ChainVerificationLogger
|
||||||
|
|
||||||
trait ChainSync extends ChainVerificationLogger {
|
trait ChainSync extends ChainVerificationLogger {
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import org.bitcoins.core.protocol.blockchain.BlockHeader
|
|||||||
import org.bitcoins.core.util.NumberUtil
|
import org.bitcoins.core.util.NumberUtil
|
||||||
|
|
||||||
import org.bitcoins.chain.config.ChainAppConfig
|
import org.bitcoins.chain.config.ChainAppConfig
|
||||||
import org.bitcoins.db.ChainVerificationLogger
|
import org.bitcoins.chain.ChainVerificationLogger
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Responsible for checking if we can connect two
|
* Responsible for checking if we can connect two
|
||||||
|
@ -13,7 +13,7 @@ bitcoin-s {
|
|||||||
# The available loggers are:
|
# The available loggers are:
|
||||||
|
|
||||||
# incoming and outgoing P2P messages
|
# incoming and outgoing P2P messages
|
||||||
#p2p = info
|
# p2p = info
|
||||||
|
|
||||||
# verification of block headers, merkle trees
|
# verification of block headers, merkle trees
|
||||||
# chain-verification = info
|
# chain-verification = info
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package org.bitcoins.node.networking.peer
|
package org.bitcoins.node.networking.peer
|
||||||
|
|
||||||
import org.bitcoins.testkit.util.BitcoinSUnitTest
|
import org.bitcoins.testkit.util.BitcoinSUnitTest
|
||||||
|
import org.bitcoins.testkit.BitcoinSTestAppConfig
|
||||||
import org.bitcoins.testkit.Implicits._
|
import org.bitcoins.testkit.Implicits._
|
||||||
|
import org.bitcoins.node.config.NodeAppConfig
|
||||||
import org.bitcoins.core.protocol.blockchain.MerkleBlock
|
import org.bitcoins.core.protocol.blockchain.MerkleBlock
|
||||||
import org.bitcoins.testkit.core.gen.BlockchainElementsGenerator
|
import org.bitcoins.testkit.core.gen.BlockchainElementsGenerator
|
||||||
import org.bitcoins.testkit.core.gen.TransactionGenerators
|
import org.bitcoins.testkit.core.gen.TransactionGenerators
|
||||||
@ -15,6 +17,10 @@ import scala.util.Try
|
|||||||
import scala.util.Failure
|
import scala.util.Failure
|
||||||
|
|
||||||
class MerkleBuffersTest extends BitcoinSUnitTest {
|
class MerkleBuffersTest extends BitcoinSUnitTest {
|
||||||
|
|
||||||
|
implicit private val config: NodeAppConfig =
|
||||||
|
BitcoinSTestAppConfig.getTestConfig().nodeConf
|
||||||
|
|
||||||
behavior of "MerkleBuffers"
|
behavior of "MerkleBuffers"
|
||||||
|
|
||||||
it must "match a merkle block with its corresponding transactions" in {
|
it must "match a merkle block with its corresponding transactions" in {
|
||||||
|
24
node/src/main/scala/org/bitcoins/node/P2PLogger.scala
Normal file
24
node/src/main/scala/org/bitcoins/node/P2PLogger.scala
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package org.bitcoins.node
|
||||||
|
|
||||||
|
import org.slf4j.Logger
|
||||||
|
import org.bitcoins.node.config.NodeAppConfig
|
||||||
|
import org.bitcoins.db.AppLoggers
|
||||||
|
|
||||||
|
/** Exposes access to the P2P submodule logger */
|
||||||
|
private[bitcoins] trait P2PLogger {
|
||||||
|
private var _logger: Logger = _
|
||||||
|
protected def logger(implicit config: NodeAppConfig) = {
|
||||||
|
if (_logger == null) {
|
||||||
|
_logger = P2PLogger.getLogger
|
||||||
|
}
|
||||||
|
_logger
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private[bitcoins] object P2PLogger extends AppLoggers {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the peer-to-peer submobule logger
|
||||||
|
*/
|
||||||
|
def getLogger(implicit conf: NodeAppConfig) = getLoggerImpl(LoggerKind.P2P)
|
||||||
|
}
|
@ -9,7 +9,6 @@ import org.bitcoins.core.bloom.BloomFilter
|
|||||||
import org.bitcoins.core.p2p.NetworkPayload
|
import org.bitcoins.core.p2p.NetworkPayload
|
||||||
import org.bitcoins.core.protocol.BitcoinAddress
|
import org.bitcoins.core.protocol.BitcoinAddress
|
||||||
import org.bitcoins.core.protocol.transaction.Transaction
|
import org.bitcoins.core.protocol.transaction.Transaction
|
||||||
import org.bitcoins.db.P2PLogger
|
|
||||||
import org.bitcoins.node.config.NodeAppConfig
|
import org.bitcoins.node.config.NodeAppConfig
|
||||||
import org.bitcoins.node.models.{
|
import org.bitcoins.node.models.{
|
||||||
BroadcastAbleTransaction,
|
BroadcastAbleTransaction,
|
||||||
@ -83,8 +82,7 @@ case class SpvNode(
|
|||||||
* @return SPV node with the updated bloom filter
|
* @return SPV node with the updated bloom filter
|
||||||
*/
|
*/
|
||||||
def updateBloomFilter(transaction: Transaction): Future[SpvNode] = {
|
def updateBloomFilter(transaction: Transaction): Future[SpvNode] = {
|
||||||
logger(nodeAppConfig).info(
|
logger.info(s"Updating bloom filter with transaction=${transaction.txIdBE}")
|
||||||
s"Updating bloom filter with transaction=${transaction.txIdBE}")
|
|
||||||
val newBloom = bloomFilter.update(transaction)
|
val newBloom = bloomFilter.update(transaction)
|
||||||
|
|
||||||
// we could send filteradd messages, but we would
|
// we could send filteradd messages, but we would
|
||||||
@ -103,7 +101,7 @@ case class SpvNode(
|
|||||||
* @return SPV node with the updated bloom filter
|
* @return SPV node with the updated bloom filter
|
||||||
*/
|
*/
|
||||||
def updateBloomFilter(address: BitcoinAddress): Future[SpvNode] = {
|
def updateBloomFilter(address: BitcoinAddress): Future[SpvNode] = {
|
||||||
logger(nodeAppConfig).info(s"Updating bloom filter with address=$address")
|
logger.info(s"Updating bloom filter with address=$address")
|
||||||
val hash = address.hash
|
val hash = address.hash
|
||||||
val newBloom = bloomFilter.insert(hash)
|
val newBloom = bloomFilter.insert(hash)
|
||||||
val sentFilterAddF = peerMsgSenderF.map(_.sendFilterAddMessage(hash))
|
val sentFilterAddF = peerMsgSenderF.map(_.sendFilterAddMessage(hash))
|
||||||
@ -125,7 +123,7 @@ case class SpvNode(
|
|||||||
|
|
||||||
/** Starts our spv node */
|
/** Starts our spv node */
|
||||||
def start(): Future[SpvNode] = {
|
def start(): Future[SpvNode] = {
|
||||||
logger(nodeAppConfig).info("Starting spv node")
|
logger.info("Starting spv node")
|
||||||
val start = System.currentTimeMillis()
|
val start = System.currentTimeMillis()
|
||||||
for {
|
for {
|
||||||
_ <- nodeAppConfig.initialize()
|
_ <- nodeAppConfig.initialize()
|
||||||
@ -135,30 +133,26 @@ case class SpvNode(
|
|||||||
_ <- AsyncUtil.retryUntilSatisfiedF(() => isInitialized)
|
_ <- AsyncUtil.retryUntilSatisfiedF(() => isInitialized)
|
||||||
} yield ()
|
} yield ()
|
||||||
|
|
||||||
isInitializedF.failed.foreach(
|
isInitializedF.failed.foreach(err =>
|
||||||
err =>
|
logger.error(s"Failed to connect with peer=$peer with err=${err}"))
|
||||||
logger(nodeAppConfig).error(
|
|
||||||
s"Failed to connect with peer=$peer with err=${err}"))
|
|
||||||
|
|
||||||
isInitializedF.map { _ =>
|
isInitializedF.map { _ =>
|
||||||
logger(nodeAppConfig).info(s"Our peer=${peer} has been initialized")
|
logger.info(s"Our peer=${peer} has been initialized")
|
||||||
logger(nodeAppConfig).info(
|
logger.info(s"Our spv node has been full started. It took=${System
|
||||||
s"Our spv node has been full started. It took=${System
|
.currentTimeMillis() - start}ms")
|
||||||
.currentTimeMillis() - start}ms")
|
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ <- peerMsgSenderF.map(_.sendFilterLoadMessage(bloomFilter))
|
_ <- peerMsgSenderF.map(_.sendFilterLoadMessage(bloomFilter))
|
||||||
} yield {
|
} yield {
|
||||||
logger(nodeAppConfig).info(
|
logger.info(s"Sending bloomfilter=${bloomFilter.hex} to $peer")
|
||||||
s"Sending bloomfilter=${bloomFilter.hex} to $peer")
|
|
||||||
node
|
node
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Stops our spv node */
|
/** Stops our spv node */
|
||||||
def stop(): Future[SpvNode] = {
|
def stop(): Future[SpvNode] = {
|
||||||
logger(nodeAppConfig).info(s"Stopping spv node")
|
logger.info(s"Stopping spv node")
|
||||||
val disconnectF = for {
|
val disconnectF = for {
|
||||||
p <- peerMsgSenderF
|
p <- peerMsgSenderF
|
||||||
disconnect <- p.disconnect()
|
disconnect <- p.disconnect()
|
||||||
@ -166,13 +160,13 @@ case class SpvNode(
|
|||||||
|
|
||||||
val start = System.currentTimeMillis()
|
val start = System.currentTimeMillis()
|
||||||
val isStoppedF = disconnectF.flatMap { _ =>
|
val isStoppedF = disconnectF.flatMap { _ =>
|
||||||
logger(nodeAppConfig).info(s"Awaiting disconnect")
|
logger.info(s"Awaiting disconnect")
|
||||||
//25 seconds to disconnect
|
//25 seconds to disconnect
|
||||||
AsyncUtil.retryUntilSatisfiedF(() => isDisconnected, 500.millis)
|
AsyncUtil.retryUntilSatisfiedF(() => isDisconnected, 500.millis)
|
||||||
}
|
}
|
||||||
|
|
||||||
isStoppedF.map { _ =>
|
isStoppedF.map { _ =>
|
||||||
logger(nodeAppConfig).info(
|
logger.info(
|
||||||
s"Spv node stopped! It took=${System.currentTimeMillis() - start}ms")
|
s"Spv node stopped! It took=${System.currentTimeMillis() - start}ms")
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
@ -184,14 +178,13 @@ case class SpvNode(
|
|||||||
|
|
||||||
txDAO.create(broadcastTx).onComplete {
|
txDAO.create(broadcastTx).onComplete {
|
||||||
case Failure(exception) =>
|
case Failure(exception) =>
|
||||||
logger(nodeAppConfig)
|
logger.error(s"Error when writing broadcastable TX to DB", exception)
|
||||||
.error(s"Error when writing broadcastable TX to DB", exception)
|
|
||||||
case Success(written) =>
|
case Success(written) =>
|
||||||
logger(nodeAppConfig).debug(
|
logger.debug(
|
||||||
s"Wrote tx=${written.transaction.txIdBE} to broadcastable table")
|
s"Wrote tx=${written.transaction.txIdBE} to broadcastable table")
|
||||||
}
|
}
|
||||||
|
|
||||||
logger(nodeAppConfig).info(s"Sending out inv for tx=${transaction.txIdBE}")
|
logger.info(s"Sending out inv for tx=${transaction.txIdBE}")
|
||||||
peerMsgSenderF.flatMap(_.sendInventoryMessage(transaction))
|
peerMsgSenderF.flatMap(_.sendInventoryMessage(transaction))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,8 +214,7 @@ case class SpvNode(
|
|||||||
.map(_.get) // .get is safe since this is an internal call
|
.map(_.get) // .get is safe since this is an internal call
|
||||||
} yield {
|
} yield {
|
||||||
peerMsgSenderF.map(_.sendGetHeadersMessage(hash.flip))
|
peerMsgSenderF.map(_.sendGetHeadersMessage(hash.flip))
|
||||||
logger(nodeAppConfig).info(
|
logger.info(s"Starting sync node, height=${header.height} hash=$hash")
|
||||||
s"Starting sync node, height=${header.height} hash=$hash")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package org.bitcoins.node.networking
|
|||||||
|
|
||||||
import akka.actor.{Actor, ActorRef, ActorRefFactory, Props}
|
import akka.actor.{Actor, ActorRef, ActorRefFactory, Props}
|
||||||
import akka.io.{IO, Tcp}
|
import akka.io.{IO, Tcp}
|
||||||
import akka.pattern.AskTimeoutException
|
|
||||||
import akka.util.{ByteString, CompactByteString, Timeout}
|
import akka.util.{ByteString, CompactByteString, Timeout}
|
||||||
import org.bitcoins.core.config.NetworkParameters
|
import org.bitcoins.core.config.NetworkParameters
|
||||||
import org.bitcoins.core.p2p.NetworkMessage
|
import org.bitcoins.core.p2p.NetworkMessage
|
||||||
@ -17,7 +16,7 @@ import org.bitcoins.node.config.NodeAppConfig
|
|||||||
|
|
||||||
import scala.annotation.tailrec
|
import scala.annotation.tailrec
|
||||||
import scala.util._
|
import scala.util._
|
||||||
import org.bitcoins.db.P2PLogger
|
import org.bitcoins.node.P2PLogger
|
||||||
|
|
||||||
import scala.concurrent.{Await, ExecutionContext, Future}
|
import scala.concurrent.{Await, ExecutionContext, Future}
|
||||||
import scala.concurrent.duration.DurationInt
|
import scala.concurrent.duration.DurationInt
|
||||||
|
@ -4,7 +4,7 @@ import org.bitcoins.chain.api.ChainApi
|
|||||||
import org.bitcoins.core.p2p.{Inventory, MsgUnassigned, TypeIdentifier, _}
|
import org.bitcoins.core.p2p.{Inventory, MsgUnassigned, TypeIdentifier, _}
|
||||||
import org.bitcoins.core.protocol.blockchain.{Block, MerkleBlock}
|
import org.bitcoins.core.protocol.blockchain.{Block, MerkleBlock}
|
||||||
import org.bitcoins.core.protocol.transaction.Transaction
|
import org.bitcoins.core.protocol.transaction.Transaction
|
||||||
import org.bitcoins.db.P2PLogger
|
import org.bitcoins.node.P2PLogger
|
||||||
import org.bitcoins.node.SpvNodeCallbacks
|
import org.bitcoins.node.SpvNodeCallbacks
|
||||||
import org.bitcoins.node.config.NodeAppConfig
|
import org.bitcoins.node.config.NodeAppConfig
|
||||||
import org.bitcoins.node.models.BroadcastAbleTransactionDAO
|
import org.bitcoins.node.models.BroadcastAbleTransactionDAO
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package org.bitcoins.node.networking.peer
|
package org.bitcoins.node.networking.peer
|
||||||
|
|
||||||
import org.bitcoins.core.util.BitcoinSLogger
|
import org.bitcoins.node.P2PLogger
|
||||||
import scala.collection.mutable
|
import scala.collection.mutable
|
||||||
import org.bitcoins.core.protocol.blockchain.MerkleBlock
|
import org.bitcoins.core.protocol.blockchain.MerkleBlock
|
||||||
import org.bitcoins.core.protocol.transaction.Transaction
|
import org.bitcoins.core.protocol.transaction.Transaction
|
||||||
|
import org.bitcoins.node.config.NodeAppConfig
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A buffer of merkleblocks and the transactions associated with them.
|
* A buffer of merkleblocks and the transactions associated with them.
|
||||||
@ -16,14 +17,14 @@ import org.bitcoins.core.protocol.transaction.Transaction
|
|||||||
* This buffer is responsible for calling the approriate callbacks
|
* This buffer is responsible for calling the approriate callbacks
|
||||||
* once a merkle block has received all its transactions.
|
* once a merkle block has received all its transactions.
|
||||||
*/
|
*/
|
||||||
private[peer] object MerkleBuffers extends BitcoinSLogger {
|
private[peer] object MerkleBuffers extends P2PLogger {
|
||||||
private type MerkleBlocksWithTransactions =
|
private type MerkleBlocksWithTransactions =
|
||||||
mutable.Map[MerkleBlock, mutable.Builder[Transaction, Vector[Transaction]]]
|
mutable.Map[MerkleBlock, mutable.Builder[Transaction, Vector[Transaction]]]
|
||||||
|
|
||||||
private val underlyingMap: MerkleBlocksWithTransactions = mutable.Map.empty
|
private val underlyingMap: MerkleBlocksWithTransactions = mutable.Map.empty
|
||||||
|
|
||||||
/** Adds the given merkleblock to the buffer */
|
/** Adds the given merkleblock to the buffer */
|
||||||
def putMerkle(merkle: MerkleBlock): Unit = {
|
def putMerkle(merkle: MerkleBlock)(implicit config: NodeAppConfig): Unit = {
|
||||||
val tree = merkle.partialMerkleTree
|
val tree = merkle.partialMerkleTree
|
||||||
val matches = tree.extractMatches
|
val matches = tree.extractMatches
|
||||||
|
|
||||||
@ -56,7 +57,8 @@ private[peer] object MerkleBuffers extends BitcoinSLogger {
|
|||||||
*/
|
*/
|
||||||
def putTx(
|
def putTx(
|
||||||
tx: Transaction,
|
tx: Transaction,
|
||||||
callbacks: Seq[DataMessageHandler.OnMerkleBlockReceived]): Boolean = {
|
callbacks: Seq[DataMessageHandler.OnMerkleBlockReceived])(
|
||||||
|
implicit config: NodeAppConfig): Boolean = {
|
||||||
val blocksInBuffer = underlyingMap.keys.toList
|
val blocksInBuffer = underlyingMap.keys.toList
|
||||||
logger.trace(s"Looking for transaction=${tx.txIdBE} in merkleblock buffer")
|
logger.trace(s"Looking for transaction=${tx.txIdBE} in merkleblock buffer")
|
||||||
logger.trace(s"Merkleblocks in buffer: ${blocksInBuffer.length}")
|
logger.trace(s"Merkleblocks in buffer: ${blocksInBuffer.length}")
|
||||||
@ -81,7 +83,8 @@ private[peer] object MerkleBuffers extends BitcoinSLogger {
|
|||||||
private def handleMerkleMatch(
|
private def handleMerkleMatch(
|
||||||
transaction: Transaction,
|
transaction: Transaction,
|
||||||
merkleBlock: MerkleBlock,
|
merkleBlock: MerkleBlock,
|
||||||
callbacks: Seq[DataMessageHandler.OnMerkleBlockReceived]) = {
|
callbacks: Seq[DataMessageHandler.OnMerkleBlockReceived])(
|
||||||
|
implicit config: NodeAppConfig) = {
|
||||||
val merkleBlockMatches = merkleBlock.partialMerkleTree.extractMatches
|
val merkleBlockMatches = merkleBlock.partialMerkleTree.extractMatches
|
||||||
val merkleHash = merkleBlock.blockHeader.hashBE
|
val merkleHash = merkleBlock.blockHeader.hashBE
|
||||||
|
|
||||||
|
@ -2,62 +2,4 @@ package org.bitcoins.node.networking.peer
|
|||||||
|
|
||||||
import org.bitcoins.node.networking.P2PClient
|
import org.bitcoins.node.networking.P2PClient
|
||||||
|
|
||||||
/*
|
|
||||||
abstract class PeerHandler extends BitcoinSLogger {
|
|
||||||
implicit val system: ActorSystem
|
|
||||||
implicit val ec: ExecutionContext = system.dispatcher
|
|
||||||
implicit val timeout: Timeout
|
|
||||||
|
|
||||||
def socket: InetSocketAddress
|
|
||||||
|
|
||||||
def dbConfig: DbConfig
|
|
||||||
|
|
||||||
def peerMsgSender: PeerMessageSender
|
|
||||||
|
|
||||||
def getHeaders(getHeadersMsg: GetHeadersMessage): Unit = {
|
|
||||||
sendToPeer(getHeadersMsg)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Connects with our peer*/
|
|
||||||
def connect(): Future[Unit] = {
|
|
||||||
pee
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Checks if we are connected with our peer */
|
|
||||||
def isConnected: Boolean = ???
|
|
||||||
|
|
||||||
/** Closes our connection with our peer */
|
|
||||||
def close(): Future[Unit] = {
|
|
||||||
val closedF = (peerMsgSender.actor ? Tcp.Close).mapTo[Tcp.Closed.type]
|
|
||||||
|
|
||||||
closedF.map(_ => ())
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
object PeerHandler {
|
|
||||||
private case class PeerHandlerImpl(
|
|
||||||
peerMsgSender: PeerMessageSender,
|
|
||||||
socket: InetSocketAddress,
|
|
||||||
dbConfig: DbConfig)(
|
|
||||||
override implicit val system: ActorSystem,
|
|
||||||
val timeout: Timeout)
|
|
||||||
extends PeerHandler
|
|
||||||
|
|
||||||
def apply(
|
|
||||||
peerMsgSender: PeerMessageSender,
|
|
||||||
socket: InetSocketAddress,
|
|
||||||
dbConfig: DbConfig)(
|
|
||||||
implicit system: ActorSystem,
|
|
||||||
timeout: Timeout): PeerHandler = {
|
|
||||||
PeerHandlerImpl(peerMsgSender, socket, dbConfig)(system, timeout)
|
|
||||||
}
|
|
||||||
|
|
||||||
/* def apply(peer: Peer, dbConfig: DbConfig)(implicit system: ActorSystem, timeout: Timeout): PeerHandler = {
|
|
||||||
val actorRef = PeerMessageHandler(dbConfig = dbConfig)
|
|
||||||
PeerHandler(actorRef,peer.socket,dbConfig)
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
case class PeerHandler(p2pClient: P2PClient, peerMsgSender: PeerMessageSender)
|
case class PeerHandler(p2pClient: P2PClient, peerMsgSender: PeerMessageSender)
|
||||||
|
@ -6,7 +6,7 @@ import org.bitcoins.chain.blockchain.ChainHandler
|
|||||||
import org.bitcoins.chain.config.ChainAppConfig
|
import org.bitcoins.chain.config.ChainAppConfig
|
||||||
import org.bitcoins.chain.models.BlockHeaderDAO
|
import org.bitcoins.chain.models.BlockHeaderDAO
|
||||||
import org.bitcoins.core.p2p.{NetworkMessage, _}
|
import org.bitcoins.core.p2p.{NetworkMessage, _}
|
||||||
import org.bitcoins.db.P2PLogger
|
import org.bitcoins.node.P2PLogger
|
||||||
import org.bitcoins.node.SpvNodeCallbacks
|
import org.bitcoins.node.SpvNodeCallbacks
|
||||||
import org.bitcoins.node.config.NodeAppConfig
|
import org.bitcoins.node.config.NodeAppConfig
|
||||||
import org.bitcoins.node.models.Peer
|
import org.bitcoins.node.models.Peer
|
||||||
@ -54,7 +54,7 @@ class PeerMessageReceiver(
|
|||||||
new RuntimeException(s"Cannot call connect when in state=${bad}")
|
new RuntimeException(s"Cannot call connect when in state=${bad}")
|
||||||
)
|
)
|
||||||
case Preconnection =>
|
case Preconnection =>
|
||||||
logger(nodeAppConfig).info(s"Connection established with peer=${peer}")
|
logger.info(s"Connection established with peer=${peer}")
|
||||||
|
|
||||||
val newState = Preconnection.toInitializing(client)
|
val newState = Preconnection.toInitializing(client)
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ class PeerMessageReceiver(
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected[networking] def disconnect(): Future[PeerMessageReceiver] = {
|
protected[networking] def disconnect(): Future[PeerMessageReceiver] = {
|
||||||
logger(nodeAppConfig).trace(s"Disconnecting with internalstate=${state}")
|
logger.trace(s"Disconnecting with internalstate=${state}")
|
||||||
state match {
|
state match {
|
||||||
case bad @ (_: Initializing | _: Disconnected | Preconnection) =>
|
case bad @ (_: Initializing | _: Disconnected | Preconnection) =>
|
||||||
Future.failed(
|
Future.failed(
|
||||||
@ -78,7 +78,7 @@ class PeerMessageReceiver(
|
|||||||
)
|
)
|
||||||
|
|
||||||
case good: Normal =>
|
case good: Normal =>
|
||||||
logger(nodeAppConfig).debug(s"Disconnected bitcoin peer=${peer}")
|
logger.debug(s"Disconnected bitcoin peer=${peer}")
|
||||||
val newState = Disconnected(
|
val newState = Disconnected(
|
||||||
clientConnectP = good.clientConnectP,
|
clientConnectP = good.clientConnectP,
|
||||||
clientDisconnectP = good.clientDisconnectP.success(()),
|
clientDisconnectP = good.clientDisconnectP.success(()),
|
||||||
@ -113,7 +113,7 @@ class PeerMessageReceiver(
|
|||||||
//create a way to send a response if we need too
|
//create a way to send a response if we need too
|
||||||
val peerMsgSender = PeerMessageSender(client)
|
val peerMsgSender = PeerMessageSender(client)
|
||||||
|
|
||||||
logger(nodeAppConfig).debug(
|
logger.debug(
|
||||||
s"Received message=${networkMsgRecv.msg.header.commandName} from peer=${client.peer} state=${state} ")
|
s"Received message=${networkMsgRecv.msg.header.commandName} from peer=${client.peer} state=${state} ")
|
||||||
networkMsgRecv.msg.payload match {
|
networkMsgRecv.msg.payload match {
|
||||||
case controlPayload: ControlPayload =>
|
case controlPayload: ControlPayload =>
|
||||||
@ -159,8 +159,7 @@ class PeerMessageReceiver(
|
|||||||
payload match {
|
payload match {
|
||||||
|
|
||||||
case versionMsg: VersionMessage =>
|
case versionMsg: VersionMessage =>
|
||||||
logger(nodeAppConfig).trace(
|
logger.trace(s"Received versionMsg=${versionMsg}from peer=${peer}")
|
||||||
s"Received versionMsg=${versionMsg}from peer=${peer}")
|
|
||||||
|
|
||||||
state match {
|
state match {
|
||||||
case bad @ (_: Disconnected | _: Normal | Preconnection) =>
|
case bad @ (_: Disconnected | _: Normal | Preconnection) =>
|
||||||
|
@ -9,7 +9,7 @@ import org.bitcoins.core.p2p._
|
|||||||
import org.bitcoins.node.networking.P2PClient
|
import org.bitcoins.node.networking.P2PClient
|
||||||
import org.bitcoins.node.config.NodeAppConfig
|
import org.bitcoins.node.config.NodeAppConfig
|
||||||
import org.bitcoins.core.protocol.transaction.Transaction
|
import org.bitcoins.core.protocol.transaction.Transaction
|
||||||
import org.bitcoins.db.P2PLogger
|
import org.bitcoins.node.P2PLogger
|
||||||
import org.bitcoins.core.crypto.HashDigest
|
import org.bitcoins.core.crypto.HashDigest
|
||||||
import org.bitcoins.core.bloom.BloomFilter
|
import org.bitcoins.core.bloom.BloomFilter
|
||||||
import org.bitcoins.core.protocol.blockchain.BlockHeader
|
import org.bitcoins.core.protocol.blockchain.BlockHeader
|
||||||
|
@ -10,10 +10,20 @@ object BitcoinSTestAppConfig {
|
|||||||
* App configuration suitable for test purposes:
|
* App configuration suitable for test purposes:
|
||||||
*
|
*
|
||||||
* 1) Data directory is set to user temp directory
|
* 1) Data directory is set to user temp directory
|
||||||
|
* 2) Logging is turned down to WARN
|
||||||
*/
|
*/
|
||||||
def getTestConfig(config: Config*): BitcoinSAppConfig = {
|
def getTestConfig(config: Config*): BitcoinSAppConfig = {
|
||||||
|
val overrideConf = ConfigFactory.parseString {
|
||||||
|
"""
|
||||||
|
|bitcoin-s {
|
||||||
|
| logging {
|
||||||
|
| level = WARN
|
||||||
|
| }
|
||||||
|
|}
|
||||||
|
""".stripMargin
|
||||||
|
}
|
||||||
val tmpDir = Files.createTempDirectory("bitcoin-s-")
|
val tmpDir = Files.createTempDirectory("bitcoin-s-")
|
||||||
BitcoinSAppConfig(tmpDir, config: _*)
|
BitcoinSAppConfig(tmpDir, (overrideConf +: config): _*)
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed trait ProjectType
|
sealed trait ProjectType
|
||||||
|
@ -4,6 +4,7 @@ import java.net.InetSocketAddress
|
|||||||
|
|
||||||
import akka.actor.ActorSystem
|
import akka.actor.ActorSystem
|
||||||
import com.typesafe.config.ConfigFactory
|
import com.typesafe.config.ConfigFactory
|
||||||
|
import org.bitcoins.chain.ChainVerificationLogger
|
||||||
import org.bitcoins.chain.blockchain.ChainHandler
|
import org.bitcoins.chain.blockchain.ChainHandler
|
||||||
import org.bitcoins.chain.config.ChainAppConfig
|
import org.bitcoins.chain.config.ChainAppConfig
|
||||||
import org.bitcoins.chain.db.ChainDbManagement
|
import org.bitcoins.chain.db.ChainDbManagement
|
||||||
@ -13,7 +14,6 @@ import org.bitcoins.chain.models.{
|
|||||||
BlockHeaderDbHelper
|
BlockHeaderDbHelper
|
||||||
}
|
}
|
||||||
import org.bitcoins.core.protocol.blockchain.{Block, BlockHeader, ChainParams}
|
import org.bitcoins.core.protocol.blockchain.{Block, BlockHeader, ChainParams}
|
||||||
import org.bitcoins.core.util.BitcoinSLogger
|
|
||||||
import org.bitcoins.rpc.client.common.BitcoindRpcClient
|
import org.bitcoins.rpc.client.common.BitcoindRpcClient
|
||||||
import org.bitcoins.testkit.chain
|
import org.bitcoins.testkit.chain
|
||||||
import org.bitcoins.testkit.chain.fixture._
|
import org.bitcoins.testkit.chain.fixture._
|
||||||
@ -35,7 +35,7 @@ trait ChainUnitTest
|
|||||||
with BitcoinSFixture
|
with BitcoinSFixture
|
||||||
with ChainFixtureHelper
|
with ChainFixtureHelper
|
||||||
with MustMatchers
|
with MustMatchers
|
||||||
with BitcoinSLogger
|
with ChainVerificationLogger
|
||||||
with BeforeAndAfter
|
with BeforeAndAfter
|
||||||
with BeforeAndAfterAll {
|
with BeforeAndAfterAll {
|
||||||
|
|
||||||
@ -299,7 +299,7 @@ trait ChainUnitTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object ChainUnitTest extends BitcoinSLogger {
|
object ChainUnitTest extends ChainVerificationLogger {
|
||||||
|
|
||||||
/** Height of the first block in populated fixtures */
|
/** Height of the first block in populated fixtures */
|
||||||
val FIRST_BLOCK_HEIGHT: Int = 562375
|
val FIRST_BLOCK_HEIGHT: Int = 562375
|
||||||
|
@ -9,7 +9,11 @@ import org.scalatest._
|
|||||||
import scala.concurrent.{Future, Promise}
|
import scala.concurrent.{Future, Promise}
|
||||||
import scala.util.{Failure, Success}
|
import scala.util.{Failure, Success}
|
||||||
|
|
||||||
trait BitcoinSFixture extends fixture.AsyncFlatSpec with BitcoinSLogger {
|
trait BitcoinSFixture extends fixture.AsyncFlatSpec {
|
||||||
|
|
||||||
|
// to avoid this trickling up to things that extend
|
||||||
|
// this trait
|
||||||
|
private val logger = BitcoinSLogger.logger
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given functions to build and destroy a fixture, returns a OneArgAsyncTest => FutureOutcome
|
* Given functions to build and destroy a fixture, returns a OneArgAsyncTest => FutureOutcome
|
||||||
|
@ -18,13 +18,13 @@ import scala.concurrent.Future
|
|||||||
import scala.concurrent.ExecutionContext
|
import scala.concurrent.ExecutionContext
|
||||||
import scala.concurrent.duration._
|
import scala.concurrent.duration._
|
||||||
import akka.actor.ActorSystem
|
import akka.actor.ActorSystem
|
||||||
import org.bitcoins.core.util.BitcoinSLogger
|
|
||||||
import org.bitcoins.testkit.async.TestAsyncUtil
|
import org.bitcoins.testkit.async.TestAsyncUtil
|
||||||
import org.bitcoins.core.bloom.BloomFilter
|
import org.bitcoins.core.bloom.BloomFilter
|
||||||
import org.bitcoins.core.bloom.BloomUpdateAll
|
import org.bitcoins.core.bloom.BloomUpdateAll
|
||||||
import org.bitcoins.core.crypto.DoubleSha256DigestBE
|
import org.bitcoins.core.crypto.DoubleSha256DigestBE
|
||||||
|
import org.bitcoins.node.P2PLogger
|
||||||
|
|
||||||
abstract class NodeTestUtil extends BitcoinSLogger {
|
abstract class NodeTestUtil extends P2PLogger {
|
||||||
|
|
||||||
//txid on testnet 44e504f5b7649d215be05ad9f09026dee95201244a3b218013c504a6a49a26ff
|
//txid on testnet 44e504f5b7649d215be05ad9f09026dee95201244a3b218013c504a6a49a26ff
|
||||||
//this tx has multiple inputs and outputs
|
//this tx has multiple inputs and outputs
|
||||||
|
@ -2,10 +2,10 @@ package org.bitcoins.testkit.node
|
|||||||
|
|
||||||
import akka.actor.ActorSystem
|
import akka.actor.ActorSystem
|
||||||
import akka.testkit.TestKit
|
import akka.testkit.TestKit
|
||||||
|
import org.bitcoins.node.P2PLogger
|
||||||
import org.bitcoins.chain.config.ChainAppConfig
|
import org.bitcoins.chain.config.ChainAppConfig
|
||||||
import org.bitcoins.chain.api.ChainApi
|
import org.bitcoins.chain.api.ChainApi
|
||||||
import org.bitcoins.core.config.NetworkParameters
|
import org.bitcoins.core.config.NetworkParameters
|
||||||
import org.bitcoins.core.util.BitcoinSLogger
|
|
||||||
import org.bitcoins.db.AppConfig
|
import org.bitcoins.db.AppConfig
|
||||||
import org.bitcoins.node.{SpvNode, SpvNodeCallbacks}
|
import org.bitcoins.node.{SpvNode, SpvNodeCallbacks}
|
||||||
import org.bitcoins.node.config.NodeAppConfig
|
import org.bitcoins.node.config.NodeAppConfig
|
||||||
@ -41,7 +41,7 @@ import scala.concurrent.{ExecutionContext, Future}
|
|||||||
trait NodeUnitTest
|
trait NodeUnitTest
|
||||||
extends BitcoinSFixture
|
extends BitcoinSFixture
|
||||||
with MustMatchers
|
with MustMatchers
|
||||||
with BitcoinSLogger
|
with P2PLogger
|
||||||
with BeforeAndAfter
|
with BeforeAndAfter
|
||||||
with BeforeAndAfterAll {
|
with BeforeAndAfterAll {
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ trait NodeUnitTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object NodeUnitTest extends BitcoinSLogger {
|
object NodeUnitTest extends P2PLogger {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates
|
* Creates
|
||||||
|
@ -4,7 +4,6 @@ import akka.actor.ActorSystem
|
|||||||
import akka.testkit.TestKit
|
import akka.testkit.TestKit
|
||||||
import org.bitcoins.core.config.RegTest
|
import org.bitcoins.core.config.RegTest
|
||||||
import org.bitcoins.core.protocol.blockchain.ChainParams
|
import org.bitcoins.core.protocol.blockchain.ChainParams
|
||||||
import org.bitcoins.core.util.BitcoinSLogger
|
|
||||||
import org.bitcoins.rpc.client.common.BitcoindRpcClient
|
import org.bitcoins.rpc.client.common.BitcoindRpcClient
|
||||||
import org.bitcoins.testkit.fixtures.BitcoinSFixture
|
import org.bitcoins.testkit.fixtures.BitcoinSFixture
|
||||||
import org.bitcoins.wallet.Wallet
|
import org.bitcoins.wallet.Wallet
|
||||||
@ -14,6 +13,7 @@ import org.bitcoins.wallet.api.{
|
|||||||
UnlockedWalletApi
|
UnlockedWalletApi
|
||||||
}
|
}
|
||||||
import org.bitcoins.wallet.db.{WalletDbManagement}
|
import org.bitcoins.wallet.db.{WalletDbManagement}
|
||||||
|
import org.bitcoins.wallet.WalletLogger
|
||||||
import org.scalatest._
|
import org.scalatest._
|
||||||
|
|
||||||
import scala.concurrent.duration.{DurationInt, FiniteDuration}
|
import scala.concurrent.duration.{DurationInt, FiniteDuration}
|
||||||
@ -21,6 +21,7 @@ import scala.concurrent.{ExecutionContext, Future}
|
|||||||
import org.bitcoins.core.currency._
|
import org.bitcoins.core.currency._
|
||||||
import org.bitcoins.db.AppConfig
|
import org.bitcoins.db.AppConfig
|
||||||
import org.bitcoins.server.BitcoinSAppConfig
|
import org.bitcoins.server.BitcoinSAppConfig
|
||||||
|
import org.bitcoins.server.BitcoinSAppConfig._
|
||||||
import com.typesafe.config.Config
|
import com.typesafe.config.Config
|
||||||
import com.typesafe.config.ConfigFactory
|
import com.typesafe.config.ConfigFactory
|
||||||
import org.bitcoins.testkit.BitcoinSTestAppConfig
|
import org.bitcoins.testkit.BitcoinSTestAppConfig
|
||||||
@ -29,7 +30,7 @@ trait BitcoinSWalletTest
|
|||||||
extends fixture.AsyncFlatSpec
|
extends fixture.AsyncFlatSpec
|
||||||
with BitcoinSFixture
|
with BitcoinSFixture
|
||||||
with BeforeAndAfterAll
|
with BeforeAndAfterAll
|
||||||
with BitcoinSLogger {
|
with WalletLogger {
|
||||||
import BitcoinSWalletTest._
|
import BitcoinSWalletTest._
|
||||||
implicit val actorSystem: ActorSystem = ActorSystem(getClass.getSimpleName)
|
implicit val actorSystem: ActorSystem = ActorSystem(getClass.getSimpleName)
|
||||||
implicit val ec: ExecutionContext = actorSystem.dispatcher
|
implicit val ec: ExecutionContext = actorSystem.dispatcher
|
||||||
@ -103,7 +104,7 @@ trait BitcoinSWalletTest
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
object BitcoinSWalletTest extends BitcoinSLogger {
|
object BitcoinSWalletTest extends WalletLogger {
|
||||||
|
|
||||||
case class WalletWithBitcoind(
|
case class WalletWithBitcoind(
|
||||||
wallet: UnlockedWalletApi,
|
wallet: UnlockedWalletApi,
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package org.bitcoins.wallet
|
package org.bitcoins.wallet
|
||||||
|
|
||||||
import org.bitcoins.core.crypto._
|
import org.bitcoins.core.crypto._
|
||||||
import org.bitcoins.core.util.BitcoinSLogger
|
|
||||||
import scodec.bits.ByteVector
|
import scodec.bits.ByteVector
|
||||||
|
|
||||||
import scala.util.{Failure, Success, Try}
|
import scala.util.{Failure, Success, Try}
|
||||||
|
@ -17,7 +17,6 @@ import scodec.bits.BitVector
|
|||||||
|
|
||||||
import scala.concurrent.{ExecutionContext, Future}
|
import scala.concurrent.{ExecutionContext, Future}
|
||||||
import scala.util.{Failure, Success, Try}
|
import scala.util.{Failure, Success, Try}
|
||||||
import org.bitcoins.db.KeyHandlingLogger
|
|
||||||
|
|
||||||
sealed abstract class Wallet extends LockedWallet with UnlockedWalletApi {
|
sealed abstract class Wallet extends LockedWallet with UnlockedWalletApi {
|
||||||
|
|
||||||
|
45
wallet/src/main/scala/org/bitcoins/wallet/WalletLogger.scala
Normal file
45
wallet/src/main/scala/org/bitcoins/wallet/WalletLogger.scala
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package org.bitcoins.wallet
|
||||||
|
|
||||||
|
import org.slf4j.Logger
|
||||||
|
import org.bitcoins.wallet.config.WalletAppConfig
|
||||||
|
import org.bitcoins.db.AppLoggers
|
||||||
|
|
||||||
|
/** Exposes acccess to the wallet logger */
|
||||||
|
private[bitcoins] trait WalletLogger {
|
||||||
|
private var _logger: Logger = _
|
||||||
|
protected[bitcoins] def logger(implicit config: WalletAppConfig) = {
|
||||||
|
if (_logger == null) {
|
||||||
|
_logger = WalletLogger.getLogger
|
||||||
|
}
|
||||||
|
_logger
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private[bitcoins] object WalletLogger extends AppLoggers {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the generic wallet logger (i.e. everything not related to key handling)
|
||||||
|
*/
|
||||||
|
def getLogger(implicit conf: WalletAppConfig): Logger =
|
||||||
|
getLoggerImpl(LoggerKind.Wallet)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Exposes access to the key handling logger */
|
||||||
|
private[bitcoins] trait KeyHandlingLogger {
|
||||||
|
private var _logger: Logger = _
|
||||||
|
protected[bitcoins] def logger(implicit config: WalletAppConfig) = {
|
||||||
|
if (_logger == null) {
|
||||||
|
_logger = KeyHandlingLogger.getLogger
|
||||||
|
}
|
||||||
|
_logger
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private[bitcoins] object KeyHandlingLogger extends AppLoggers {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the key handling submobule logger
|
||||||
|
*/
|
||||||
|
def getLogger(implicit conf: WalletAppConfig): Logger =
|
||||||
|
getLoggerImpl(LoggerKind.KeyHandling)
|
||||||
|
}
|
@ -14,7 +14,6 @@ import java.nio.file.Path
|
|||||||
import scala.util.Try
|
import scala.util.Try
|
||||||
import org.bitcoins.wallet.config.WalletAppConfig
|
import org.bitcoins.wallet.config.WalletAppConfig
|
||||||
import org.bitcoins.core.crypto.AesIV
|
import org.bitcoins.core.crypto.AesIV
|
||||||
import org.bitcoins.db.KeyHandlingLogger
|
|
||||||
|
|
||||||
// what do we do if seed exists? error if they aren't equal?
|
// what do we do if seed exists? error if they aren't equal?
|
||||||
object WalletStorage extends KeyHandlingLogger {
|
object WalletStorage extends KeyHandlingLogger {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package org.bitcoins.wallet.internal
|
package org.bitcoins.wallet.internal
|
||||||
|
|
||||||
import org.bitcoins.wallet.LockedWallet
|
import org.bitcoins.wallet._
|
||||||
import scala.concurrent.Future
|
import scala.concurrent.Future
|
||||||
import org.bitcoins.wallet.models.AddressDb
|
import org.bitcoins.wallet.models.AddressDb
|
||||||
import org.bitcoins.core.crypto.ECPublicKey
|
import org.bitcoins.core.crypto.ECPublicKey
|
||||||
@ -22,7 +22,6 @@ import org.bitcoins.core.protocol.script.ScriptPubKey
|
|||||||
import org.bitcoins.core.protocol.transaction.TransactionOutPoint
|
import org.bitcoins.core.protocol.transaction.TransactionOutPoint
|
||||||
import org.bitcoins.core.number.UInt32
|
import org.bitcoins.core.number.UInt32
|
||||||
import org.bitcoins.core.hd.AddressType
|
import org.bitcoins.core.hd.AddressType
|
||||||
import org.bitcoins.db.KeyHandlingLogger
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides functionality related to addresses. This includes
|
* Provides functionality related to addresses. This includes
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package org.bitcoins.wallet.internal
|
package org.bitcoins.wallet.internal
|
||||||
|
|
||||||
import org.bitcoins.wallet.LockedWallet
|
|
||||||
import org.bitcoins.core.protocol.transaction.Transaction
|
import org.bitcoins.core.protocol.transaction.Transaction
|
||||||
|
import org.bitcoins.wallet._
|
||||||
import org.bitcoins.wallet.models._
|
import org.bitcoins.wallet.models._
|
||||||
import scala.concurrent.Future
|
import scala.concurrent.Future
|
||||||
import org.bitcoins.core.protocol.transaction.TransactionOutput
|
import org.bitcoins.core.protocol.transaction.TransactionOutput
|
||||||
@ -9,7 +9,6 @@ import org.bitcoins.wallet.api.AddUtxoSuccess
|
|||||||
import org.bitcoins.wallet.api.AddUtxoError
|
import org.bitcoins.wallet.api.AddUtxoError
|
||||||
import org.bitcoins.core.number.UInt32
|
import org.bitcoins.core.number.UInt32
|
||||||
import org.bitcoins.core.util.FutureUtil
|
import org.bitcoins.core.util.FutureUtil
|
||||||
import org.bitcoins.db.KeyHandlingLogger
|
|
||||||
|
|
||||||
/** Provides functionality for processing transactions. This
|
/** Provides functionality for processing transactions. This
|
||||||
* includes importing UTXOs spent to our wallet, updating
|
* includes importing UTXOs spent to our wallet, updating
|
||||||
|
@ -22,7 +22,7 @@ import org.bitcoins.core.protocol.BitcoinAddress
|
|||||||
import scala.util.Success
|
import scala.util.Success
|
||||||
import scala.util.Failure
|
import scala.util.Failure
|
||||||
import org.bitcoins.core.crypto.DoubleSha256DigestBE
|
import org.bitcoins.core.crypto.DoubleSha256DigestBE
|
||||||
import org.bitcoins.db.KeyHandlingLogger
|
import org.bitcoins.wallet.KeyHandlingLogger
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides functionality related to handling UTXOs in our wallet.
|
* Provides functionality related to handling UTXOs in our wallet.
|
||||||
|
Loading…
Reference in New Issue
Block a user