OSDN Git Service

Merge branch 'master' into demo
authorBlockmeta-区块元 <blockmeta@8btc.com>
Fri, 22 Sep 2017 07:46:08 +0000 (15:46 +0800)
committerGitHub <noreply@github.com>
Fri, 22 Sep 2017 07:46:08 +0000 (15:46 +0800)
1  2 
blockchain/hsm.go
blockchain/pseudohsm/pseudohsm.go
blockchain/reactor.go

@@@ -107,9 -108,8 +108,9 @@@ func RemoteHSM(hsm *remoteHSM) RunOptio
                api.mux.Handle("/hsm/sign-transaction", needConfig(h.Sign))
        }
  }
 +*/
  
- /*
  type remoteHSM struct {
        Client *rpc.Client
  }
@@@ -14,8 -14,7 +14,6 @@@ import 
        "github.com/bytom/errors"
        "github.com/bytom/crypto"
        //"bytom/protocol/bc/legacy"
-       //"github.com/bytom/blockchain/config"
 -      "github.com/bytom/blockchain/config"
        "github.com/pborman/uuid"
  )
  
@@@ -46,8 -45,8 +44,9 @@@ type XPub struct 
        File    string             `json:"file"`
  }
  
- func New(/*conf *config.Config*/) *HSM {
-       keydir, _ := filepath.Abs("~/.bytom")
++
+ func New(keypath string) (*HSM, error) {
+       keydir, _ := filepath.Abs(keypath)
        return &HSM{
                keyStore:   &keyStorePassphrase{keydir, LightScryptN, LightScryptP},
                cache:          newAddrCache(keydir),
@@@ -55,22 -60,35 +60,22 @@@ type hsmSigner interface 
  type BlockchainReactor struct {
        p2p.BaseReactor
  
-       chain       *protocol.Chain
-       store       *txdb.Store
-       accounts    *account.Manager
-       assets      *asset.Registry
-       txFeeds     *txfeed.TxFeed
-       pool        *BlockPool
-       txPool      *protocol.TxPool
-       mining      *cpuminer.CPUMiner
-       mux         *http.ServeMux
-       handler     http.Handler
-       fastSync    bool
-       requestsCh  chan BlockRequest
-       timeoutsCh  chan string
-       accesstoken *accesstoken.Token
-       submitter   txbuilder.Submitter
+       chain      *protocol.Chain
+       store      *txdb.Store
+       accounts   *account.Manager
+       assets     *asset.Registry
+       txFeeds    *txfeed.TxFeed
+       pool       *BlockPool
+       txPool     *protocol.TxPool
+       mining     *cpuminer.CPUMiner
+       mux        *http.ServeMux
+       handler    http.Handler
+       fastSync   bool
+       requestsCh chan BlockRequest
+       timeoutsCh chan string
+       submitter  txbuilder.Submitter
+       hsm                     hsmSigner
 -      chain       *protocol.Chain
 -      store       *txdb.Store
 -      accounts    *account.Manager
 -      assets      *asset.Registry
 -      txFeeds     *txfeed.TxFeed
 -      pool        *BlockPool
 -      mux         *http.ServeMux
 -      accesstoken *accesstoken.Token
 -
 -      fastSync    bool
 -      requestsCh  chan BlockRequest
 -      timeoutsCh  chan string
 -      submitter   txbuilder.Submitter
 -      evsw types.EventSwitch
 +      evsw        types.EventSwitch
  }
  
  func batchRecover(ctx context.Context, v *interface{}) {
@@@ -241,7 -271,7 +258,8 @@@ type page struct 
        LastPage bool         `json:"last_page"`
  }
  
- func NewBlockchainReactor(store *txdb.Store, chain *protocol.Chain, txPool *protocol.TxPool, accounts *account.Manager, assets *asset.Registry, fastSync bool) *BlockchainReactor {
 -func NewBlockchainReactor(store *txdb.Store, chain *protocol.Chain, accounts *account.Manager, assets *asset.Registry, hsm hsmSigner, fastSync bool) *BlockchainReactor {
++
++func NewBlockchainReactor(store *txdb.Store, chain *protocol.Chain, txPool *protocol.TxPool, accounts *account.Manager, assets *asset.Registry, hsm hsmSigner, fastSync bool) *BlockchainReactor {
        requestsCh := make(chan BlockRequest, defaultChannelCapacity)
        timeoutsCh := make(chan string, defaultChannelCapacity)
        pool := NewBlockPool(