Skip to content

Commit

Permalink
refactor ops
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelliao committed Feb 15, 2017
1 parent 0ca92a5 commit 5c8d463
Show file tree
Hide file tree
Showing 23 changed files with 662 additions and 360 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.itranswarp.bitcoin.script;

import com.itranswarp.bitcoin.util.HashUtils;

/**
* Data op is executed by script engine directly.
*
* @author liaoxuefeng
*/
public class DataOp extends Op {

final byte[] data;

DataOp(int code, byte[] data) {
super(code, "DATA(" + HashUtils.toHexString(data) + ")");
this.data = data;
}

@Override
public boolean execute(ScriptContext context) {
log.info("push data: " + HashUtils.toHexString(data));
context.push(data);
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@

public abstract class Op {

public static final byte[] TRUE = new byte[] { 1 };
public static final byte[] FALSE = new byte[] { 0 };

protected final Log log = LogFactory.getLog(getClass());

public final int code;
public final String name;

/**
Expand All @@ -15,7 +19,8 @@ public abstract class Op {
* @param name
* Human-readable name.
*/
public Op(String name) {
public Op(int code, String name) {
this.code = code;
this.name = name;
}

Expand Down
Loading

0 comments on commit 5c8d463

Please sign in to comment.