Commit 05b350a0 authored by 陈德海's avatar 陈德海 Committed by vipwzw

fix mempool price score

parent f64d40a4
...@@ -65,25 +65,19 @@ grpcFuncWhitelist=["*"] ...@@ -65,25 +65,19 @@ grpcFuncWhitelist=["*"]
name="timeline" name="timeline"
poolCacheSize=10240 poolCacheSize=10240
minTxFee=100000 minTxFee=100000
maxTxNumPerAccount=10000 maxTxNumPerAccount=100
[mempool.sub.timeline] [mempool.sub.timeline]
poolCacheSize=10240 poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
[mempool.sub.score] [mempool.sub.score]
poolCacheSize=10240 poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
timeParam=1 #时间占价格比例 timeParam=1 #时间占价格比例
priceConstant=1544 #手续费相对于时间的一个合适的常量,取当前unxi时间戳前四位数,排序时手续费高1e-5~=快1s priceConstant=1544 #手续费相对于时间的一个合适的常量,取当前unxi时间戳前四位数,排序时手续费高1e-5~=快1s
pricePower=1 #常量比例 pricePower=1 #常量比例
[mempool.sub.price] [mempool.sub.price]
poolCacheSize=10240 poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
[consensus] [consensus]
name="ticket" name="ticket"
......
...@@ -62,6 +62,19 @@ grpcFuncWhitelist=["*"] ...@@ -62,6 +62,19 @@ grpcFuncWhitelist=["*"]
name="timeline" name="timeline"
poolCacheSize=10240 poolCacheSize=10240
minTxFee=100000 minTxFee=100000
maxTxNumPerAccount=100
[mempool.sub.timeline]
poolCacheSize=10240
[mempool.sub.score]
poolCacheSize=10240
timeParam=1 #时间占价格比例
priceConstant=1544 #手续费相对于时间的一个合适的常量,取当前unxi时间戳前四位数,排序时手续费高1e-5~=快1s
pricePower=1 #常量比例
[mempool.sub.price]
poolCacheSize=10240
[consensus] [consensus]
# 共识驱动名,支持solo/raft/ticket/tendermint/pbft # 共识驱动名,支持solo/raft/ticket/tendermint/pbft
......
...@@ -67,25 +67,19 @@ keyFile="key.pem" ...@@ -67,25 +67,19 @@ keyFile="key.pem"
name="price" name="price"
poolCacheSize=10240 poolCacheSize=10240
minTxFee=100000 minTxFee=100000
maxTxNumPerAccount=10000 maxTxNumPerAccount=100
[mempool.sub.timeline] [mempool.sub.timeline]
poolCacheSize=10240 poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
[mempool.sub.score] [mempool.sub.score]
poolCacheSize=10240 poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
timeParam=1 #时间占价格比例 timeParam=1 #时间占价格比例
priceConstant=1544 #手续费相对于时间的一个合适的常量,取当前unxi时间戳前四位数,排序时手续费高1e-5~=快1s priceConstant=1544 #手续费相对于时间的一个合适的常量,取当前unxi时间戳前四位数,排序时手续费高1e-5~=快1s
pricePower=1 #常量比例 pricePower=1 #常量比例
[mempool.sub.price] [mempool.sub.price]
poolCacheSize=10240 poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
[consensus] [consensus]
name="solo" name="solo"
......
...@@ -11,8 +11,6 @@ import ( ...@@ -11,8 +11,6 @@ import (
type subConfig struct { type subConfig struct {
PoolCacheSize int64 `json:"poolCacheSize"` PoolCacheSize int64 `json:"poolCacheSize"`
MinTxFee int64 `json:"minTxFee"`
MaxTxNumPerAccount int64 `json:"maxTxNumPerAccount"`
} }
func init() { func init() {
......
...@@ -67,21 +67,20 @@ keyFile="key.pem" ...@@ -67,21 +67,20 @@ keyFile="key.pem"
name="score" name="score"
poolCacheSize=10240 poolCacheSize=10240
minTxFee=100000 minTxFee=100000
maxTxNumPerAccount=10000 maxTxNumPerAccount=100
[mempool.sub.timeline] [mempool.sub.timeline]
poolCacheSize=10240 poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
[mempool.sub.score] [mempool.sub.score]
poolCacheSize=10240 poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
timeParam=1 #时间占价格比例 timeParam=1 #时间占价格比例
priceConstant=1544 #手续费相对于时间的一个合适的常量,取当前unxi时间戳前四位数,排队时手续费高1e-5的分数~=快1s的分数 priceConstant=1544 #手续费相对于时间的一个合适的常量,取当前unxi时间戳前四位数,排队时手续费高1e-5的分数~=快1s的分数
pricePower=1 #常量比例 pricePower=1 #常量比例
[mempool.sub.price]
poolCacheSize=10240
[consensus] [consensus]
name="solo" name="solo"
minerstart=true minerstart=true
......
...@@ -11,8 +11,6 @@ import ( ...@@ -11,8 +11,6 @@ import (
type subConfig struct { type subConfig struct {
PoolCacheSize int64 `json:"poolCacheSize"` PoolCacheSize int64 `json:"poolCacheSize"`
MinTxFee int64 `json:"minTxFee"`
MaxTxNumPerAccount int64 `json:"maxTxNumPerAccount"`
TimeParam int64 `json:"timeParam"` TimeParam int64 `json:"timeParam"`
PriceConstant int64 `json:"priceConstant"` PriceConstant int64 `json:"priceConstant"`
PricePower int64 `json:"pricePower"` PricePower int64 `json:"pricePower"`
......
...@@ -67,20 +67,19 @@ keyFile="key.pem" ...@@ -67,20 +67,19 @@ keyFile="key.pem"
name="timeline" name="timeline"
poolCacheSize=10240 poolCacheSize=10240
minTxFee=100000 minTxFee=100000
maxTxNumPerAccount=10000 maxTxNumPerAccount=100
[mempool.sub.timeline] [mempool.sub.timeline]
poolCacheSize=10240 poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
[mempool.sub.trade] [mempool.sub.score]
poolCacheSize=10240 poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
timeParam=1 #时间占价格比例 timeParam=1 #时间占价格比例
priceConstant=1 #一个合适的常量 priceConstant=1544 #手续费相对于时间的一个合适的常量,取当前unxi时间戳前四位数,排序时手续费高1e-5~=快1s
pricePower=0 #手续费占常量比例 pricePower=1 #常量比例
[mempool.sub.price]
poolCacheSize=10240
[consensus] [consensus]
name="solo" name="solo"
......
...@@ -67,20 +67,19 @@ keyFile="key.pem" ...@@ -67,20 +67,19 @@ keyFile="key.pem"
name="timeline" name="timeline"
poolCacheSize=10240 poolCacheSize=10240
minTxFee=100000 minTxFee=100000
maxTxNumPerAccount=10000 maxTxNumPerAccount=100
[mempool.sub.timeline] [mempool.sub.timeline]
poolCacheSize=10240 poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
[mempool.sub.trade] [mempool.sub.score]
poolCacheSize=10240 poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
timeParam=1 #时间占价格比例 timeParam=1 #时间占价格比例
priceConstant=1 #一个合适的常量 priceConstant=1544 #手续费相对于时间的一个合适的常量,取当前unxi时间戳前四位数,排序时手续费高1e-5~=快1s
pricePower=0 #手续费占常量比例 pricePower=1 #常量比例
[mempool.sub.price]
poolCacheSize=10240
[consensus] [consensus]
name="solo" name="solo"
......
...@@ -63,7 +63,7 @@ func (mem *Mempool) checkTx(msg *queue.Message) *queue.Message { ...@@ -63,7 +63,7 @@ func (mem *Mempool) checkTx(msg *queue.Message) *queue.Message {
} }
// 检查交易账户在mempool中是否存在过多交易 // 检查交易账户在mempool中是否存在过多交易
from := tx.From() from := tx.From()
if mem.TxNumOfAccount(from) >= maxTxNumPerAccount { if mem.TxNumOfAccount(from) >= mem.cfg.MaxTxNumPerAccount {
msg.Data = types.ErrManyTx msg.Data = types.ErrManyTx
return msg return msg
} }
......
...@@ -439,6 +439,22 @@ func TestAddMoreTxThanPoolSize(t *testing.T) { ...@@ -439,6 +439,22 @@ func TestAddMoreTxThanPoolSize(t *testing.T) {
} }
} }
func TestAddMoreTxThanMaxAccountTx(t *testing.T) {
q, mem := initEnv(4)
mem.cfg.MaxTxNumPerAccount = 2
defer q.Close()
defer mem.Close()
err := add4Tx(mem.client)
if err != nil {
t.Error("add tx error", err.Error())
return
}
if mem.Size() != 2 {
t.Error("TestAddMoreTxThanMaxAccountTx failed", "size", mem.Size())
}
}
func TestRemoveTxOfBlock(t *testing.T) { func TestRemoveTxOfBlock(t *testing.T) {
q, mem := initEnv(0) q, mem := initEnv(0)
defer q.Close() defer q.Close()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment