-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
12 additions
and
17 deletions.
There are no files selected for viewing
29 changes: 12 additions & 17 deletions
29
node/src/main/scala/com/wavesplatform/transaction/PBSince.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,20 @@ | ||
package com.wavesplatform.transaction | ||
|
||
import com.wavesplatform.protobuf.transaction.PBTransactions | ||
import com.wavesplatform.transaction.PBSince.* | ||
|
||
trait PBSince { self: Transaction with VersionedTransaction => | ||
def protobufVersion: TxVersion | ||
final def isProtobufVersion: Boolean = self.version >= protobufVersion | ||
import scala.annotation.nowarn | ||
|
||
override def bytesSize: Int = | ||
if (isProtobufVersion) PBTransactions.protobuf(self).serializedSize else bytes().length | ||
sealed trait PBSince { self: Transaction & VersionedTransaction => | ||
lazy val protobufVersion: TxVersion = this match { | ||
case _: V1 => TxVersion.V1 | ||
case _: V2 => TxVersion.V2: @nowarn // scalac: unreachable code | ||
case _: V3 => TxVersion.V3 | ||
} | ||
final def isProtobufVersion: Boolean = self.version >= protobufVersion | ||
} | ||
|
||
object PBSince { | ||
trait V1 extends PBSince { self: Transaction with VersionedTransaction => | ||
override def protobufVersion: TxVersion = TxVersion.V1 | ||
} | ||
|
||
trait V2 extends PBSince { self: Transaction with VersionedTransaction => | ||
override def protobufVersion: TxVersion = TxVersion.V2 | ||
} | ||
|
||
trait V3 extends PBSince { self: Transaction with VersionedTransaction => | ||
override def protobufVersion: TxVersion = TxVersion.V3 | ||
} | ||
trait V1 extends PBSince { self: Transaction & VersionedTransaction => } | ||
trait V2 extends PBSince { self: Transaction & VersionedTransaction => } | ||
trait V3 extends PBSince { self: Transaction & VersionedTransaction => } | ||
} |