Skip to content

Commit 35fe431

Browse files
committed
pre-pow
1 parent 7e6b72c commit 35fe431

5 files changed

Lines changed: 50 additions & 2 deletions

File tree

‎core/chain_manager_test.go‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,21 @@ func TestChainMultipleInsertions(t *testing.T) {
128128
t.Error("Invalid canonical chain")
129129
}
130130
}
131+
132+
func TestGetAncestors(t *testing.T) {
133+
db, _ := ethdb.NewMemDatabase()
134+
var eventMux event.TypeMux
135+
chainMan := NewChainManager(db, &eventMux)
136+
chain, err := loadChain("valid1", t)
137+
if err != nil {
138+
fmt.Println(err)
139+
t.FailNow()
140+
}
141+
142+
for _, block := range chain {
143+
chainMan.write(block)
144+
}
145+
146+
ancestors := chainMan.GetAncestors(chain[len(chain)-1], 4)
147+
fmt.Println(ancestors)
148+
}

‎crypto/crypto_test.go‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package crypto
33
import (
44
"bytes"
55
"encoding/hex"
6+
"fmt"
67
"testing"
8+
"time"
79
)
810

911
// These tests are sanity checks.
@@ -34,3 +36,14 @@ func checkhash(t *testing.T, name string, f func([]byte) []byte, msg, exp []byte
3436
t.Errorf("hash %s returned wrong result.\ngot: %x\nwant: %x", name, sum, exp)
3537
}
3638
}
39+
40+
func BenchmarkSha3(b *testing.B) {
41+
a := []byte("hello world")
42+
amount := 1000000
43+
start := time.Now()
44+
for i := 0; i < amount; i++ {
45+
Sha3(a)
46+
}
47+
48+
fmt.Println(amount, ":", time.Since(start))
49+
}

‎event/filter/old_filter.go‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
package filter
33

44
import (
5-
"fmt"
65
"sync"
76

87
"github.com/ethereum/go-ethereum/core"
@@ -79,7 +78,6 @@ out:
7978
self.filterMu.RUnlock()
8079

8180
case state.Messages:
82-
fmt.Println("got messages")
8381
self.filterMu.RLock()
8482
for _, filter := range self.filters {
8583
if filter.MessageCallback != nil {

‎pow/dash/crypto.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
extern char *Sha3(char *, int);
2+
char *sha3_cgo(char *data, int l)
3+
{
4+
return Sha3(data, l);
5+
}

‎pow/dash/crypto.go‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package dash
2+
3+
/*
4+
char *sha3_cgo(char *, int); // Forward declaration
5+
*/
6+
import "C"
7+
import (
8+
"github.com/ethereum/go-ethereum/crypto"
9+
)
10+
11+
//export Sha3
12+
func Sha3(data []byte, l int) []byte {
13+
return crypto.Sha3(data)
14+
}

0 commit comments

Comments
 (0)