OSDN Git Service

modify variable name
authoroys <oys@oysdeMBP.localdomain>
Wed, 3 Jul 2019 11:02:11 +0000 (19:02 +0800)
committeroys <oys@oysdeMBP.localdomain>
Wed, 3 Jul 2019 11:02:11 +0000 (19:02 +0800)
proposal/proposal_test.go
protocol/protocol.go
protocol/state/consensus_result.go

index 44c1fc6..894e544 100644 (file)
@@ -71,7 +71,7 @@ func TestCreateCoinbaseTx(t *testing.T) {
                        desc: "the coinbase block height with multi outputs",
                        consensusResult: &state.ConsensusResult{
                                BlockHeight: reductionInterval - 1,
-                               RewardOfCoinbase: map[string]uint64{
+                               CoinbaseReward: map[string]uint64{
                                        "51": 100,
                                        "52": 200,
                                        "55": 500,
index 4c590bf..153312c 100644 (file)
@@ -84,11 +84,11 @@ func (c *Chain) initChainStatus() error {
        }
 
        consensusResults := []*state.ConsensusResult{&state.ConsensusResult{
-               Seq:              0,
-               NumOfVote:        make(map[string]uint64),
-               RewardOfCoinbase: make(map[string]uint64),
-               BlockHash:        genesisBlock.Hash(),
-               BlockHeight:      0,
+               Seq:            0,
+               NumOfVote:      make(map[string]uint64),
+               CoinbaseReward: make(map[string]uint64),
+               BlockHash:      genesisBlock.Hash(),
+               BlockHeight:    0,
        }}
 
        genesisBlockHeader := &genesisBlock.BlockHeader
index bdb1524..8182578 100644 (file)
@@ -50,7 +50,7 @@ func CalcVoteSeq(blockHeight uint64) uint64 {
 type ConsensusResult struct {
        Seq              uint64
        NumOfVote        map[string]uint64
-       RewardOfCoinbase map[string]uint64
+       CoinbaseReward map[string]uint64
        BlockHash        bc.Hash
        BlockHeight      uint64
 }
@@ -68,11 +68,11 @@ func (c *ConsensusResult) ApplyBlock(block *types.Block) error {
        }
 
        if c.IsFinalize() {
-               c.RewardOfCoinbase = map[string]uint64{}
+               c.CoinbaseReward = map[string]uint64{}
        }
 
        program := hex.EncodeToString(reward.ControlProgram)
-       c.RewardOfCoinbase[program], ok = checked.AddUint64(c.RewardOfCoinbase[program], reward.Amount)
+       c.CoinbaseReward[program], ok = checked.AddUint64(c.CoinbaseReward[program], reward.Amount)
        if !ok {
                return errMathOperationOverFlow
        }
@@ -163,12 +163,12 @@ func (c *ConsensusResult) DetachBlock(block *types.Block) error {
        }
 
        program := hex.EncodeToString(reward.ControlProgram)
-       if c.RewardOfCoinbase[program], ok = checked.SubUint64(c.RewardOfCoinbase[program], reward.Amount); !ok {
+       if c.CoinbaseReward[program], ok = checked.SubUint64(c.CoinbaseReward[program], reward.Amount); !ok {
                return errMathOperationOverFlow
        }
 
-       if c.RewardOfCoinbase[program] == 0 {
-               delete(c.RewardOfCoinbase, program)
+       if c.CoinbaseReward[program] == 0 {
+               delete(c.CoinbaseReward, program)
        }
 
        for i := len(block.Transactions) - 1; i >= 0; i-- {
@@ -213,7 +213,7 @@ func (c *ConsensusResult) Fork() *ConsensusResult {
        f := &ConsensusResult{
                Seq:              c.Seq,
                NumOfVote:        map[string]uint64{},
-               RewardOfCoinbase: map[string]uint64{},
+               CoinbaseReward: map[string]uint64{},
                BlockHash:        c.BlockHash,
                BlockHeight:      c.BlockHeight,
        }
@@ -222,8 +222,8 @@ func (c *ConsensusResult) Fork() *ConsensusResult {
                f.NumOfVote[key] = value
        }
 
-       for key, value := range c.RewardOfCoinbase {
-               f.RewardOfCoinbase[key] = value
+       for key, value := range c.CoinbaseReward {
+               f.CoinbaseReward[key] = value
        }
        return f
 }
@@ -303,7 +303,7 @@ func AddCoinbaseRewards(consensusResult *ConsensusResult, reward *CoinbaseReward
        }
 
        aggregateFlag := false
-       for p, amount := range consensusResult.RewardOfCoinbase {
+       for p, amount := range consensusResult.CoinbaseReward {
                coinbaseAmount := amount
                program, err := hex.DecodeString(p)
                if err != nil {