forked from cerc-io/plugeth
Merge branch 'master' into readme
Conflicts: README.md
This commit is contained in:
commit
f4433a6804
@ -76,11 +76,11 @@ func (i *Console) ValidateInput(action string, argumentLength int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i *Console) PrintRoot() {
|
func (i *Console) PrintRoot() {
|
||||||
root := ethutil.Conv(i.trie.RootT)
|
root := ethutil.Conv(i.trie.Root)
|
||||||
if len(root.AsBytes()) != 0 {
|
if len(root.AsBytes()) != 0 {
|
||||||
fmt.Println(hex.EncodeToString(root.AsBytes()))
|
fmt.Println(hex.EncodeToString(root.AsBytes()))
|
||||||
} else {
|
} else {
|
||||||
fmt.Println(i.trie.RootT)
|
fmt.Println(i.trie.Root)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,15 +108,15 @@ func (i *Console) ParseInput(input string) bool {
|
|||||||
} else {
|
} else {
|
||||||
switch tokens[0] {
|
switch tokens[0] {
|
||||||
case "update":
|
case "update":
|
||||||
i.trie.UpdateT(tokens[1], tokens[2])
|
i.trie.Update(tokens[1], tokens[2])
|
||||||
|
|
||||||
i.PrintRoot()
|
i.PrintRoot()
|
||||||
case "get":
|
case "get":
|
||||||
fmt.Println(i.trie.GetT(tokens[1]))
|
fmt.Println(i.trie.Get(tokens[1]))
|
||||||
case "root":
|
case "root":
|
||||||
i.PrintRoot()
|
i.PrintRoot()
|
||||||
case "rawroot":
|
case "rawroot":
|
||||||
fmt.Println(i.trie.RootT)
|
fmt.Println(i.trie.Root)
|
||||||
case "print":
|
case "print":
|
||||||
i.db.Print()
|
i.db.Print()
|
||||||
case "dag":
|
case "dag":
|
||||||
@ -124,11 +124,11 @@ func (i *Console) ParseInput(input string) bool {
|
|||||||
ethutil.BigPow(2, 36), // diff
|
ethutil.BigPow(2, 36), // diff
|
||||||
ethutil.Big(tokens[2]))) // nonce
|
ethutil.Big(tokens[2]))) // nonce
|
||||||
case "decode":
|
case "decode":
|
||||||
d, _ := ethutil.Decode([]byte(tokens[1]), 0)
|
value := ethutil.NewRlpDecoder([]byte(tokens[1]))
|
||||||
fmt.Printf("%q\n", d)
|
fmt.Println(value)
|
||||||
case "getaddr":
|
case "getaddr":
|
||||||
encoded, _ := hex.DecodeString(tokens[1])
|
encoded, _ := hex.DecodeString(tokens[1])
|
||||||
d := i.ethereum.BlockManager.CurrentBlock.State().Get(string(encoded))
|
d := i.ethereum.BlockManager.BlockChain().CurrentBlock.State().Get(string(encoded))
|
||||||
if d != "" {
|
if d != "" {
|
||||||
decoder := ethutil.NewRlpDecoder([]byte(d))
|
decoder := ethutil.NewRlpDecoder([]byte(d))
|
||||||
fmt.Println(decoder)
|
fmt.Println(decoder)
|
||||||
|
46
ethereum.go
46
ethereum.go
@ -8,7 +8,6 @@ import (
|
|||||||
"github.com/ethereum/ethutil-go"
|
"github.com/ethereum/ethutil-go"
|
||||||
_ "github.com/ethereum/ethwire-go"
|
_ "github.com/ethereum/ethwire-go"
|
||||||
"log"
|
"log"
|
||||||
"math/big"
|
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path"
|
"path"
|
||||||
@ -84,31 +83,40 @@ func main() {
|
|||||||
ethereum.Start()
|
ethereum.Start()
|
||||||
|
|
||||||
if StartMining {
|
if StartMining {
|
||||||
blockTime := time.Duration(15)
|
blockTime := time.Duration(10)
|
||||||
log.Printf("Dev Test Mining started. Blocks found each %d seconds\n", blockTime)
|
log.Printf("Dev Test Mining started. Blocks found each %d seconds\n", blockTime)
|
||||||
|
|
||||||
// Fake block mining. It broadcasts a new block every 5 seconds
|
// Fake block mining. It broadcasts a new block every 5 seconds
|
||||||
go func() {
|
go func() {
|
||||||
|
pow := ðchain.EasyPow{}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
|
||||||
time.Sleep(blockTime * time.Second)
|
|
||||||
|
|
||||||
txs := ethereum.TxPool.Flush()
|
txs := ethereum.TxPool.Flush()
|
||||||
|
block := ethereum.BlockManager.BlockChain().NewBlock("82c3b0b72cf62f1a9ce97c64da8072efa28225d8", txs)
|
||||||
|
|
||||||
block := ethchain.CreateBlock(
|
nonce := pow.Search(block)
|
||||||
ethereum.BlockManager.CurrentBlock.State().Root,
|
block.Nonce = nonce
|
||||||
ethereum.BlockManager.LastBlockHash,
|
|
||||||
"123",
|
log.Println("nonce found:", nonce)
|
||||||
big.NewInt(1),
|
/*
|
||||||
big.NewInt(1),
|
time.Sleep(blockTime * time.Second)
|
||||||
"",
|
|
||||||
txs)
|
|
||||||
err := ethereum.BlockManager.ProcessBlockWithState(block, block.State())
|
block := ethchain.CreateBlock(
|
||||||
if err != nil {
|
ethereum.BlockManager.BlockChain().CurrentBlock.State().Root,
|
||||||
log.Println(err)
|
ethereum.BlockManager.BlockChain().LastBlockHash,
|
||||||
} else {
|
"123",
|
||||||
log.Println("\n+++++++ MINED BLK +++++++\n", block.String())
|
big.NewInt(1),
|
||||||
}
|
big.NewInt(1),
|
||||||
|
"",
|
||||||
|
txs)
|
||||||
|
err := ethereum.BlockManager.ProcessBlockWithState(block, block.State())
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
} else {
|
||||||
|
//log.Println("\n+++++++ MINED BLK +++++++\n", block.String())
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user