aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <obscuren@obscura.com>2014-01-03 20:40:38 +0800
committerobscuren <obscuren@obscura.com>2014-01-03 20:40:38 +0800
commit9581faf5fdacf4a135bcdf77d6f0fbe0d6eecba8 (patch)
treeae74d77233f6280c56b6f7c151ccae7d2851bc00
parent055407c835328c8b9628c73ddd7ba872d787c09d (diff)
downloadgo-tangerine-9581faf5fdacf4a135bcdf77d6f0fbe0d6eecba8.tar.gz
go-tangerine-9581faf5fdacf4a135bcdf77d6f0fbe0d6eecba8.tar.zst
go-tangerine-9581faf5fdacf4a135bcdf77d6f0fbe0d6eecba8.zip
Parsing for block and tx
-rw-r--r--block.go2
-rw-r--r--parsing.go9
-rw-r--r--transaction.go2
3 files changed, 8 insertions, 5 deletions
diff --git a/block.go b/block.go
index dd329f8ac..39858b0fd 100644
--- a/block.go
+++ b/block.go
@@ -73,7 +73,7 @@ func CreateBlock(root string, num int, prevHash string, base string, difficulty
contract := NewContract(tx.value, []byte(""))
block.state.Update(string(addr), string(contract.MarshalRlp()))
for i, val := range tx.data {
- contract.state.Update(string(Encode(i)), val)
+ contract.state.Update(string(Encode(uint32(i))), val)
}
block.UpdateContract(addr, contract)
}
diff --git a/parsing.go b/parsing.go
index 765950a4c..4c3f1187e 100644
--- a/parsing.go
+++ b/parsing.go
@@ -11,8 +11,11 @@ import (
// Op codes
var OpCodes = map[string]string{
"STOP": "0",
- "PSH": "30", // 0x30
- /*
+ "PUSH": "48", // 0x30
+ "POP": "49", // 0x31
+ "LOAD": "54", // 0x36
+
+ /* OLD VM OPCODES
"ADD": "16", // 0x10
"SUB": "17", // 0x11
"MUL": "18", // 0x12
@@ -57,7 +60,7 @@ var OpCodes = map[string]string{
func CompileInstr(s string) (string, error) {
tokens := strings.Split(s, " ")
if OpCodes[tokens[0]] == "" {
- return "", errors.New(fmt.Sprintf("OP not found: %s", tokens[0]))
+ return s, errors.New(fmt.Sprintf("OP not found: %s", tokens[0]))
}
code := OpCodes[tokens[0]] // Replace op codes with the proper numerical equivalent
diff --git a/transaction.go b/transaction.go
index dc5204f9b..1cfa6d729 100644
--- a/transaction.go
+++ b/transaction.go
@@ -57,7 +57,7 @@ func NewTransaction(to string, value uint32, data []string) *Transaction {
for i, val := range data {
instr, err := CompileInstr(val)
if err != nil {
- fmt.Printf("compile error:%d %v", i+1, err)
+ fmt.Printf("compile error:%d %v\n", i+1, err)
}
tx.data[i] = instr