OSDN Git Service

opz code format
authorYahtoo Ma <yahtoo.ma@gmail.com>
Fri, 27 Sep 2019 07:32:23 +0000 (15:32 +0800)
committerYahtoo Ma <yahtoo.ma@gmail.com>
Fri, 27 Sep 2019 07:32:23 +0000 (15:32 +0800)
proposal/blockproposer/blockproposer.go
protocol/block.go
protocol/mov.go

index 7216e9b..c209741 100644 (file)
@@ -31,7 +31,7 @@ type BlockProposer struct {
        chain           *protocol.Chain
        accountManager  *account.Manager
        txPool          *protocol.TxPool
-       Preprocessors   []Preprocessor
+       preprocessors   []Preprocessor
        started         bool
        quit            chan struct{}
        eventDispatcher *event.Dispatcher
@@ -88,7 +88,7 @@ func (b *BlockProposer) generateBlocks() {
                        packageTxs = append(packageTxs, txDesc.Tx)
                }
 
-               for i, p := range b.Preprocessors {
+               for i, p := range b.preprocessors {
                        txs, err := p.BeforeProposalBlock(packageTxs)
                        if err != nil {
                                log.WithFields(log.Fields{"module": logModule, "index": i, "error": err}).Error("failed on sub protocol txs package")
@@ -175,7 +175,7 @@ func NewBlockProposer(c *protocol.Chain, accountManager *account.Manager, txPool
                chain:           c,
                accountManager:  accountManager,
                txPool:          txPool,
-               Preprocessors:   preprocessors,
+               preprocessors:   preprocessors,
                eventDispatcher: dispatcher,
        }
 }
index b7e6240..0571119 100644 (file)
@@ -112,7 +112,7 @@ func (c *Chain) connectBlock(block *types.Block) (err error) {
 
        for _, p := range c.subProtocols {
                if err := p.ApplyBlock(block); err != nil {
-                       return errors.Wrap(err, "sub protocol connect block")
+                       return errors.Wrap(err, p.Name(), "sub protocol connect block")
                }
        }
 
@@ -172,7 +172,7 @@ func (c *Chain) reorganizeChain(blockHeader *types.BlockHeader) error {
 
                for _, p := range c.subProtocols {
                        if err := p.DetachBlock(b); err != nil {
-                               return errors.Wrap(err, "sub protocol detach block")
+                               return errors.Wrap(err, p.Name(), "sub protocol detach block")
                        }
                }
 
@@ -213,7 +213,7 @@ func (c *Chain) reorganizeChain(blockHeader *types.BlockHeader) error {
 
                for _, p := range c.subProtocols {
                        if err := p.ApplyBlock(b); err != nil {
-                               return errors.Wrap(err, "sub protocol attach block")
+                               return errors.Wrap(err, p.Name(), "sub protocol attach block")
                        }
                }
 
index b9bec61..3f84b02 100644 (file)
@@ -5,8 +5,11 @@ import (
        "github.com/vapor/protocol/bc/types"
 )
 
-// startHeight mov protocol startup height.
-const startHeight = 0
+const (
+       name = "MOV"
+       // startHeight mov protocol startup height.
+       startHeight = 0
+)
 
 type combination interface {
        ApplyBlock(block *types.Block) error
@@ -42,7 +45,7 @@ func (m MOV) IsDust(tx *types.Tx) bool {
 }
 
 func (m MOV) Name() string {
-       return "MOV"
+       return name
 }
 
 func (m MOV) ValidateBlock(block *bc.Block) error {
@@ -53,8 +56,8 @@ func (m MOV) ValidateTxs(txs []*bc.Tx) error {
        return nil
 }
 
-func (m MOV) Status() (uint64, *bc.Hash){
-       return 0,nil
+func (m MOV) Status() (uint64, *bc.Hash) {
+       return 0, nil
 }
 
 func (m MOV) SyncStatus() error {