Moved qml files, conform to the new server model.

QML files got moved to their own directories. QML now has a ui helper
which should find assets in the correct resource directory
pull/27/head
obscuren 11 years ago
parent 833a1a4eab
commit 8275059856
  1. 15
      ethereum.go
  2. 0
      qml/test_app.qml
  3. 0
      qml/transactions.qml
  4. 10
      qml/wallet.qml
  5. 29
      ui/gui.go

@ -144,7 +144,7 @@ func main() {
} }
if ShowGenesis { if ShowGenesis {
fmt.Println(ethereum.BlockManager.BlockChain().Genesis()) fmt.Println(ethereum.BlockChain().Genesis())
os.Exit(0) os.Exit(0)
} }
@ -183,23 +183,24 @@ func main() {
addr := keyRing.Get(1).Bytes() addr := keyRing.Get(1).Bytes()
for { for {
txs := ethereum.TxPool.Flush() txs := ethereum.TxPool().Flush()
// Create a new block which we're going to mine // Create a new block which we're going to mine
block := ethereum.BlockManager.BlockChain().NewBlock(addr, txs) block := ethereum.BlockChain().NewBlock(addr, txs)
log.Println("Mining on new block. Includes", len(block.Transactions()), "transactions") log.Println("Mining on new block. Includes", len(block.Transactions()), "transactions")
// Apply all transactions to the block // Apply all transactions to the block
ethereum.BlockManager.ApplyTransactions(block, block.Transactions()) ethereum.StateManager().ApplyTransactions(block, block.Transactions())
ethereum.BlockManager.AccumelateRewards(block, block) ethereum.StateManager().AccumelateRewards(block, block)
// Search the nonce // Search the nonce
block.Nonce = pow.Search(block) block.Nonce = pow.Search(block)
ethereum.Broadcast(ethwire.MsgBlockTy, []interface{}{block.Value().Val}) ethereum.Broadcast(ethwire.MsgBlockTy, []interface{}{block.Value().Val})
err := ethereum.BlockManager.ProcessBlock(block) err := ethereum.StateManager().ProcessBlock(block)
if err != nil { if err != nil {
log.Println(err) log.Println(err)
} else { } else {
log.Println("\n+++++++ MINED BLK +++++++\n", ethereum.BlockManager.BlockChain().CurrentBlock) //log.Println("\n+++++++ MINED BLK +++++++\n", ethereum.BlockChain().CurrentBlock)
log.Printf("🔨 Mined block %x\n", block.Hash())
} }
} }
}() }()

@ -85,7 +85,7 @@ ApplicationWindow {
anchors.right: parent.right anchors.right: parent.right
height: 200 height: 200
Image { Image {
source: "tx.png" source: ui.assetPath("tx.png")
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
@ -95,7 +95,7 @@ ApplicationWindow {
} }
} }
Image { Image {
source: "new.png" source: ui.assetPath("new.png")
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
@ -105,7 +105,7 @@ ApplicationWindow {
} }
} }
Image { Image {
source: "net.png" source: ui.assetPath("net.png")
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
@ -300,7 +300,7 @@ ApplicationWindow {
id: peerImage id: peerImage
anchors.right: parent.right anchors.right: parent.right
width: 10; height: 10 width: 10; height: 10
source: "network.png" source: ui.assetPath("network.png")
} }
} }
} }
@ -365,7 +365,7 @@ ApplicationWindow {
width: 150 width: 150
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
smooth: true smooth: true
source: "facet.png" source: ui.assetPath("facet.png")
x: 10 x: 10
y: 10 y: 10
} }

@ -57,7 +57,7 @@ type Gui struct {
// Create GUI, but doesn't start it // Create GUI, but doesn't start it
func New(ethereum *eth.Ethereum) *Gui { func New(ethereum *eth.Ethereum) *Gui {
lib := &EthLib{blockManager: ethereum.BlockManager, blockChain: ethereum.BlockManager.BlockChain(), txPool: ethereum.TxPool} lib := &EthLib{blockManager: ethereum.StateManager(), blockChain: ethereum.BlockChain(), txPool: ethereum.TxPool()}
db, err := ethdb.NewLDBDatabase("tx_database") db, err := ethdb.NewLDBDatabase("tx_database")
if err != nil { if err != nil {
panic(err) panic(err)
@ -66,7 +66,7 @@ func New(ethereum *eth.Ethereum) *Gui {
key := ethutil.Config.Db.GetKeys()[0] key := ethutil.Config.Db.GetKeys()[0]
addr := key.Address() addr := key.Address()
ethereum.BlockManager.WatchAddr(addr) ethereum.StateManager().WatchAddr(addr)
return &Gui{eth: ethereum, lib: lib, txDb: db, addr: addr} return &Gui{eth: ethereum, lib: lib, txDb: db, addr: addr}
} }
@ -84,24 +84,23 @@ func (ui *Gui) Start() {
ethutil.Config.Log.Infoln("[GUI] Starting GUI") ethutil.Config.Log.Infoln("[GUI] Starting GUI")
// Create a new QML engine // Create a new QML engine
ui.engine = qml.NewEngine() ui.engine = qml.NewEngine()
context := ui.engine.Context()
// Expose the eth library and the ui library to QML
context.SetVar("eth", ui.lib)
context.SetVar("ui", &UiLib{engine: ui.engine, eth: ui.eth})
// Load the main QML interface // Load the main QML interface
component, err := ui.engine.LoadFile(AssetPath("wallet.qml")) component, err := ui.engine.LoadFile(AssetPath("qml/wallet.qml"))
if err != nil { if err != nil {
panic(err) panic(err)
} }
ui.engine.LoadFile(AssetPath("transactions.qml")) ui.engine.LoadFile(AssetPath("qml/transactions.qml"))
ui.win = component.CreateWindow(nil) ui.win = component.CreateWindow(nil)
context := ui.engine.Context()
// Expose the eth library and the ui library to QML
context.SetVar("eth", ui.lib)
context.SetVar("ui", &UiLib{engine: ui.engine, eth: ui.eth})
// Register the ui as a block processor // Register the ui as a block processor
ui.eth.BlockManager.SecondaryBlockProcessor = ui //ui.eth.BlockManager.SecondaryBlockProcessor = ui
//ui.eth.TxPool.SecondaryProcessor = ui //ui.eth.TxPool.SecondaryProcessor = ui
// Add the ui as a log system so we can log directly to the UGI // Add the ui as a log system so we can log directly to the UGI
@ -120,7 +119,7 @@ func (ui *Gui) Start() {
func (ui *Gui) setInitialBlockChain() { func (ui *Gui) setInitialBlockChain() {
// Load previous 10 blocks // Load previous 10 blocks
chain := ui.eth.BlockManager.BlockChain().GetChain(ui.eth.BlockManager.BlockChain().CurrentBlock.Hash(), 10) chain := ui.eth.BlockChain().GetChain(ui.eth.BlockChain().CurrentBlock.Hash(), 10)
for _, block := range chain { for _, block := range chain {
ui.ProcessBlock(block) ui.ProcessBlock(block)
} }
@ -144,9 +143,9 @@ func (ui *Gui) ProcessBlock(block *ethchain.Block) {
// Simple go routine function that updates the list of peers in the GUI // Simple go routine function that updates the list of peers in the GUI
func (ui *Gui) update() { func (ui *Gui) update() {
txChan := make(chan ethchain.TxMsg, 1) txChan := make(chan ethchain.TxMsg, 1)
ui.eth.TxPool.Subscribe(txChan) ui.eth.TxPool().Subscribe(txChan)
account := ui.eth.BlockManager.GetAddrState(ui.addr).Account account := ui.eth.StateManager().GetAddrState(ui.addr).Account
unconfirmedFunds := new(big.Int) unconfirmedFunds := new(big.Int)
ui.win.Root().Call("setWalletValue", fmt.Sprintf("%v", ethutil.CurrencyToString(account.Amount))) ui.win.Root().Call("setWalletValue", fmt.Sprintf("%v", ethutil.CurrencyToString(account.Amount)))
for { for {
@ -159,7 +158,7 @@ func (ui *Gui) update() {
ui.win.Root().Call("addTx", NewTxFromTransaction(tx)) ui.win.Root().Call("addTx", NewTxFromTransaction(tx))
ui.txDb.Put(tx.Hash(), tx.RlpEncode()) ui.txDb.Put(tx.Hash(), tx.RlpEncode())
ui.eth.BlockManager.GetAddrState(ui.addr).Nonce += 1 ui.eth.StateManager().GetAddrState(ui.addr).Nonce += 1
unconfirmedFunds.Sub(unconfirmedFunds, tx.Value) unconfirmedFunds.Sub(unconfirmedFunds, tx.Value)
} else if bytes.Compare(tx.Recipient, ui.addr) == 0 { } else if bytes.Compare(tx.Recipient, ui.addr) == 0 {
ui.win.Root().Call("addTx", NewTxFromTransaction(tx)) ui.win.Root().Call("addTx", NewTxFromTransaction(tx))

Loading…
Cancel
Save