OSDN Git Service

Fixed a bug about assets memory not be alloc.
authorgguoss <1536310027@qq.com>
Thu, 7 Sep 2017 06:48:45 +0000 (14:48 +0800)
committergguoss <1536310027@qq.com>
Thu, 7 Sep 2017 06:48:45 +0000 (14:48 +0800)
blockchain/reactor.go
cmd/bytomcli/main.go
node/node.go

index 97231d3..7d81104 100644 (file)
@@ -48,21 +48,10 @@ const (
        crosscoreRPCPrefix = "/rpc/"
 )
 
-/*
-type consensusReactor interface {
-       // for when we switch from blockchain reactor and fast sync to
-       // the consensus machine
-       SwitchToConsensus(*sm.State)
-}
-*/
-
 // BlockchainReactor handles long-term catchup syncing.
 type BlockchainReactor struct {
        p2p.BaseReactor
 
-//     state        *sm.State
-//     proxyAppConn proxy.AppConnConsensus // same as consensus.proxyAppConn
-//     store        *MemStore
        chain        *protocol.Chain
        store        *txdb.Store
        accounts         *account.Manager
@@ -75,7 +64,6 @@ type BlockchainReactor struct {
        requestsCh   chan BlockRequest
        timeoutsCh   chan string
        submitter    txbuilder.Submitter
-//     lastBlock    *types.Block
 
        evsw types.EventSwitch
 }
@@ -238,7 +226,7 @@ type page struct {
        LastPage bool         `json:"last_page"`
 }
 
-func NewBlockchainReactor(store *txdb.Store, chain *protocol.Chain, accounts *account.Manager, fastSync bool) *BlockchainReactor {
+func NewBlockchainReactor(store *txdb.Store, chain *protocol.Chain, accounts *account.Manager, assets *asset.Registry, fastSync bool) *BlockchainReactor {
     requestsCh    := make(chan BlockRequest, defaultChannelCapacity)
     timeoutsCh    := make(chan string, defaultChannelCapacity)
     pool := NewBlockPool(
@@ -250,6 +238,7 @@ func NewBlockchainReactor(store *txdb.Store, chain *protocol.Chain, accounts *ac
         chain:         chain,
         store:         store,
                accounts:      accounts,
+               assets:            assets,
         pool:          pool,
                mux:           http.NewServeMux(),
         fastSync:      fastSync,
index 09cfab5..7bb3d38 100644 (file)
@@ -311,7 +311,7 @@ func createAccount(client *rpc.Client, args []string) {
        var ins Ins
        ins.RootXPubs = []chainkd.XPub{xpub}
        ins.Quorum = 1
-       ins.Alias = "aa"
+       ins.Alias = "alice"
        ins.Tags = map[string]interface{}{"test_tag": "v0",}
        ins.ClientToken = args[0]
        responses := make([]interface{}, 50)
@@ -342,7 +342,7 @@ func createAsset(client *rpc.Client, args []string) {
        var ins Ins
        ins.RootXPubs = []chainkd.XPub{xpub}
        ins.Quorum = 1
-       ins.Alias = "aa"
+       ins.Alias = "bob"
        ins.Tags = map[string]interface{}{"test_tag": "v0",}
        ins.Definition = map[string]interface{}{"test_definition": "v0"}
        ins.ClientToken = args[0]
index 1abf552..afd9e50 100644 (file)
@@ -28,6 +28,7 @@ import (
        "github.com/bytom/blockchain/txdb"
        "github.com/bytom/net/http/reqid"
        "github.com/bytom/protocol"
+       "github.com/bytom/blockchain/asset"
        rpcserver "github.com/bytom/rpc/lib/server"
        //      "github.com/bytom/net/http/static"
        //      "github.com/bytom/generated/dashboard"
@@ -62,6 +63,7 @@ type Node struct {
        blockStore   *txdb.Store
        bcReactor    *bc.BlockchainReactor
        accounts     *account.Manager
+       assets       *asset.Registry
        rpcListeners []net.Listener // rpc servers
 }
 
@@ -209,7 +211,9 @@ func NewNode(config *cfg.Config, logger log.Logger) *Node {
 
        accounts_db := dbm.NewDB("account", config.DBBackend, config.DBDir())
        accounts := account.NewManager(accounts_db, chain)
-       bcReactor := bc.NewBlockchainReactor(store, chain, accounts, fastSync)
+       assets_db := dbm.NewDB("asset", config.DBBackend, config.DBDir())
+       assets := asset.NewRegistry(assets_db, chain)
+       bcReactor := bc.NewBlockchainReactor(store, chain, accounts, assets, fastSync)
        bcReactor.SetLogger(logger.With("module", "blockchain"))
        sw.AddReactor("BLOCKCHAIN", bcReactor)
 
@@ -248,6 +252,7 @@ func NewNode(config *cfg.Config, logger log.Logger) *Node {
                bcReactor:  bcReactor,
                blockStore: store,
                accounts:   accounts,
+               assets:     assets,
        }
        node.BaseService = *cmn.NewBaseService(logger, "Node", node)
        return node