aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md4
-rw-r--r--ethchain/keypair.go74
-rw-r--r--ethchain/state_manager.go3
-rw-r--r--ethutil/trie.go12
4 files changed, 78 insertions, 15 deletions
diff --git a/README.md b/README.md
index f6c49cc2d..3553a5e35 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@ Ethereum
Ethereum Go Development package (C) Jeffrey Wilcke
Ethereum is currently in its testing phase. The current state is "Proof
-of Concept 2". For build instructions see the [Wiki](https://github.com/ethereum/go-ethereum/wiki/Building-Edge).
+of Concept 3". For build instructions see the [Wiki](https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum(Go)).
Ethereum Go is split up in several sub packages Please refer to each
individual package for more information.
@@ -35,7 +35,7 @@ get a node and connectivity going.
Build
=======
-This is the Developer package. For the development client please see
+This is the Developer package. For the Ethereal client please see
[Ethereum(G)](https://github.com/ethereum/go-ethereum).
`go get -u github.com/ethereum/eth-go`
diff --git a/ethchain/keypair.go b/ethchain/keypair.go
new file mode 100644
index 000000000..9fdc95972
--- /dev/null
+++ b/ethchain/keypair.go
@@ -0,0 +1,74 @@
+package ethchain
+
+import (
+ "github.com/ethereum/eth-go/ethutil"
+ "math/big"
+)
+
+type KeyPair struct {
+ PrivateKey []byte
+ PublicKey []byte
+
+ // The associated account
+ account *Account
+ state *State
+}
+
+func NewKeyPairFromValue(val *ethutil.Value) *KeyPair {
+ keyPair := &KeyPair{PrivateKey: val.Get(0).Bytes(), PublicKey: val.Get(1).Bytes()}
+
+ return keyPair
+}
+
+func (k *KeyPair) Address() []byte {
+ return ethutil.Sha3Bin(k.PublicKey[1:])[12:]
+}
+
+func (k *KeyPair) Account() *Account {
+ if k.account == nil {
+ k.account = k.state.GetAccount(k.Address())
+ }
+
+ return k.account
+}
+
+// Create transaction, creates a new and signed transaction, ready for processing
+func (k *KeyPair) CreateTx(receiver []byte, value *big.Int, data []string) *Transaction {
+ tx := NewTransaction(receiver, value, data)
+ tx.Nonce = k.account.Nonce
+
+ // Sign the transaction with the private key in this key chain
+ tx.Sign(k.PrivateKey)
+
+ return tx
+}
+
+func (k *KeyPair) RlpEncode() []byte {
+ return ethutil.EmptyValue().Append(k.PrivateKey).Append(k.PublicKey).Encode()
+}
+
+type KeyRing struct {
+ keys []*KeyPair
+}
+
+func (k *KeyRing) Add(pair *KeyPair) {
+ k.keys = append(k.keys, pair)
+}
+
+// The public "singleton" keyring
+var keyRing *KeyRing
+
+func GetKeyRing(state *State) *KeyRing {
+ if keyRing == nil {
+ keyRing = &KeyRing{}
+
+ data, _ := ethutil.Config.Db.Get([]byte("KeyRing"))
+ it := ethutil.NewValueFromBytes(data).NewIterator()
+ for it.Next() {
+ v := it.Value()
+ keyRing.Add(NewKeyPairFromValue(v))
+ }
+ }
+
+ return keyRing
+}
diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go
index 7085146df..0923b017e 100644
--- a/ethchain/state_manager.go
+++ b/ethchain/state_manager.go
@@ -21,7 +21,6 @@ type EthManager interface {
Broadcast(msgType ethwire.MsgType, data []interface{})
}
-// TODO rename to state manager
type StateManager struct {
// Mutex for locking the block processor. Blocks can only be handled one at a time
mutex sync.Mutex
@@ -50,6 +49,8 @@ type StateManager struct {
// Comparative state it used for comparing and validating end
// results
compState *State
+
+ miningState *State
}
func NewStateManager(ethereum EthManager) *StateManager {
diff --git a/ethutil/trie.go b/ethutil/trie.go
index a17dc37ad..c67f750bc 100644
--- a/ethutil/trie.go
+++ b/ethutil/trie.go
@@ -220,18 +220,6 @@ func (t *Trie) UpdateState(node interface{}, key []int, value string) interface{
func (t *Trie) Put(node interface{}) interface{} {
/*
- enc := Encode(node)
- if len(enc) >= 32 {
- var sha []byte
- sha = Sha3Bin(enc)
- //t.db.Put([]byte(sha), enc)
-
- return sha
- }
- return node
- */
-
- /*
TODO?
c := Conv(t.Root)
fmt.Println(c.Type(), c.Length())