Remove .map() and use .foreach() with buffer in CryptoBytesUtil.toByteVector() (#4454)

This commit is contained in:
Chris Stewart 2022-07-06 18:23:14 -05:00 committed by GitHub
parent ae0962d7ed
commit 2b60bbb1c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -36,7 +36,7 @@ class ScanBitcoind()(implicit
bitcoind <- bitcoindF
endHeight <- endHeightF
//_ <- countWitV1MempoolTxs(bitcoind)
_ <- countTaprootTxsInBlocks(endHeight, 10000, bitcoind)
_ <- countTaprootTxsInBlocks(endHeight, 250000, bitcoind)
} yield ()
f.failed.foreach(err =>
logger.error(s"Failed to count witness v1 mempool txs", err))

View File

@ -2,7 +2,7 @@ package org.bitcoins.crypto
import scodec.bits.{BitVector, ByteVector}
import scala.math.BigInt
import java.io.ByteArrayOutputStream
/** Created by chris on 2/26/16.
*/
@ -97,7 +97,11 @@ trait CryptoBytesUtil {
@inline
final def toByteVector[T <: NetworkElement](h: Seq[T]): ByteVector = {
ByteVector.concat(h.map(_.bytes))
val outputStream = new ByteArrayOutputStream()
h.foreach { ne =>
outputStream.write(ne.bytes.toArray)
}
ByteVector(outputStream.toByteArray)
}
}