Skip to content

Commit

Permalink
clean unused code (#1143)
Browse files Browse the repository at this point in the history
  • Loading branch information
laizy committed Feb 18, 2020
1 parent 84583ce commit 9747ea3
Show file tree
Hide file tree
Showing 40 changed files with 45 additions and 473 deletions.
8 changes: 3 additions & 5 deletions account/identity.go
Expand Up @@ -26,7 +26,7 @@ import (
"fmt"
"math/big"

base58 "github.com/itchyny/base58-go"
"github.com/itchyny/base58-go"
"github.com/ontio/ontology-crypto/keypair"
"github.com/ontio/ontology/core/types"
"golang.org/x/crypto/ripemd160"
Expand Down Expand Up @@ -89,10 +89,8 @@ func VerifyID(id string) bool {
data := buf[:pos]
check := buf[pos:]
sum := checksum(data)
if !bytes.Equal(sum, check) {
return false
}
return true

return bytes.Equal(sum, check)
}

func checksum(data []byte) []byte {
Expand Down
8 changes: 0 additions & 8 deletions common/inventory.go
Expand Up @@ -25,11 +25,3 @@ const (
BLOCK InventoryType = 0x02
CONSENSUS InventoryType = 0xe0
)

//TODO: temp inventory
type Inventory interface {
//sig.SignableData
Hash() Uint256
Verify() error
Type() InventoryType
}
4 changes: 2 additions & 2 deletions common/log/log.go
Expand Up @@ -377,9 +377,9 @@ func GetLogFileSize() (int64, error) {

func GetMaxLogChangeInterval(maxLogSize int64) int64 {
if maxLogSize != 0 {
return (maxLogSize * BYTE_TO_MB)
return maxLogSize * BYTE_TO_MB
} else {
return (DEFAULT_MAX_LOG_SIZE * BYTE_TO_MB)
return DEFAULT_MAX_LOG_SIZE * BYTE_TO_MB
}
}

Expand Down
2 changes: 1 addition & 1 deletion common/log/log_test.go
Expand Up @@ -81,5 +81,5 @@ func TestNewLogFile(t *testing.T) {
fmt.Println(err2)
return
}
assert.Equal(t, len(logfileNum1), (len(logfileNum2) - 1))
assert.Equal(t, len(logfileNum1), len(logfileNum2)-1)
}
12 changes: 0 additions & 12 deletions consensus/dbft/dbft_service.go
Expand Up @@ -309,18 +309,6 @@ func (ds *DbftService) InitializeConsensus(viewNum byte) error {
return nil
}

func (ds *DbftService) LocalNodeNewInventory(v interface{}) {
log.Debug()
if inventory, ok := v.(common.Inventory); ok {
if inventory.Type() == common.CONSENSUS {
payload, ret := inventory.(*p2pmsg.ConsensusPayload)
if ret == true {
ds.NewConsensusPayload(payload)
}
}
}
}

func (ds *DbftService) NewConsensusPayload(payload *p2pmsg.ConsensusPayload) {
//if payload from current peer, ignore it
if int(payload.BookkeeperIndex) == ds.context.BookkeeperIndex {
Expand Down
43 changes: 0 additions & 43 deletions consensus/policy.go

This file was deleted.

28 changes: 0 additions & 28 deletions consensus/policy_level.go

This file was deleted.

2 changes: 1 addition & 1 deletion consensus/vbft/msg_builder.go
Expand Up @@ -266,7 +266,7 @@ func (self *Server) constructProposalMsg(blkNum uint32, sysTxs, userTxs []*types
}
merkleRoot, err := self.blockPool.getExecMerkleRoot(blkNum - 1)
if err != nil {
return nil, fmt.Errorf("failed to GetExecMerkleRoot: %s,blkNum:%d", err, (blkNum - 1))
return nil, fmt.Errorf("failed to GetExecMerkleRoot: %s,blkNum:%d", err, blkNum-1)
}

msg := &blockProposalMsg{
Expand Down
2 changes: 1 addition & 1 deletion consensus/vbft/node_sync.go
Expand Up @@ -194,7 +194,7 @@ func (self *Syncer) run() {
} else {
merkleRoot, err := self.server.blockPool.getExecMerkleRoot(blkNum - 1)
if err != nil {
log.Errorf("failed to GetExecMerkleRoot: %s,blkNum:%d", err, (blkNum - 1))
log.Errorf("failed to GetExecMerkleRoot: %s,blkNum:%d", err, blkNum-1)
break
}
if blk.getPrevBlockMerkleRoot() != merkleRoot {
Expand Down
4 changes: 2 additions & 2 deletions consensus/vbft/service.go
Expand Up @@ -1085,7 +1085,7 @@ func (self *Server) processProposalMsg(msg *blockProposalMsg) {
msgBlkNum := msg.GetBlockNum()
blk, prevBlkHash := self.blockPool.getSealedBlock(msg.GetBlockNum() - 1)
if blk == nil {
log.Errorf("BlockProposal failed to GetPreBlock:%d", (msg.GetBlockNum() - 1))
log.Errorf("BlockProposal failed to GetPreBlock:%d", msg.GetBlockNum()-1)
return
}

Expand All @@ -1101,7 +1101,7 @@ func (self *Server) processProposalMsg(msg *blockProposalMsg) {
}
merkleRoot, err := self.blockPool.getExecMerkleRoot(msgBlkNum - 1)
if err != nil {
log.Errorf("failed to GetExecMerkleRoot: %s,blkNum:%d", err, (msgBlkNum - 1))
log.Errorf("failed to GetExecMerkleRoot: %s,blkNum:%d", err, msgBlkNum-1)
return
}
if msg.Block.getPrevBlockMerkleRoot() != merkleRoot {
Expand Down
2 changes: 1 addition & 1 deletion core/genesis/genesis.go
Expand Up @@ -51,7 +51,7 @@ var (
ONGTokenID = ONGToken.Hash()
)

var GenBlockTime = (config.DEFAULT_GEN_BLOCK_TIME * time.Second)
var GenBlockTime = config.DEFAULT_GEN_BLOCK_TIME * time.Second

var INIT_PARAM = map[string]string{
"gasPrice": "0",
Expand Down
28 changes: 0 additions & 28 deletions core/states/interfaces.go

This file was deleted.

52 changes: 0 additions & 52 deletions core/store/common/store.go
Expand Up @@ -21,7 +21,6 @@ package common
import (
"errors"
"github.com/ontio/ontology/common"
"github.com/ontio/ontology/core/states"
"github.com/ontio/ontology/smartcontract/event"
)

Expand Down Expand Up @@ -54,34 +53,6 @@ type PersistStore interface {
NewIterator(prefix []byte) StoreIterator //Return the iterator of store
}

//StateStore save result of smart contract execution, before commit to store
type StateStore interface {
//Add key-value pair to store
TryAdd(prefix DataEntryPrefix, key []byte, value states.StateValue)
//Get key from state store, if not exist, add it to store
TryGetOrAdd(prefix DataEntryPrefix, key []byte, value states.StateValue) error
//Get key from state store
TryGet(prefix DataEntryPrefix, key []byte) (*StateItem, error)
//Delete key in store
TryDelete(prefix DataEntryPrefix, key []byte)
//iterator key in store
Find(prefix DataEntryPrefix, key []byte) ([]*StateItem, error)
}

//MemoryCacheStore
type MemoryCacheStore interface {
//Put the key-value pair to store
Put(prefix byte, key []byte, value states.StateValue, state ItemState)
//Get the value if key in store
Get(prefix byte, key []byte) *StateItem
//Delete the key in store
Delete(prefix byte, key []byte)
//Get all updated key-value set
GetChangeSet() map[string]*StateItem
// Get all key-value in store
Find() []*StateItem
}

//EventStore save event notify
type EventStore interface {
//SaveEventNotifyByTx save event notify gen by smart contract execution
Expand All @@ -93,26 +64,3 @@ type EventStore interface {
//Commit event notify to store
CommitTo() error
}

//State item type
type ItemState byte

//Status of item
const (
None ItemState = iota //no change
Changed //which was be mark delete
Deleted //which wad be mark delete
)

//State item struct
type StateItem struct {
Key string //State key
Value states.StateValue //State value
State ItemState //Status
Trie bool //no use
}

func (e *StateItem) Copy() *StateItem {
c := *e
return &c
}
58 changes: 0 additions & 58 deletions core/store/ledgerstore/state_cache.go

This file was deleted.

4 changes: 0 additions & 4 deletions core/types/block.go
Expand Up @@ -100,10 +100,6 @@ func (b *Block) Hash() common.Uint256 {
return b.Header.Hash()
}

func (b *Block) Type() common.InventoryType {
return common.BLOCK
}

func (b *Block) RebuildMerkleRoot() {
txs := b.Transactions
hashes := make([]common.Uint256, 0, len(txs))
Expand Down
6 changes: 0 additions & 6 deletions core/types/header.go
Expand Up @@ -256,12 +256,6 @@ func (bd *Header) Hash() common.Uint256 {
return hash
}

func (bd *Header) GetMessage() []byte {
sink := common.NewZeroCopySink(nil)
bd.serializationUnsigned(sink)
return sink.Bytes()
}

func (bd *Header) ToArray() []byte {
sink := common.NewZeroCopySink(nil)
bd.Serialization(sink)
Expand Down
6 changes: 1 addition & 5 deletions core/types/transaction.go
Expand Up @@ -171,7 +171,7 @@ func (tx *Transaction) deserializationUnsigned(source *common.ZeroCopySource) er
}
tx.Payload = pl
default:
return fmt.Errorf("unsupported tx type %v", tx.Type())
return fmt.Errorf("unsupported tx type %v", tx.TxType)
}

var length uint64
Expand Down Expand Up @@ -324,10 +324,6 @@ func (tx *Transaction) Hash() common.Uint256 {
return tx.hash
}

func (tx *Transaction) Type() common.InventoryType {
return common.TRANSACTION
}

func (tx *Transaction) Verify() error {
panic("unimplemented ")
return nil
Expand Down

0 comments on commit 9747ea3

Please sign in to comment.