Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class GenesisDataLoader(blockchain: Blockchain, blockchainConfig: BlockchainConf

val header: BlockHeader = prepareHeader(genesisData, stateMptRootHash)

log.debug(s"prepared genesis header: $header, with hash ${header.hashAsHexString}")
log.debug(s"Prepared genesis header: $header")

blockchain.getBlockHeaderByNumber(0) match {
case Some(existingGenesisHeader) if existingGenesisHeader.hash == header.hash =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ class NewBlockImportMessages(block: Block, peerId: PeerId) extends ImportMessage
val lastHeader = newBranch.last.header
(
DebugLevel,
s"""Imported block $number ($hash) from $peerId
|resulting in chain reorganisation: new branch of length ${newBranch.size} with head at block
|${lastHeader.number} (${hash2string(lastHeader.hash)})""".stripMargin
s"Imported block $number ($hash) from $peerId " +
s"resulting in chain reorganisation: new branch of length ${newBranch.size} with head at block " +
s"${lastHeader.number} (${hash2string(lastHeader.hash)})"
)
}
override def importFailed(error: String): LogEntry =
Expand Down
8 changes: 2 additions & 6 deletions src/main/scala/io/iohk/ethereum/domain/Block.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ import io.iohk.ethereum.rlp.{RLPEncodeable, RLPList, RLPSerializable, rawDecode}
* @param body Block body
*/
case class Block(header: BlockHeader, body: BlockBody) {
override def toString: String = {
s"""BlockHeader {
| header: $header
| body: $body
""".stripMargin
}
override def toString: String =
s"Block { header: $header, body: $body }"

def idTag: String =
header.idTag
Expand Down
6 changes: 1 addition & 5 deletions src/main/scala/io/iohk/ethereum/domain/BlockBody.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ import io.iohk.ethereum.rlp.{RLPEncodeable, RLPList, RLPSerializable, rawDecode}

case class BlockBody(transactionList: Seq[SignedTransaction], uncleNodesList: Seq[BlockHeader]) {
override def toString: String =
s"""BlockBody{
|transactionList: $transactionList
|uncleNodesList: $uncleNodesList
|}
""".stripMargin
s"BlockBody{ transactionList: $transactionList, uncleNodesList: $uncleNodesList }"

lazy val numberOfTxs: Int = transactionList.size

Expand Down
40 changes: 20 additions & 20 deletions src/main/scala/io/iohk/ethereum/domain/BlockHeader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,26 @@ case class BlockHeader(
("Pre-ECIP1098 block", "Pre-ECIP1097 block")
}

s"""BlockHeader {
|hash: $hashAsHexString
|parentHash: ${ByteStringUtils.hash2string(parentHash)}
|ommersHash: ${ByteStringUtils.hash2string(ommersHash)}
|beneficiary: ${ByteStringUtils.hash2string(beneficiary)}
|stateRoot: ${ByteStringUtils.hash2string(stateRoot)}
|transactionsRoot: ${ByteStringUtils.hash2string(transactionsRoot)}
|receiptsRoot: ${ByteStringUtils.hash2string(receiptsRoot)}
|logsBloom: ${ByteStringUtils.hash2string(logsBloom)}
|difficulty: $difficulty,
|number: $number,
|gasLimit: $gasLimit,
|gasUsed: $gasUsed,
|unixTimestamp: $unixTimestamp,
|extraData: ${ByteStringUtils.hash2string(extraData)}
|mixHash: ${ByteStringUtils.hash2string(mixHash)}
|nonce: ${ByteStringUtils.hash2string(nonce)},
|treasuryOptOut: $treasuryOptOutString
|isCheckpointing: $checkpointString
|}""".stripMargin
s"BlockHeader { " +
s"hash: $hashAsHexString, " +
s"parentHash: ${ByteStringUtils.hash2string(parentHash)}, " +
s"ommersHash: ${ByteStringUtils.hash2string(ommersHash)}, " +
s"beneficiary: ${ByteStringUtils.hash2string(beneficiary)} " +
s"stateRoot: ${ByteStringUtils.hash2string(stateRoot)} " +
s"transactionsRoot: ${ByteStringUtils.hash2string(transactionsRoot)} " +
s"receiptsRoot: ${ByteStringUtils.hash2string(receiptsRoot)} " +
s"logsBloom: ${ByteStringUtils.hash2string(logsBloom)} " +
s"difficulty: $difficulty, " +
s"number: $number, " +
s"gasLimit: $gasLimit, " +
s"gasUsed: $gasUsed, " +
s"unixTimestamp: $unixTimestamp, " +
s"extraData: ${ByteStringUtils.hash2string(extraData)} " +
s"mixHash: ${ByteStringUtils.hash2string(mixHash)} " +
s"nonce: ${ByteStringUtils.hash2string(nonce)}, " +
s"treasuryOptOut: $treasuryOptOutString " +
s"isCheckpointing: $checkpointString" +
s"}"
}

/**
Expand Down
14 changes: 6 additions & 8 deletions src/main/scala/io/iohk/ethereum/domain/Receipt.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,11 @@ case class Receipt(
case _ => Array(0.toByte)
}

s"""
|Receipt{
| postTransactionStateHash: ${Hex.toHexString(stateHash)}
| cumulativeGasUsed: $cumulativeGasUsed
| logsBloomFilter: ${Hex.toHexString(logsBloomFilter.toArray[Byte])}
| logs: $logs
|}
""".stripMargin
s"Receipt{ " +
s"postTransactionStateHash: ${Hex.toHexString(stateHash)}, " +
s"cumulativeGasUsed: $cumulativeGasUsed, " +
s"logsBloomFilter: ${Hex.toHexString(logsBloomFilter.toArray[Byte])}, " +
s"logs: $logs" +
s"}"
}
}
11 changes: 5 additions & 6 deletions src/main/scala/io/iohk/ethereum/domain/SignedTransaction.scala
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,11 @@ case class SignedTransaction(tx: Transaction, signature: ECDSASignature) {
def safeSenderIsEqualTo(address: Address): Boolean =
SignedTransaction.getSender(this).contains(address)

override def toString: String = {
s"""SignedTransaction {
|tx: $tx
|signature: $signature
|}""".stripMargin
}
override def toString: String =
s"SignedTransaction { " +
s"tx: $tx, " +
s"signature: $signature" +
s"}"

def isChainSpecific: Boolean =
signature.v != ECDSASignature.negativePointSign && signature.v != ECDSASignature.positivePointSign
Expand Down
22 changes: 11 additions & 11 deletions src/main/scala/io/iohk/ethereum/domain/Transaction.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ case class Transaction(
def isContractInit: Boolean = receivingAddress.isEmpty

override def toString: String = {
s"""Transaction {
|nonce: $nonce
|gasPrice: $gasPrice
|gasLimit: $gasLimit
|receivingAddress: ${if (receivingAddress.isDefined) Hex.toHexString(receivingAddress.get.toArray)
else "[Contract creation]"}
|value: $value wei
|payload: ${if (isContractInit) "ContractInit: " else "TransactionData: "}${Hex.toHexString(
payload.toArray[Byte]
)}
|}""".stripMargin
val receivingAddressString =
if (receivingAddress.isDefined) Hex.toHexString(receivingAddress.get.toArray) else "[Contract creation]"

s"Transaction {" +
s"nonce: $nonce " +
s"gasPrice: $gasPrice " +
s"gasLimit: $gasLimit " +
s"receivingAddress: $receivingAddressString " +
s"value: $value wei " +
s"payload: ${if (isContractInit) "ContractInit: " else "TransactionData: "}${Hex.toHexString(payload.toArray[Byte])} " +
s"}"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,15 @@ object CommonMessages {
) extends Message {
require(code == Status.code63 || code == Status.code64, s"Invalid code for Status: $code")

override def toString: String = {
s"""Status {
|code: $code
|protocolVersion: $protocolVersion
|networkId: $networkId
|chainWeight: $chainWeight
|bestHash: ${Hex.toHexString(bestHash.toArray[Byte])}
|genesisHash: ${Hex.toHexString(genesisHash.toArray[Byte])}
|}""".stripMargin
}
override def toString: String =
s"Status { " +
s"code: $code, " +
s"protocolVersion: $protocolVersion, " +
s"networkId: $networkId, " +
s"chainWeight: $chainWeight, " +
s"bestHash: ${Hex.toHexString(bestHash.toArray[Byte])}, " +
s"genesisHash: ${Hex.toHexString(genesisHash.toArray[Byte])}," +
s"}"

def as63: Status =
copy(code = Status.code63)
Expand Down Expand Up @@ -293,13 +292,12 @@ object CommonMessages {
case class NewBlock(code: Int, block: Block, chainWeight: ChainWeight) extends Message {
require(code == NewBlock.code63 || code == NewBlock.code64, s"Invalid code for NewBlock: $code")

override def toString: String = {
s"""NewBlock {
|code: $code
|block: $block
|chainWeight: $chainWeight
|}""".stripMargin
}
override def toString: String =
s"NewBlock { " +
s"code: $code, " +
s"block: $block, " +
s"chainWeight: $chainWeight" +
s"}"

def as63: NewBlock =
copy(code = NewBlock.code63)
Expand Down
37 changes: 16 additions & 21 deletions src/main/scala/io/iohk/ethereum/network/p2p/messages/PV62.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ object PV62 {
}

case class BlockHash(hash: ByteString, number: BigInt) {
override def toString: String = {
s"""BlockHash {
|hash: ${Hex.toHexString(hash.toArray[Byte])}
|number: $number
|}""".stripMargin
}
override def toString: String =
s"BlockHash { " +
s"hash: ${Hex.toHexString(hash.toArray[Byte])} " +
s"number: $number " +
s"}"
}

object NewBlockHashes {
Expand Down Expand Up @@ -101,15 +100,13 @@ object PV62 {
extends Message {
override def code: Int = GetBlockHeaders.code

override def toString: String = {
s"""GetBlockHeaders{
|block: ${block.fold(a => a, b => Hex.toHexString(b.toArray[Byte]))}
|maxHeaders: $maxHeaders
|skip: $skip
|reverse: $reverse
|}
""".stripMargin
}
override def toString: String =
s"GetBlockHeaders{ " +
s"block: ${block.fold(a => a, b => Hex.toHexString(b.toArray[Byte]))} " +
s"maxHeaders: $maxHeaders " +
s"skip: $skip " +
s"reverse: $reverse " +
s"}"
}

object BlockBodies {
Expand Down Expand Up @@ -189,11 +186,9 @@ object PV62 {
case class GetBlockBodies(hashes: Seq[ByteString]) extends Message {
override def code: Int = GetBlockBodies.code

override def toString: String = {
s"""GetBlockBodies {
|hashes: ${hashes.map(h => Hex.toHexString(h.toArray[Byte]))}
|}
""".stripMargin
}
override def toString: String =
s"GetBlockBodies { " +
s"hashes: ${hashes.map(h => Hex.toHexString(h.toArray[Byte]))} " +
s"}"
}
}
21 changes: 5 additions & 16 deletions src/main/scala/io/iohk/ethereum/network/p2p/messages/PV63.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@ object PV63 {
case class GetNodeData(mptElementsHashes: Seq[ByteString]) extends Message {
override def code: Int = GetNodeData.code

override def toString: String = {
s"""GetNodeData{
|hashes: ${mptElementsHashes.map(e => Hex.toHexString(e.toArray[Byte]))}
|}
""".stripMargin
}
override def toString: String =
s"GetNodeData{ hashes: ${mptElementsHashes.map(e => Hex.toHexString(e.toArray[Byte]))} }"
}

object AccountImplicits {
Expand Down Expand Up @@ -111,12 +107,8 @@ object PV63 {

override def code: Int = NodeData.code

override def toString: String = {
s"""NodeData{
|values: ${values.map(b => Hex.toHexString(b.toArray[Byte]))}
|}
""".stripMargin
}
override def toString: String =
s"NodeData{ values: ${values.map(b => Hex.toHexString(b.toArray[Byte]))} }"
}

object GetReceipts {
Expand All @@ -142,10 +134,7 @@ object PV63 {
override def code: Int = GetReceipts.code

override def toString: String = {
s"""GetReceipts{
|blockHashes: ${blockHashes.map(e => Hex.toHexString(e.toArray[Byte]))}
|}
""".stripMargin
s"GetReceipts{ blockHashes: ${blockHashes.map(e => Hex.toHexString(e.toArray[Byte]))} } "
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ object WireProtocol {
override val code: Int = Hello.code

override def toString: String = {
s"""Hello {
|p2pVersion: $p2pVersion
|clientId: $clientId
|capabilities: $capabilities
|listenPort: $listenPort
|nodeId: ${Hex.toHexString(nodeId.toArray[Byte])}
|}""".stripMargin
s"Hello { " +
s"p2pVersion: $p2pVersion " +
s"clientId: $clientId " +
s"capabilities: $capabilities " +
s"listenPort: $listenPort " +
s"nodeId: ${Hex.toHexString(nodeId.toArray[Byte])} " +
s"}"
}
}

Expand Down Expand Up @@ -132,7 +132,7 @@ object WireProtocol {
override val code: Int = Disconnect.code

override def toString: String =
s"Disconnect(${Disconnect.reasonToString(reason)}"
s"Disconnect(${Disconnect.reasonToString(reason)})"

}

Expand Down