aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <obscuren@obscura.com>2013-12-28 22:18:23 +0800
committerobscuren <obscuren@obscura.com>2013-12-28 22:18:23 +0800
commit5198b7b9ebdfe1ef99627dadb07b87e18a039972 (patch)
tree0def935db14d1b971e6f74e03d0f2197be5e5c80
parentbd582d919bf3dfa68cce10ca506c39a4c2e2ea94 (diff)
downloadgo-tangerine-5198b7b9ebdfe1ef99627dadb07b87e18a039972.tar
go-tangerine-5198b7b9ebdfe1ef99627dadb07b87e18a039972.tar.gz
go-tangerine-5198b7b9ebdfe1ef99627dadb07b87e18a039972.tar.bz2
go-tangerine-5198b7b9ebdfe1ef99627dadb07b87e18a039972.tar.lz
go-tangerine-5198b7b9ebdfe1ef99627dadb07b87e18a039972.tar.xz
go-tangerine-5198b7b9ebdfe1ef99627dadb07b87e18a039972.tar.zst
go-tangerine-5198b7b9ebdfe1ef99627dadb07b87e18a039972.zip
Test code updated
-rw-r--r--ethereum.go11
-rw-r--r--vm.go18
2 files changed, 18 insertions, 11 deletions
diff --git a/ethereum.go b/ethereum.go
index d3cecdc94..3e01f89b2 100644
--- a/ethereum.go
+++ b/ethereum.go
@@ -4,6 +4,8 @@ import (
"fmt"
)
+const Debug = false
+
func main() {
InitFees()
@@ -35,6 +37,11 @@ func main() {
bm.ProcessBlock( blck )
- //t := blck.MarshalRlp()
- //blck.UnmarshalRlp(t)
+
+ t := blck.MarshalRlp()
+ copyBlock := &Block{}
+ copyBlock.UnmarshalRlp(t)
+
+ fmt.Println(blck)
+ fmt.Println(copyBlock)
}
diff --git a/vm.go b/vm.go
index dc026f318..787e29295 100644
--- a/vm.go
+++ b/vm.go
@@ -64,10 +64,7 @@ type Vm struct {
}
func NewVm() *Vm {
- fmt.Println("init Ethereum VM")
-
- stackSize := uint(256)
- fmt.Println("stack size =", stackSize)
+ //stackSize := uint(256)
return &Vm{
stack: make(map[string]string),
@@ -76,10 +73,12 @@ func NewVm() *Vm {
}
func (vm *Vm) RunTransaction(tx *Transaction, cb TxCallback) {
- fmt.Printf(`
+ if Debug {
+ fmt.Printf(`
# processing Tx (%v)
# fee = %f, ops = %d, sender = %s, value = %d
-`, tx.addr, float32(tx.fee) / 1e8, len(tx.data), tx.sender, tx.value)
+ `, tx.addr, float32(tx.fee) / 1e8, len(tx.data), tx.sender, tx.value)
+ }
vm.stack = make(map[string]string)
vm.stack["0"] = tx.sender
@@ -102,7 +101,9 @@ out:
// XXX Should Instr return big int slice instead of string slice?
op, args, _ := Instr(tx.data[stPtr])
- fmt.Printf("%-3d %d %v\n", stPtr, op, args)
+ if Debug {
+ fmt.Printf("%-3d %d %v\n", stPtr, op, args)
+ }
opType := OpType(tNorm)
// Determine the op type (used for calculating fees by the block manager)
@@ -178,8 +179,7 @@ out:
stPtr++
} else {
stPtr = nptr
- fmt.Println("... JMP", nptr, "...")
+ if Debug { fmt.Println("... JMP", nptr, "...") }
}
}
- fmt.Println("# finished processing Tx\n")
}