diff --git a/node/src/main/scala/com/wavesplatform/transaction/PBSince.scala b/node/src/main/scala/com/wavesplatform/transaction/PBSince.scala index 69ebdc017e..86f93a8fed 100644 --- a/node/src/main/scala/com/wavesplatform/transaction/PBSince.scala +++ b/node/src/main/scala/com/wavesplatform/transaction/PBSince.scala @@ -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 => } }