Begin handling of newly connected blocks.

Utxo and Tx stores are not updated yet as they aren't being created at
the moment.  Disconnected blocks are currently ignored.
This commit is contained in:
Josh Rickmar 2013-08-27 16:45:22 -04:00
parent ab623ec9e0
commit f5a151571d

View file

@ -22,6 +22,7 @@ import (
"errors"
"fmt"
"github.com/conformal/btcjson"
"github.com/conformal/btcwire"
"net/http"
"sync"
)
@ -268,6 +269,27 @@ func ProcessBtcdNotificationReply(b []byte) {
// btcd notification must either be handled by btcwallet or sent
// to all frontends if btcwallet can not handle it.
switch idStr {
case "btcd:blockconnected":
result := m["result"].(map[string]interface{})
hashResult := result["hash"].([]interface{})
hash := new(btcwire.ShaHash)
for i, _ := range hash[:] {
hash[i] = byte(hashResult[i].(float64))
}
height := int64(result["height"].(float64))
// TODO(jrick): update TxStore and UtxoStore with new hash
var id interface{} = "btcwallet:newblockchainheight"
m := &btcjson.Reply{
Result: height,
Id: &id,
}
msg, _ := json.Marshal(m)
frontendNotificationMaster <- msg
case "btcd:blockdisconnected":
// TODO(jrick): rollback txs and utxos from removed block.
default:
frontendNotificationMaster <- b
}