ID string `json:"id"`
Type string `json:"type"`
}) Response {
- token, err := bcr.accessTokens.Create(ctx, x.ID, x.Type)
+ token, err := bcr.wallet.Tokens.Create(ctx, x.ID, x.Type)
if err != nil {
return NewErrorResponse(err)
}
}
func (bcr *BlockchainReactor) listAccessTokens(ctx context.Context) Response {
- tokens, err := bcr.accessTokens.List(ctx)
+ tokens, err := bcr.wallet.Tokens.List(ctx)
if err != nil {
log.Errorf("listAccessTokens: %v", err)
return NewErrorResponse(err)
Token string `json:"token"`
}) Response {
//TODO Add delete permission verify.
- if err := bcr.accessTokens.Delete(ctx, x.ID); err != nil {
+ if err := bcr.wallet.Tokens.Delete(ctx, x.ID); err != nil {
return NewErrorResponse(err)
}
return NewSuccessResponse(nil)
ID string `json:"id"`
Secret string `json:"secret"`
}) Response {
- if _, err := bcr.accessTokens.Check(ctx, x.ID, x.Secret); err != nil {
+ if _, err := bcr.wallet.Tokens.Check(ctx, x.ID, x.Secret); err != nil {
return NewErrorResponse(err)
}
log "github.com/sirupsen/logrus"
cmn "github.com/tendermint/tmlibs/common"
- "github.com/bytom/blockchain/accesstoken"
"github.com/bytom/blockchain/txfeed"
"github.com/bytom/blockchain/wallet"
"github.com/bytom/mining/cpuminer"
chain *protocol.Chain
wallet *wallet.Wallet
- accessTokens *accesstoken.CredentialStore
txFeedTracker *txfeed.Tracker
blockKeeper *blockKeeper
txPool *protocol.TxPool
}
// NewBlockchainReactor returns the reactor of whole blockchain.
-func NewBlockchainReactor(chain *protocol.Chain, txPool *protocol.TxPool, sw *p2p.Switch,wallet *wallet.Wallet, txfeeds *txfeed.Tracker, accessTokens *accesstoken.CredentialStore, miningEnable bool) *BlockchainReactor {
+func NewBlockchainReactor(chain *protocol.Chain, txPool *protocol.TxPool, sw *p2p.Switch,wallet *wallet.Wallet, txfeeds *txfeed.Tracker, miningEnable bool) *BlockchainReactor {
newBlockCh := make(chan *bc.Hash, maxNewBlockChSize)
bcr := &BlockchainReactor{
chain: chain,
mux: http.NewServeMux(),
sw: sw,
txFeedTracker: txfeeds,
- accessTokens: accessTokens,
miningEnable: miningEnable,
newBlockCh: newBlockCh,
}
"github.com/tendermint/go-wire/data/base58"
"github.com/tendermint/tmlibs/db"
+ "github.com/bytom/blockchain/accesstoken"
"github.com/bytom/blockchain/account"
"github.com/bytom/blockchain/asset"
"github.com/bytom/blockchain/pseudohsm"
AccountMgr *account.Manager
AssetReg *asset.Registry
Hsm *pseudohsm.HSM
+ Tokens *accesstoken.CredentialStore
chain *protocol.Chain
rescanProgress chan struct{}
ImportPrivKey bool
//NewWallet return a new wallet instance
func NewWallet(walletDB db.DB, account *account.Manager, asset *asset.Registry, hsm *pseudohsm.HSM,
- chain *protocol.Chain) (*Wallet, error) {
+ accessTokens *accesstoken.CredentialStore, chain *protocol.Chain) (*Wallet, error) {
w := &Wallet{
DB: walletDB,
AccountMgr: account,
AssetReg: asset,
chain: chain,
Hsm: hsm,
+ Tokens: accessTokens,
rescanProgress: make(chan struct{}, 1),
keysInfo: make([]KeyInfo, 0),
}
t.Fatal(err)
}
- w, err := NewWallet(testDB, acntManager, reg, hsm, chain)
+ w, err := NewWallet(testDB, acntManager, reg, hsm, nil, chain)
if err != nil {
t.Fatal(err)
}
walletDB := dbm.NewDB("wallet", config.DBBackend, config.DBDir())
accounts = account.NewManager(walletDB, chain)
assets = asset.NewRegistry(walletDB, chain)
- wallet, err = w.NewWallet(walletDB, accounts, assets, hsm, chain)
+ wallet, err = w.NewWallet(walletDB, accounts, assets, hsm, accessTokens, chain)
if err != nil {
log.WithField("error", err).Error("init NewWallet")
}
go accounts.ExpireReservations(ctx, expireReservationsPeriod)
}
- bcReactor := bc.NewBlockchainReactor(chain, txPool,sw, wallet, txFeed, accessTokens, config.Mining)
+ bcReactor := bc.NewBlockchainReactor(chain, txPool,sw, wallet, txFeed, config.Mining)
sw.AddReactor("BLOCKCHAIN", bcReactor)