Adding companion objects for script operation factories

This commit is contained in:
Chris Stewart 2016-01-08 10:44:27 -06:00
parent 60ca80e0e8
commit b70bf70dd2
3 changed files with 35 additions and 3 deletions

View File

@ -1,5 +1,12 @@
package org.scalacoin.script
import org.scalacoin.script.arithmetic.ArithmeticOperationsFactory
import org.scalacoin.script.bitwise.BitwiseOperationsFactory
import org.scalacoin.script.control.ControlOperationsFactory
import org.scalacoin.script.crypto.CryptoOperationFactory
import org.scalacoin.script.locktime.LocktimeOperationFactory
import org.scalacoin.script.stack.StackOperationFactory
/**
* Created by chris on 1/8/16.
*/
@ -20,3 +27,12 @@ trait ScriptOperationFactory[T] {
def fromString(str : String) : Option[T] = operations.find(_.toString == str)
}
object ScriptOperationFactory extends ScriptOperationFactory[ScriptOperation] {
override def operations = StackOperationFactory.operations ++ LocktimeOperationFactory.operations ++
CryptoOperationFactory.operations ++ ControlOperationsFactory.operations ++ BitwiseOperationsFactory.operations ++
ArithmeticOperationsFactory.operations
}

View File

@ -2,10 +2,12 @@ package org.scalacoin.script.parsing
import org.scalacoin.script.ScriptOperation
import scala.annotation.tailrec
/**
* Created by chris on 1/7/16.
*/
trait ScriptParser {
trait ScriptParser extends {
/**
@ -18,7 +20,21 @@ trait ScriptParser {
str.split(" ").toList
}
/**
* Parses an output script of a transaction
* @param str
* @return
*/
/* def parseOutputScript(str : String) : List[ScriptOperation] = {
@tailrec
def loop(operations : List[String], accum : List[ScriptOperation]) : List[ScriptOperation] = {
operations match {
case h :: t if ()
}
}
loop(str.split(" ").toList, List())
}*/
}

View File

@ -14,8 +14,8 @@ class ScriptParserTest extends FlatSpec with MustMatchers with ScriptParser {
parsedInput must be (TestUtil.p2pkhInputScript)
}
/* it must "parse an output script" in {
it must "parse an output script" in {
val parsedOutput = parseOutputScript(TestUtil.p2pkhOutputScriptNotParsed)
parsedOutput must be (TestUtil.p2pkhOutputScript)
}*/
}
}