Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
danil-lashin committed Sep 13, 2018
1 parent f299ee3 commit bbedad7
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 19 deletions.
7 changes: 4 additions & 3 deletions core/minter/minter.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ func (app *Blockchain) BeginBlock(req abciTypes.RequestBeginBlock) abciTypes.Res
}

// give penalty to Byzantine validators
for _, v := range req.ByzantineValidators {
for i := range req.ByzantineValidators {
v := &req.ByzantineValidators[i]
var address [20]byte
copy(address[:], v.Validator.Address)

Expand Down Expand Up @@ -320,8 +321,8 @@ func (app *Blockchain) Commit() abciTypes.ResponseCommit {

// todo: make provider
height := make([]byte, 8)
binary.BigEndian.PutUint64(height[:], app.height)
err = appTable.Put([]byte("height"), height[:])
binary.BigEndian.PutUint64(height, app.height)
err = appTable.Put([]byte("height"), height)

if err != nil {
panic(err)
Expand Down
20 changes: 9 additions & 11 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (s *StateDB) updateStateFrozenFund(stateFrozenFund *stateFrozenFund) {
panic(fmt.Errorf("can't encode frozen fund at %d: %v", blockHeight, err))
}
height := make([]byte, 8)
binary.BigEndian.PutUint64(height[:], stateFrozenFund.blockHeight)
binary.BigEndian.PutUint64(height, stateFrozenFund.blockHeight)

key := append(frozenFundsPrefix, height...)
s.setError(s.trie.TryUpdate(key, data))
Expand Down Expand Up @@ -280,7 +280,7 @@ func (s *StateDB) deleteStateCoin(stateCoin *stateCoin) {
func (s *StateDB) deleteFrozenFunds(stateFrozenFund *stateFrozenFund) {
stateFrozenFund.deleted = true
height := make([]byte, 8)
binary.BigEndian.PutUint64(height[:], stateFrozenFund.blockHeight)
binary.BigEndian.PutUint64(height, stateFrozenFund.blockHeight)
key := append(frozenFundsPrefix, height...)
s.setError(s.trie.TryDelete(key))
}
Expand All @@ -293,7 +293,7 @@ func (s *StateDB) getStateFrozenFunds(blockHeight uint64) (stateFrozenFund *stat
}

height := make([]byte, 8)
binary.BigEndian.PutUint64(height[:], blockHeight)
binary.BigEndian.PutUint64(height, blockHeight)
key := append(frozenFundsPrefix, height...)

// Load the object from the database.
Expand Down Expand Up @@ -640,16 +640,14 @@ func (s *StateDB) Commit(deleteEmptyObjects bool) (root types.Hash, err error) {
// Commit coins to the trie.
for symbol, stateCoin := range s.stateCoins {
_, isDirty := s.stateCoinsDirty[symbol]
switch {
case isDirty:
{
if stateCoin.data.Volume.Cmp(types.Big0) == 0 {
s.deleteStateCoin(stateCoin)
} else {
s.updateStateCoin(stateCoin)
}
if isDirty {
if stateCoin.data.Volume.Cmp(types.Big0) == 0 {
s.deleteStateCoin(stateCoin)
} else {
s.updateStateCoin(stateCoin)
}
}

delete(s.stateCoinsDirty, symbol)
}

Expand Down
2 changes: 1 addition & 1 deletion core/transaction/declare_candidacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (data DeclareCandidacyData) MarshalJSON() ([]byte, error) {

func (data DeclareCandidacyData) String() string {
return fmt.Sprintf("DECLARE CANDIDACY address:%s pubkey:%s commission: %d ",
data.Address.String(), hexutil.Encode(data.PubKey[:]), data.Commission)
data.Address.String(), hexutil.Encode(data.PubKey), data.Commission)
}

func (data DeclareCandidacyData) Gas() int64 {
Expand Down
2 changes: 1 addition & 1 deletion core/transaction/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (data DelegateData) MarshalJSON() ([]byte, error) {

func (data DelegateData) String() string {
return fmt.Sprintf("DELEGATE pubkey:%s ",
hexutil.Encode(data.PubKey[:]))
hexutil.Encode(data.PubKey))
}

func (data DelegateData) Gas() int64 {
Expand Down
2 changes: 1 addition & 1 deletion core/transaction/unbond.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (data UnbondData) MarshalJSON() ([]byte, error) {

func (data UnbondData) String() string {
return fmt.Sprintf("UNBOND pubkey:%s",
hexutil.Encode(data.PubKey[:]))
hexutil.Encode(data.PubKey))
}

func (data UnbondData) Gas() int64 {
Expand Down
2 changes: 1 addition & 1 deletion core/types/bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func Hex2BytesFixed(str string, flen int) []byte {
return h[len(h)-flen:]
} else {
hh := make([]byte, flen)
copy(hh[flen-len(h):flen], h[:])
copy(hh[flen-len(h):flen], h)
return hh
}
}
Expand Down
2 changes: 1 addition & 1 deletion hexutil/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (b *Big) UnmarshalText(input []byte) error {
}
var dec big.Int
dec.SetBits(words)
*b = (Big)(dec)
*b = Big(dec)
return nil
}

Expand Down

0 comments on commit bbedad7

Please sign in to comment.