OSDN Git Service

Removed some about pg data.
authorgguoss <1536310027@qq.com>
Fri, 11 Aug 2017 03:58:11 +0000 (11:58 +0800)
committergguoss <1536310027@qq.com>
Fri, 11 Aug 2017 03:58:11 +0000 (11:58 +0800)
blockchain/account/accounts.go
blockchain/account/annotate.go
blockchain/account/builder.go
blockchain/account/indexer.go
blockchain/signers/signers.go

index 89f9e07..91711ba 100644 (file)
@@ -203,7 +203,7 @@ func (m *Manager) Create(ctx context.Context, xpubs []chainkd.XPub, quorum int,
 */
 
 // FindByAlias retrieves an account's Signer record by its alias
-func (m *Manager) FindByAlias(/*ctx context.Context,*/ alias string) (*signers.Signer, error) {
+func (m *Manager) FindByAlias(ctx context.Context, alias string) (*signers.Signer, error) {
        var accountID string
 
        m.cacheMu.Lock()
@@ -230,14 +230,14 @@ func (m *Manager) FindByAlias(/*ctx context.Context,*/ alias string) (*signers.S
 }
 
 // findByID returns an account's Signer record by its ID.
-func (m *Manager) findByID(/*ctx context.Context, */id string) (*signers.Signer, error) {
+func (m *Manager) findByID(ctx context.Context, id string) (*signers.Signer, error) {
        m.cacheMu.Lock()
        cached, ok := m.cache.Get(id)
        m.cacheMu.Unlock()
        if ok {
                return cached.(*signers.Signer), nil
        }
-       account, err := signers.Find(/*ctx, */m.db, "account", id)
+       account, err := signers.Find(ctx, m.db, "account", id)
        if err != nil {
                return nil, err
        }
@@ -255,13 +255,13 @@ type controlProgram struct {
        expiresAt      time.Time
 }
 
-func (m *Manager) createControlProgram(/*ctx context.Context,*/ accountID string, change bool, expiresAt time.Time) (*controlProgram, error) {
-       account, err := m.findByID(/*ctx,*/ accountID)
+func (m *Manager) createControlProgram(ctx context.Context, accountID string, change bool, expiresAt time.Time) (*controlProgram, error) {
+       account, err := m.findByID(ctx, accountID)
        if err != nil {
                return nil, err
        }
 
-       idx, err := m.nextIndex(/*ctx*/)
+       idx, err := m.nextIndex(ctx)
        if err != nil {
                return nil, err
        }
@@ -284,15 +284,15 @@ func (m *Manager) createControlProgram(/*ctx context.Context,*/ accountID string
 
 // CreateControlProgram creates a control program
 // that is tied to the Account and stores it in the database.
-func (m *Manager) CreateControlProgram(/*ctx context.Context,*/ accountID string, change bool, expiresAt time.Time) ([]byte, error) {
-       cp, err := m.createControlProgram(/*ctx,*/ accountID, change, expiresAt)
+func (m *Manager) CreateControlProgram(ctx context.Context, accountID string, change bool, expiresAt time.Time) ([]byte, error) {
+       cp, err := m.createControlProgram(ctx, accountID, change, expiresAt)
        if err != nil {
                return nil, err
        }
-       err = m.insertAccountControlProgram(/*ctx,*/ cp)
+       /*err = m.insertAccountControlProgram(ctx, cp)
        if err != nil {
                return nil, err
-       }
+       }*/
        return cp.controlProgram, nil
 }
 
@@ -326,7 +326,7 @@ func (m *Manager) insertAccountControlProgram(ctx context.Context, progs ...*con
 }
 */
 
-func (m *Manager) nextIndex(/*ctx context.Context*/) (uint64, error) {
+func (m *Manager) nextIndex(ctx context.Context) (uint64, error) {
        m.acpMu.Lock()
        defer m.acpMu.Unlock()
 
index 73c079f..a8fc04c 100644 (file)
@@ -2,7 +2,7 @@ package account
 
 import (
        "context"
-       "database/sql"
+//     "database/sql"
        "encoding/json"
 
 //     "github.com/lib/pq"
@@ -44,7 +44,7 @@ func (m *Manager) AnnotateTxs(ctx context.Context, txs []*query.AnnotatedTx) err
 
        // Look up all of the spent and created outputs. If any of them are
        // account UTXOs add the account annotations to the inputs and outputs.
-       const q = `
+       /*const q = `
                SELECT o.output_id, o.account_id, a.alias, a.tags, o.change
                FROM account_utxos o
                LEFT JOIN accounts a ON o.account_id = a.account_id
@@ -82,6 +82,6 @@ func (m *Manager) AnnotateTxs(ctx context.Context, txs []*query.AnnotatedTx) err
                                        out.Purpose = "receive"
                                }
                        }
-               })
-       return errors.Wrap(err, "annotating with account data")
+               }) */
+       return errors.Wrap(nil, "annotating with account data")
 }
index 55e9729..03ad10c 100644 (file)
@@ -231,6 +231,6 @@ func (m *Manager) insertControlProgramDelayed(ctx context.Context, b *txbuilder.
                if len(acps) == 0 {
                        return nil
                }
-               return m.insertAccountControlProgram(ctx, acps...)
+       //      return m.insertAccountControlProgram(ctx, acps...)
        })
 }
index 54ad654..c41003d 100644 (file)
@@ -99,7 +99,7 @@ type accountOutput struct {
 }
 
 func (m *Manager) ProcessBlocks(ctx context.Context) {
-       if m.pinStore == nil {
+       /*if m.pinStore == nil {
                return
        }
        go m.pinStore.ProcessBlocks(ctx, m.chain, ExpirePinName, func(ctx context.Context, b *legacy.Block) error {
@@ -112,8 +112,10 @@ func (m *Manager) ProcessBlocks(ctx context.Context) {
                return m.deleteSpentOutputs(ctx, b)
        })
        m.pinStore.ProcessBlocks(ctx, m.chain, PinName, m.indexAccountUTXOs)
+    */
 }
 
+/*
 func (m *Manager) expireControlPrograms(ctx context.Context, b *legacy.Block) error {
        // Delete expired account control programs.
        const deleteQ = `DELETE FROM account_control_programs WHERE expires_at IS NOT NULL AND expires_at < $1`
@@ -131,6 +133,7 @@ func (m *Manager) deleteSpentOutputs(ctx context.Context, b *legacy.Block) error
        _, err := m.db.ExecContext(ctx, delQ, delOutputIDs)
        return errors.Wrap(err, "deleting spent account utxos")
 }
+*/
 
 func (m *Manager) indexAccountUTXOs(ctx context.Context, b *legacy.Block) error {
        // Upsert any UTXOs belonging to accounts managed by this Core.
@@ -166,6 +169,7 @@ func (m *Manager) indexAccountUTXOs(ctx context.Context, b *legacy.Block) error
        return errors.Wrap(err, "upserting confirmed account utxos")
 }
 
+/*
 func prevoutDBKeys(txs ...*legacy.Tx) (outputIDs pq.ByteaArray) {
        for _, tx := range txs {
                for _, inpID := range tx.Tx.InputIDs {
@@ -176,6 +180,7 @@ func prevoutDBKeys(txs ...*legacy.Tx) (outputIDs pq.ByteaArray) {
        }
        return
 }
+*/
 
 // loadAccountInfo turns a set of output IDs into a set of
 // outputs by adding account annotations.  Outputs that can't be
@@ -187,13 +192,15 @@ func (m *Manager) loadAccountInfo(ctx context.Context, outs []*rawOutput) ([]*ac
                outsByScript[scriptStr] = append(outsByScript[scriptStr], out)
        }
 
-       var scripts pq.ByteaArray
+       /*var scripts pq.ByteaArray
        for s := range outsByScript {
                scripts = append(scripts, []byte(s))
        }
+    */
 
        result := make([]*accountOutput, 0, len(outs))
 
+/*
        const q = `
                SELECT signer_id, key_index, control_program, change
                FROM account_control_programs
@@ -213,6 +220,7 @@ func (m *Manager) loadAccountInfo(ctx context.Context, outs []*rawOutput) ([]*ac
        if err != nil {
                return nil, err
        }
+    */
 
        return result, nil
 }
index cebc186..865c857 100644 (file)
@@ -178,19 +178,22 @@ func findByClientToken(ctx context.Context, db pg.DB, clientToken string) (*Sign
 
        return &s, nil
 }
+*/
 
 // Find retrieves a Signer from the database
 // using the type and id.
-func Find(ctx context.Context, db pg.DB, typ, id string) (*Signer, error) {
-       const q = `
+func Find(ctx context.Context, db dbm.DB, typ, id string) (*Signer, error) {
+       /*const q = `
                SELECT id, type, xpubs, quorum, key_index
                FROM signers WHERE id=$1
        `
+    */
 
        var (
                s         Signer
                xpubBytes [][]byte
        )
+    /*
        err := db.QueryRowContext(ctx, q, id).Scan(
                &s.ID,
                &s.Type,
@@ -207,7 +210,7 @@ func Find(ctx context.Context, db pg.DB, typ, id string) (*Signer, error) {
 
        if s.Type != typ {
                return nil, errors.Wrap(ErrBadType)
-       }
+       }*/
 
        keys, err := ConvertKeys(xpubBytes)
        if err != nil {
@@ -219,6 +222,7 @@ func Find(ctx context.Context, db pg.DB, typ, id string) (*Signer, error) {
        return &s, nil
 }
 
+/*
 // List returns a paginated set of Signers, limited to
 // the provided type.
 func List(ctx context.Context, db pg.DB, typ, prev string, limit int) ([]*Signer, string, error) {