OSDN Git Service

delete unnecessary log (#424)
authoroysheng <33340252+oysheng@users.noreply.github.com>
Wed, 14 Mar 2018 07:58:39 +0000 (15:58 +0800)
committerPaladz <yzhu101@uottawa.ca>
Wed, 14 Mar 2018 07:58:39 +0000 (15:58 +0800)
* standard transaction reserve utxo filter out contract utxo

* distinguish StandardUTXO and ContractUTXO
modfiy spendUTXOAction into no account, the contract utxo is not need to sign
wallet add contract utxo db
adjust function parameter format: the end of parameter is error

* delete ExtContractTag because contract utxo is stored in ContractUTXO

* spendUTXOAction add situation when account is empty
prevoutDBKeys delete return value
filterAccountTxs filter contract transaction to reduce unrelated transaction

* fix golint for blockchain/account/reserve.go

* optimise the import

* adjust format for golint

* adjust format

* add the function illustration

* delete unnecessary log

blockchain/net.go
blockchain/request.go
blockchain/tls.go
blockchain/txbuilder/builder.go
blockchain/txbuilder/data_witness.go
blockchain/txbuilder/finalize.go
blockchain/txbuilder/signing_instruction.go
blockchain/txbuilder/types.go
blockchain/wallet/indexer.go

index 709723a..dde1f49 100644 (file)
@@ -12,10 +12,15 @@ import (
 )
 
 const (
-       BlockRequestByte   = byte(0x10)
-       BlockResponseByte  = byte(0x11)
-       StatusRequestByte  = byte(0x20)
+       // BlockRequestByte means block request message
+       BlockRequestByte = byte(0x10)
+       // BlockResponseByte means block response message
+       BlockResponseByte = byte(0x11)
+       // StatusRequestByte means status request message
+       StatusRequestByte = byte(0x20)
+       // StatusResponseByte means status response message
        StatusResponseByte = byte(0x21)
+       // NewTransactionByte means transaction notify message
        NewTransactionByte = byte(0x30)
 )
 
@@ -31,6 +36,7 @@ var _ = wire.RegisterInterface(
        wire.ConcreteType{&TransactionNotifyMessage{}, NewTransactionByte},
 )
 
+// DecodeMessage decode receive messages
 func DecodeMessage(bz []byte) (msgType byte, msg BlockchainMessage, err error) {
        msgType = bz[0]
        n := int(0)
@@ -42,11 +48,13 @@ func DecodeMessage(bz []byte) (msgType byte, msg BlockchainMessage, err error) {
        return
 }
 
+// BlockRequestMessage is block request message struct
 type BlockRequestMessage struct {
        Height  uint64
        RawHash [32]byte
 }
 
+// GetHash return block hash
 func (m *BlockRequestMessage) GetHash() *bc.Hash {
        hash := bc.NewHash(m.RawHash)
        return &hash
@@ -60,10 +68,12 @@ func (m *BlockRequestMessage) String() string {
        return fmt.Sprintf("BlockRequestMessage{Hash: %s}", hash.String())
 }
 
+// BlockResponseMessage is block response message struct
 type BlockResponseMessage struct {
        RawBlock []byte
 }
 
+// NewBlockResponseMessage produce new BlockResponseMessage instance
 func NewBlockResponseMessage(block *legacy.Block) (*BlockResponseMessage, error) {
        rawBlock, err := block.MarshalText()
        if err != nil {
@@ -72,6 +82,7 @@ func NewBlockResponseMessage(block *legacy.Block) (*BlockResponseMessage, error)
        return &BlockResponseMessage{RawBlock: rawBlock}, nil
 }
 
+// GetBlock return block struct
 func (m *BlockResponseMessage) GetBlock() *legacy.Block {
        block := &legacy.Block{
                BlockHeader:  legacy.BlockHeader{},
@@ -85,10 +96,12 @@ func (m *BlockResponseMessage) String() string {
        return fmt.Sprintf("BlockResponseMessage{Size: %d}", len(m.RawBlock))
 }
 
+// TransactionNotifyMessage is transaction notify message struct
 type TransactionNotifyMessage struct {
        RawTx []byte
 }
 
+// NewTransactionNotifyMessage produce new TransactionNotifyMessage instance
 func NewTransactionNotifyMessage(tx *legacy.Tx) (*TransactionNotifyMessage, error) {
        rawTx, err := tx.TxData.MarshalText()
        if err != nil {
@@ -97,6 +110,7 @@ func NewTransactionNotifyMessage(tx *legacy.Tx) (*TransactionNotifyMessage, erro
        return &TransactionNotifyMessage{RawTx: rawTx}, nil
 }
 
+// GetTransaction return Tx struct
 func (m *TransactionNotifyMessage) GetTransaction() *legacy.Tx {
        tx := &legacy.Tx{}
        tx.UnmarshalText(m.RawTx)
@@ -107,17 +121,20 @@ func (m *TransactionNotifyMessage) String() string {
        return fmt.Sprintf("TransactionNotifyMessage{Size: %d}", len(m.RawTx))
 }
 
+// StatusRequestMessage is status request message struct
 type StatusRequestMessage struct{}
 
 func (m *StatusRequestMessage) String() string {
        return "StatusRequestMessage"
 }
 
+// StatusResponseMessage is status response message struct
 type StatusResponseMessage struct {
        Height  uint64
        RawHash [32]byte
 }
 
+// NewStatusResponseMessage produce new StatusResponseMessage instance
 func NewStatusResponseMessage(block *legacy.Block) *StatusResponseMessage {
        return &StatusResponseMessage{
                Height:  block.Height,
@@ -125,6 +142,7 @@ func NewStatusResponseMessage(block *legacy.Block) *StatusResponseMessage {
        }
 }
 
+// GetHash return hash pointer
 func (m *StatusResponseMessage) GetHash() *bc.Hash {
        hash := bc.NewHash(m.RawHash)
        return &hash
index a2d79b0..0ffd1fa 100644 (file)
@@ -14,6 +14,7 @@ var (
        errBadAction     = errors.New("bad action object")
 )
 
+// BuildRequest is main struct when building transactions
 type BuildRequest struct {
        Tx      *legacy.TxData           `json:"base_transaction"`
        Actions []map[string]interface{} `json:"actions"`
index d59b7d3..9e61b66 100644 (file)
@@ -10,6 +10,7 @@ import (
        "github.com/bytom/net"
 )
 
+// ErrNoTLS means that no TLS configuration available
 var ErrNoTLS = errors.New("no TLS configuration available")
 
 // TLSConfig returns a TLS config suitable for use
index b8b4be0..947217d 100755 (executable)
@@ -8,10 +8,12 @@ import (
        "github.com/bytom/protocol/bc/legacy"
 )
 
+// NewBuilder return new TemplateBuilder instance
 func NewBuilder(maxTime time.Time) *TemplateBuilder {
        return &TemplateBuilder{maxTime: maxTime}
 }
 
+// TemplateBuilder is struct of building transactions
 type TemplateBuilder struct {
        base                *legacy.TxData
        inputs              []*legacy.TxInput
@@ -24,6 +26,7 @@ type TemplateBuilder struct {
        callbacks           []func() error
 }
 
+// AddInput add inputs of transactions
 func (b *TemplateBuilder) AddInput(in *legacy.TxInput, sigInstruction *SigningInstruction) error {
        if !in.IsCoinbase() && in.Amount() > math.MaxInt64 {
                return errors.WithDetailf(ErrBadAmount, "amount %d exceeds maximum value 2^63", in.Amount())
@@ -33,6 +36,7 @@ func (b *TemplateBuilder) AddInput(in *legacy.TxInput, sigInstruction *SigningIn
        return nil
 }
 
+// AddOutput add outputs of transactions
 func (b *TemplateBuilder) AddOutput(o *legacy.TxOutput) error {
        if o.Amount > math.MaxInt64 {
                return errors.WithDetailf(ErrBadAmount, "amount %d exceeds maximum value 2^63", o.Amount)
@@ -41,18 +45,21 @@ func (b *TemplateBuilder) AddOutput(o *legacy.TxOutput) error {
        return nil
 }
 
+// RestrictMinTime set minTime
 func (b *TemplateBuilder) RestrictMinTime(t time.Time) {
        if t.After(b.minTime) {
                b.minTime = t
        }
 }
 
+// RestrictMaxTime set maxTime
 func (b *TemplateBuilder) RestrictMaxTime(t time.Time) {
        if t.Before(b.maxTime) {
                b.maxTime = t
        }
 }
 
+// MaxTime return maxTime
 func (b *TemplateBuilder) MaxTime() time.Time {
        return b.maxTime
 }
@@ -80,6 +87,7 @@ func (b *TemplateBuilder) rollback() {
        }
 }
 
+// Build build transactions with template
 func (b *TemplateBuilder) Build() (*Template, *legacy.TxData, error) {
        // Run any building callbacks.
        for _, cb := range b.callbacks {
index 4120fe9..0060ed0 100755 (executable)
@@ -6,6 +6,7 @@ import (
        chainjson "github.com/bytom/encoding/json"
 )
 
+// DataWitness used sign transaction
 type DataWitness chainjson.HexBytes
 
 func (dw DataWitness) materialize(args *[][]byte) error {
@@ -13,6 +14,7 @@ func (dw DataWitness) materialize(args *[][]byte) error {
        return nil
 }
 
+// MarshalJSON marshal DataWitness
 func (dw DataWitness) MarshalJSON() ([]byte, error) {
        x := struct {
                Type  string             `json:"type"`
index 66b834b..4929129 100755 (executable)
@@ -13,8 +13,9 @@ import (
 var (
        // ErrRejected means the network rejected a tx (as a double-spend)
        ErrRejected = errors.New("transaction rejected")
-
-       ErrMissingRawTx        = errors.New("missing raw tx")
+       // ErrMissingRawTx means missing transaction
+       ErrMissingRawTx = errors.New("missing raw tx")
+       // ErrBadInstructionCount means too many signing instructions compare with inputs
        ErrBadInstructionCount = errors.New("too many signing instructions in template")
 )
 
index a2c1d60..1c65f61 100755 (executable)
@@ -29,7 +29,7 @@ func (si *SigningInstruction) AddWitnessKeys(xpubs []chainkd.XPub, path [][]byte
        si.WitnessComponents = append(si.WitnessComponents, sw)
 }
 
-// AddWitnessKeys adds a SignatureWitness with the given quorum and
+// AddRawWitnessKeys adds a SignatureWitness with the given quorum and
 // list of keys derived by applying the derivation path to each of the
 // xpubs.
 func (si *SigningInstruction) AddRawWitnessKeys(xpubs []chainkd.XPub, path [][]byte, quorum int) {
@@ -64,6 +64,7 @@ type witnessComponent interface {
        materialize(*[][]byte) error
 }
 
+// UnmarshalJSON unmarshal SigningInstruction
 func (si *SigningInstruction) UnmarshalJSON(b []byte) error {
        var pre struct {
                Position          uint32            `json:"position"`
index 2ebf1b5..c642da0 100755 (executable)
@@ -27,10 +27,12 @@ type Template struct {
        AllowAdditional bool `json:"allow_additional_actions"`
 }
 
+// Hash return sign hash
 func (t *Template) Hash(idx uint32) bc.Hash {
        return t.Transaction.SigHash(idx)
 }
 
+// Action is a interface
 type Action interface {
        Build(context.Context, *TemplateBuilder) error
 }
index 1b8c91f..bb778ad 100755 (executable)
@@ -253,7 +253,6 @@ func prevoutDBKeys(batch db.Batch, b *legacy.Block, txStatus *bc.TransactionStat
                for _, inpID := range tx.Tx.InputIDs {
                        sp, err := tx.Spend(inpID)
                        if err != nil {
-                               log.WithField("err", err).Error("building spend entry type")
                                continue
                        }