From: gguoss <1536310027@qq.com> Date: Thu, 7 Sep 2017 06:48:45 +0000 (+0800) Subject: Fixed a bug about assets memory not be alloc. X-Git-Tag: v1.0.5~470^2~22 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=eb74b5705442bef10fec2d7697c2c8729d57ec5c;p=bytom%2Fbytom.git Fixed a bug about assets memory not be alloc. --- diff --git a/blockchain/reactor.go b/blockchain/reactor.go index 97231d34..7d811047 100644 --- a/blockchain/reactor.go +++ b/blockchain/reactor.go @@ -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, diff --git a/cmd/bytomcli/main.go b/cmd/bytomcli/main.go index 09cfab59..7bb3d387 100644 --- a/cmd/bytomcli/main.go +++ b/cmd/bytomcli/main.go @@ -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] diff --git a/node/node.go b/node/node.go index 1abf552c..afd9e500 100644 --- a/node/node.go +++ b/node/node.go @@ -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