Skip to content

Commit

Permalink
0.16.3 Update b1
Browse files Browse the repository at this point in the history
  • Loading branch information
BlockchainJames committed Apr 5, 2019
1 parent 43a9534 commit c75af9b
Show file tree
Hide file tree
Showing 323 changed files with 3,444 additions and 13,066 deletions.

This file was deleted.

Expand Up @@ -39,7 +39,7 @@ trait BaseState {
private var _lastBlock: Block = _
def lastBlock: Block = _lastBlock

protected def zbs(n: Float): Long = (n * 100000000L).toLong
protected def zbs(n: Float): Long = (n * 100000000L).toLong
protected val accountGen: Gen[PrivateKeyAccount] = Gen.containerOfN[Array, Byte](32, Arbitrary.arbitrary[Byte]).map(seed => PrivateKeyAccount(seed))

protected def updateFunctionalitySettings(base: FunctionalitySettings): FunctionalitySettings = base
Expand Down
32 changes: 10 additions & 22 deletions build.sbt
Expand Up @@ -15,12 +15,12 @@ val versionSource = Def.task {
// Please, update the fallback version every major and minor releases.
// This version is used then building from sources without Git repository
// In case of not updating the version nodes build from headless sources will fail to connect to newer versions
val FallbackVersion = (0, 16, 2)
val FallbackVersion = (0, 16, 3)

val versionFile = (sourceManaged in Compile).value / "com" / "zbsnetwork" / "Version.scala"
val versionExtractor = """(\d+)\.(\d+)\.(\d+).*""".r
val (major, minor, patch) = version.value match {
case versionExtractor(ma, mi, pa) => FallbackVersion //(ma.toInt, mi.toInt, pa.toInt)
case versionExtractor(ma, mi, pa) => (ma.toInt, mi.toInt, pa.toInt)
case _ => FallbackVersion
}
IO.write(
Expand All @@ -41,21 +41,15 @@ name := "zbs"
normalizedName := s"${name.value}${network.value.packageSuffix}"

git.useGitDescribe := true
git.uncommittedSignifier := Some("MT")
git.uncommittedSignifier := Some("DIRTY")
logBuffered := false

inThisBuild(
Seq(
scalaVersion := "2.12.8",
organization := "com.zbsnetwork",
crossPaths := false,
scalacOptions ++= Seq("-feature",
"-deprecation",
"-language:higherKinds",
"-language:implicitConversions",
"-Ywarn-unused:-implicits",
"-Xlint",
"-Ywarn-unused-import")
scalacOptions ++= Seq("-feature", "-deprecation", "-language:higherKinds", "-language:implicitConversions", "-Ywarn-unused:-implicits", "-Xlint")
))

resolvers ++= Seq(
Expand All @@ -73,7 +67,7 @@ val java9Options = Seq(
fork in run := true
javaOptions in run ++= java9Options

Test / fork := false
Test / fork := true
Test / javaOptions ++= java9Options

Jmh / javaOptions ++= java9Options
Expand Down Expand Up @@ -116,9 +110,7 @@ inConfig(Compile)(
mainClass := Some("com.zbsnetwork.Application"),
publishArtifact in packageDoc := false,
publishArtifact in packageSrc := false,
sourceGenerators += versionSource,
PB.targets += scalapb.gen(flatPackage = true) -> (sourceManaged in Compile).value,
PB.deleteTargetDirectory := false
sourceGenerators += versionSource
))

inConfig(Test)(
Expand Down Expand Up @@ -221,8 +213,8 @@ def allProjects: List[ProjectReference] = ReflectUtilities.allVals[Project](this

addCommandAlias(
"checkPR",
// set scalacOptions in ThisBuild ++= Seq("-Xfatal-warnings");
""";
|set scalacOptions in ThisBuild ++= Seq("-Xfatal-warnings");
|Global / checkPRRaw;
|set scalacOptions in ThisBuild -= "-Xfatal-warnings";
""".stripMargin
Expand All @@ -241,7 +233,6 @@ checkPRRaw in Global := {

lazy val common = crossProject(JSPlatform, JVMPlatform)
.withoutSuffixFor(JVMPlatform)
.disablePlugins(ProtocPlugin)
.settings(
libraryDependencies ++= Dependencies.scalatest
)
Expand All @@ -252,7 +243,6 @@ lazy val commonJVM = common.jvm
lazy val lang =
crossProject(JSPlatform, JVMPlatform)
.withoutSuffixFor(JVMPlatform)
.disablePlugins(ProtocPlugin)
.settings(
version := "1.0.0",
coverageExcludedPackages := ".*",
Expand Down Expand Up @@ -318,7 +308,7 @@ lazy val node = project
Dependencies.http ++
Dependencies.akka ++
Dependencies.serialization ++
Dependencies.testKit.map(_ % Test) ++
Dependencies.testKit.map(_ % "test") ++
Dependencies.logging ++
Dependencies.matcher ++
Dependencies.metrics ++
Expand All @@ -327,9 +317,7 @@ lazy val node = project
Dependencies.ficus ++
Dependencies.scorex ++
Dependencies.commons_net ++
Dependencies.monix.value ++
Dependencies.protobuf.value ++
Dependencies.grpc,
Dependencies.monix.value,
dependencyOverrides ++= Seq(
Dependencies.AkkaActor,
Dependencies.AkkaStream,
Expand All @@ -338,7 +326,7 @@ lazy val node = project
)
.dependsOn(langJVM, commonJVM)

///lazy val discovery = project
lazy val discovery = project

lazy val it = project
.dependsOn(node)
Expand Down
Expand Up @@ -52,5 +52,9 @@ class ByteStrTest extends Matchers with WordSpecLike {
ByteStr(getSeqBytesArr(3)).dropRight(-100) shouldBe ByteStr(getSeqBytesArr(3))
ByteStr(getSeqBytesArr(3)).dropRight(100) shouldBe ByteStr.empty
}

"serialize to base64 if huge" in {
ByteStr(new Array(1024)).toString.startsWith("base64:") shouldBe true
}
}
}
Expand Up @@ -5,16 +5,35 @@ import com.zbsnetwork.common.utils.{Base58, Base64}
import scala.util.Try

case class ByteStr(arr: Array[Byte]) {

override def equals(a: Any): Boolean = a match {
case other: ByteStr => arr.sameElements(other.arr)
case _ => false
}

override def hashCode(): Int = java.util.Arrays.hashCode(arr)

lazy val base58: String = Base58.encode(arr)

lazy val base64: String = "base64:" + Base64.encode(arr)
lazy val base64Raw: String = Base64.encode(arr)
lazy val base64: String = "base64:" + base64Raw

lazy val trim: String = base58.toString.take(7) + "..."
lazy val trim: String = (if (arr.length < 1024) {
base58.toString.take(7)
} else {
base64Raw
}) + "..."

override lazy val toString: String = base58
override lazy val toString: String = if (arr.length < 1024) {
base58
} else {
base64
}

def isEmpty: Boolean = arr.length == 0

def size: Int = arr.length

def ++(other: ByteStr): ByteStr = if (this.isEmpty) other else ByteStr(this.arr ++ other.arr)

def take(n: Long): ByteStr = {
Expand Down Expand Up @@ -44,27 +63,23 @@ case class ByteStr(arr: Array[Byte]) {

def dropRight(n: Long): ByteStr = take(arr.length.toLong - n.max(0))

override def equals(a: Any): Boolean = a match {
case other: ByteStr => arr.sameElements(other.arr)
case _ => false
}

override def hashCode(): Int = java.util.Arrays.hashCode(arr)
}

object ByteStr {

val empty: ByteStr = ByteStr(Array.emptyByteArray)

implicit def fromByteArray(arr: Array[Byte]): ByteStr = {
new ByteStr(arr)
}
def fromBytes(bytes: Byte*): ByteStr = {

implicit def toByteArray(bs: ByteStr): Array[Byte] = {
bs.arr
}
val buf = new Array[Byte](bytes.size)
var i = 0

def fromBytes(bytes: Byte*): ByteStr = {
ByteStr(bytes.toArray)
bytes.foreach { b =>
buf(i) = b
i += 1
}

ByteStr(buf)
}

def fromLong(l: Long): ByteStr = {
Expand Down
@@ -1,20 +1,12 @@
package com.zbsnetwork.common
import scala.util.{Failure, Success, Try}

package object utils {

implicit class EitherExt2[A, B](ei: Either[A, B]) {

def explicitGet(): B = ei match {
case Left(value) => throw new Exception(value.toString)
case Right(value) => value
}

def foldToTry: Try[B] = {
ei.fold(
left => Failure(new Exception(left.toString)),
right => Success(right)
)
}
}

}
6 changes: 3 additions & 3 deletions dexgenerator/src/main/resources/application.conf
Expand Up @@ -6,13 +6,13 @@ generator {

send-to = [
{
address = "http://devnet-aws-fr-4.0bsnetworknodes.com:6869"
port = 6869
address = "http://devnet-aws-fr-4.0bsnetwork.com:7441"
port = 7441
}
]

matcher-config {
endpoint = "http://devnet-aws-fr-4.0bsnetworknodes.com:6886"
endpoint = "http://devnet-aws-fr-4.0bsnetwork.com:7441"
matcher-key = "BvfTcXu4d9Nsge8Woz42QW94Rf7MKcjtMYQz4L6MAPFX"
}

Expand Down
45 changes: 0 additions & 45 deletions dexgenerator/src/main/resources/devnet.conf

This file was deleted.

6 changes: 3 additions & 3 deletions dexgenerator/src/main/resources/devnetM.conf
Expand Up @@ -6,13 +6,13 @@ generator {

send-to = [
{
address = "http://devnet-aws-fr-4.0bsnetworknodes.com:6869"
port = 6869
address = "http://devnet-aws-fr-4.0bsnetwork.com:7441"
port = 7441
}
]

matcher-config {
endpoint = "http://devnet-aws-fr-4.0bsnetworknodes.com:6886"
endpoint = "http://devnet-aws-fr-4.0bsnetwork.com:6886"
matcher-key = "BvfTcXu4d9Nsge8Woz42QW94Rf7MKcjtMYQz4L6MAPFX"
}

Expand Down

0 comments on commit c75af9b

Please sign in to comment.