aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-01-12 17:19:27 +0800
committerobscuren <geffobscura@gmail.com>2015-01-12 17:19:27 +0800
commit35fe4313d57e1df6c3c8af0bc0b530bd7033e21b (patch)
treeed6b22ac3691315d0f208856bc8070bc1f5896a3
parent7e6b72cb5c0172b8a6a15239a6628b64c8f8de23 (diff)
downloaddexon-35fe4313d57e1df6c3c8af0bc0b530bd7033e21b.tar
dexon-35fe4313d57e1df6c3c8af0bc0b530bd7033e21b.tar.gz
dexon-35fe4313d57e1df6c3c8af0bc0b530bd7033e21b.tar.bz2
dexon-35fe4313d57e1df6c3c8af0bc0b530bd7033e21b.tar.lz
dexon-35fe4313d57e1df6c3c8af0bc0b530bd7033e21b.tar.xz
dexon-35fe4313d57e1df6c3c8af0bc0b530bd7033e21b.tar.zst
dexon-35fe4313d57e1df6c3c8af0bc0b530bd7033e21b.zip
pre-pow
-rw-r--r--core/chain_manager_test.go18
-rw-r--r--crypto/crypto_test.go13
-rw-r--r--event/filter/old_filter.go2
-rw-r--r--pow/dash/crypto.c5
-rw-r--r--pow/dash/crypto.go14
5 files changed, 50 insertions, 2 deletions
diff --git a/core/chain_manager_test.go b/core/chain_manager_test.go
index 725352daf..f382516b7 100644
--- a/core/chain_manager_test.go
+++ b/core/chain_manager_test.go
@@ -128,3 +128,21 @@ func TestChainMultipleInsertions(t *testing.T) {
t.Error("Invalid canonical chain")
}
}
+
+func TestGetAncestors(t *testing.T) {
+ db, _ := ethdb.NewMemDatabase()
+ var eventMux event.TypeMux
+ chainMan := NewChainManager(db, &eventMux)
+ chain, err := loadChain("valid1", t)
+ if err != nil {
+ fmt.Println(err)
+ t.FailNow()
+ }
+
+ for _, block := range chain {
+ chainMan.write(block)
+ }
+
+ ancestors := chainMan.GetAncestors(chain[len(chain)-1], 4)
+ fmt.Println(ancestors)
+}
diff --git a/crypto/crypto_test.go b/crypto/crypto_test.go
index af62a02a2..b579e6e4e 100644
--- a/crypto/crypto_test.go
+++ b/crypto/crypto_test.go
@@ -3,7 +3,9 @@ package crypto
import (
"bytes"
"encoding/hex"
+ "fmt"
"testing"
+ "time"
)
// These tests are sanity checks.
@@ -34,3 +36,14 @@ func checkhash(t *testing.T, name string, f func([]byte) []byte, msg, exp []byte
t.Errorf("hash %s returned wrong result.\ngot: %x\nwant: %x", name, sum, exp)
}
}
+
+func BenchmarkSha3(b *testing.B) {
+ a := []byte("hello world")
+ amount := 1000000
+ start := time.Now()
+ for i := 0; i < amount; i++ {
+ Sha3(a)
+ }
+
+ fmt.Println(amount, ":", time.Since(start))
+}
diff --git a/event/filter/old_filter.go b/event/filter/old_filter.go
index 6c7f053d4..1a9a88173 100644
--- a/event/filter/old_filter.go
+++ b/event/filter/old_filter.go
@@ -2,7 +2,6 @@
package filter
import (
- "fmt"
"sync"
"github.com/ethereum/go-ethereum/core"
@@ -79,7 +78,6 @@ out:
self.filterMu.RUnlock()
case state.Messages:
- fmt.Println("got messages")
self.filterMu.RLock()
for _, filter := range self.filters {
if filter.MessageCallback != nil {
diff --git a/pow/dash/crypto.c b/pow/dash/crypto.c
new file mode 100644
index 000000000..9c5a62d16
--- /dev/null
+++ b/pow/dash/crypto.c
@@ -0,0 +1,5 @@
+extern char *Sha3(char *, int);
+char *sha3_cgo(char *data, int l)
+{
+ return Sha3(data, l);
+}
diff --git a/pow/dash/crypto.go b/pow/dash/crypto.go
new file mode 100644
index 000000000..0644a54ae
--- /dev/null
+++ b/pow/dash/crypto.go
@@ -0,0 +1,14 @@
+package dash
+
+/*
+char *sha3_cgo(char *, int); // Forward declaration
+*/
+import "C"
+import (
+ "github.com/ethereum/go-ethereum/crypto"
+)
+
+//export Sha3
+func Sha3(data []byte, l int) []byte {
+ return crypto.Sha3(data)
+}