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

fix mempool price score

parent f64d40a4
......@@ -65,25 +65,19 @@ grpcFuncWhitelist=["*"]
name="timeline"
poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
maxTxNumPerAccount=100
[mempool.sub.timeline]
poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
[mempool.sub.score]
poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
timeParam=1 #时间占价格比例
priceConstant=1544 #手续费相对于时间的一个合适的常量,取当前unxi时间戳前四位数,排序时手续费高1e-5~=快1s
pricePower=1 #常量比例
[mempool.sub.price]
poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
[consensus]
name="ticket"
......
......@@ -62,6 +62,19 @@ grpcFuncWhitelist=["*"]
name="timeline"
poolCacheSize=10240
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]
# 共识驱动名,支持solo/raft/ticket/tendermint/pbft
......
......@@ -67,25 +67,19 @@ keyFile="key.pem"
name="price"
poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
maxTxNumPerAccount=100
[mempool.sub.timeline]
poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
[mempool.sub.score]
poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
timeParam=1 #时间占价格比例
priceConstant=1544 #手续费相对于时间的一个合适的常量,取当前unxi时间戳前四位数,排序时手续费高1e-5~=快1s
pricePower=1 #常量比例
[mempool.sub.price]
poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
[consensus]
name="solo"
......
......@@ -10,9 +10,7 @@ import (
// Module Mempool
type subConfig struct {
PoolCacheSize int64 `json:"poolCacheSize"`
MinTxFee int64 `json:"minTxFee"`
MaxTxNumPerAccount int64 `json:"maxTxNumPerAccount"`
PoolCacheSize int64 `json:"poolCacheSize"`
}
func init() {
......
......@@ -67,21 +67,20 @@ keyFile="key.pem"
name="score"
poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
maxTxNumPerAccount=100
[mempool.sub.timeline]
poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
[mempool.sub.score]
poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
timeParam=1 #时间占价格比例
priceConstant=1544 #手续费相对于时间的一个合适的常量,取当前unxi时间戳前四位数,排队时手续费高1e-5的分数~=快1s的分数
pricePower=1 #常量比例
[mempool.sub.price]
poolCacheSize=10240
[consensus]
name="solo"
minerstart=true
......
......@@ -10,12 +10,10 @@ import (
// Module Mempool
type subConfig struct {
PoolCacheSize int64 `json:"poolCacheSize"`
MinTxFee int64 `json:"minTxFee"`
MaxTxNumPerAccount int64 `json:"maxTxNumPerAccount"`
TimeParam int64 `json:"timeParam"`
PriceConstant int64 `json:"priceConstant"`
PricePower int64 `json:"pricePower"`
PoolCacheSize int64 `json:"poolCacheSize"`
TimeParam int64 `json:"timeParam"`
PriceConstant int64 `json:"priceConstant"`
PricePower int64 `json:"pricePower"`
}
func init() {
......
......@@ -67,20 +67,19 @@ keyFile="key.pem"
name="timeline"
poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
maxTxNumPerAccount=100
[mempool.sub.timeline]
poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
[mempool.sub.trade]
[mempool.sub.score]
poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
timeParam=1 #时间占价格比例
priceConstant=1 #一个合适的常量
pricePower=0 #手续费占常量比例
priceConstant=1544 #手续费相对于时间的一个合适的常量,取当前unxi时间戳前四位数,排序时手续费高1e-5~=快1s
pricePower=1 #常量比例
[mempool.sub.price]
poolCacheSize=10240
[consensus]
name="solo"
......
......@@ -67,20 +67,19 @@ keyFile="key.pem"
name="timeline"
poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
maxTxNumPerAccount=100
[mempool.sub.timeline]
poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
[mempool.sub.trade]
[mempool.sub.score]
poolCacheSize=10240
minTxFee=100000
maxTxNumPerAccount=10000
timeParam=1 #时间占价格比例
priceConstant=1 #一个合适的常量
pricePower=0 #手续费占常量比例
priceConstant=1544 #手续费相对于时间的一个合适的常量,取当前unxi时间戳前四位数,排序时手续费高1e-5~=快1s
pricePower=1 #常量比例
[mempool.sub.price]
poolCacheSize=10240
[consensus]
name="solo"
......
......@@ -63,7 +63,7 @@ func (mem *Mempool) checkTx(msg *queue.Message) *queue.Message {
}
// 检查交易账户在mempool中是否存在过多交易
from := tx.From()
if mem.TxNumOfAccount(from) >= maxTxNumPerAccount {
if mem.TxNumOfAccount(from) >= mem.cfg.MaxTxNumPerAccount {
msg.Data = types.ErrManyTx
return msg
}
......
......@@ -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) {
q, mem := initEnv(0)
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