Skip to content

Commit

Permalink
core: change shield to unsupported keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonLi000 committed May 4, 2018
1 parent eedf759 commit b99e6a8
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 90 deletions.
22 changes: 11 additions & 11 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type BlockChain struct {

superNode bool

shieldKeyword string
unsupportedKeyword string
}

const (
Expand Down Expand Up @@ -135,16 +135,16 @@ func NewBlockChain(neb Neblet) (*BlockChain, error) {
txPool.RegisterInNetwork(neb.NetService())

var bc = &BlockChain{
chainID: neb.Config().Chain.ChainId,
genesis: neb.Genesis(),
bkPool: blockPool,
txPool: txPool,
storage: neb.Storage(),
eventEmitter: neb.EventEmitter(),
nvm: neb.Nvm(),
quitCh: make(chan int, 1),
superNode: neb.Config().Chain.SuperNode,
shieldKeyword: neb.Config().Chain.ShieldKeyword,
chainID: neb.Config().Chain.ChainId,
genesis: neb.Genesis(),
bkPool: blockPool,
txPool: txPool,
storage: neb.Storage(),
eventEmitter: neb.EventEmitter(),
nvm: neb.Nvm(),
quitCh: make(chan int, 1),
superNode: neb.Config().Chain.SuperNode,
unsupportedKeyword: neb.Config().Chain.UnsupportedKeyword,
}

bc.cachedBlocks, err = lru.New(128)
Expand Down
14 changes: 7 additions & 7 deletions core/transaction_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,19 +254,19 @@ func (pool *TransactionPool) Push(tx *Transaction) error {
pool.mu.Lock()
defer pool.mu.Unlock()

//if super node and tx type is deploy, add keyword shielding.
if pool.bc.superNode == true && len(pool.bc.shieldKeyword) > 0 && len(tx.Data()) > 0 {
//if is super node and tx type is deploy, do unsupported keyword checking.
if pool.bc.superNode == true && len(pool.bc.unsupportedKeyword) > 0 && len(tx.Data()) > 0 {
if tx.Type() == TxPayloadDeployType {
data := string(tx.Data())
keywords := strings.Split(pool.bc.shieldKeyword, ",")
keywords := strings.Split(pool.bc.unsupportedKeyword, ",")
for _, keyword := range keywords {
keyword = strings.ToLower(keyword)
if strings.Contains(data, keyword) {
logging.VLog().WithFields(logrus.Fields{
"tx": tx,
"shieldedKeyword": keyword,
}).Debug("transaction data has shielded keyword")
return ErrShieldedKeyword
"tx": tx,
"unsupportedKeyword": keyword,
}).Debug("transaction data has unsupported keyword")
return ErrUnsupportedKeyword
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ var (
// nvm error
ErrExecutionFailed = errors.New("execution failed")

// shielded keywork error
ErrShieldedKeyword = errors.New("transaction data has unsupported keywords")
// unsupported keyword error in smart contract
ErrUnsupportedKeyword = errors.New("transaction data has unsupported keyword")
)

// Default gas count
Expand Down
138 changes: 69 additions & 69 deletions neblet/pb/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion neblet/pb/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ message ChainConfig {

bool super_node = 30;

string shield_keyword = 31;
string unsupported_keyword = 31;
}

message RPCConfig {
Expand Down

0 comments on commit b99e6a8

Please sign in to comment.