Commit 1c51e32d authored by kingwang's avatar kingwang Committed by 33cn

update 05/23

parent df09995f
...@@ -129,12 +129,8 @@ func (m *mockBlockChain) SetQueueClient(q queue.Queue) { ...@@ -129,12 +129,8 @@ func (m *mockBlockChain) SetQueueClient(q queue.Queue) {
msg.ReplyErr("Do not support", types.ErrInvalidParam) msg.ReplyErr("Do not support", types.ErrInvalidParam)
} }
case types.EventLocalList: case types.EventLocalList:
if req, ok := msg.GetData().(*types.LocalDBList); ok { if _, ok := msg.GetData().(*types.LocalDBList); ok {
if len(req.Key) > 0 && bytes.Equal(req.Key, []byte("Statistics:TicketInfoOrder:Addr:case1")) { msg.Reply(client.NewMessage(blockchainKey, types.EventReplyQuery, &types.LocalReplyValue{}))
msg.Reply(client.NewMessage(blockchainKey, types.EventReplyQuery, &types.TicketMinerInfo{}))
} else {
msg.Reply(client.NewMessage(blockchainKey, types.EventReplyQuery, &types.LocalReplyValue{}))
}
} else { } else {
msg.ReplyErr("Do not support", types.ErrInvalidParam) msg.ReplyErr("Do not support", types.ErrInvalidParam)
} }
......
...@@ -76,17 +76,15 @@ func (j *JSONRPCServer) Listen() (int, error) { ...@@ -76,17 +76,15 @@ func (j *JSONRPCServer) Listen() (int, error) {
} }
//格式做一个检查 //格式做一个检查
client, err := parseJSONRpcParams(data) client, err := parseJSONRpcParams(data)
errstr := "nil"
if err != nil { if err != nil {
errstr = err.Error() err = fmt.Errorf(`invalid json request err:%s`, err.Error())
log.Debug("JSONRPCServer", "request", string(data), "parseErr", err)
writeError(w, r, 0, err.Error())
return
} }
funcName := strings.Split(client.Method, ".")[len(strings.Split(client.Method, "."))-1] funcName := strings.Split(client.Method, ".")[len(strings.Split(client.Method, "."))-1]
if !checkFilterPrintFuncBlacklist(funcName) { if !checkFilterPrintFuncBlacklist(funcName) {
log.Debug("JSONRPCServer", "request", string(data), "err", errstr) log.Debug("JSONRPCServer", "request", string(data))
}
if err != nil {
writeError(w, r, 0, fmt.Sprintf(`parse request err %s`, err.Error()))
return
} }
//Release local request //Release local request
ipaddr := net.ParseIP(ip) ipaddr := net.ParseIP(ip)
......
...@@ -215,7 +215,7 @@ func createTxGroup(cmd *cobra.Command, args []string) { ...@@ -215,7 +215,7 @@ func createTxGroup(cmd *cobra.Command, args []string) {
fmt.Fprintln(os.Stderr, err) fmt.Fprintln(os.Stderr, err)
return return
} }
err = group.Check(0, types.GInt("MinFee"), types.GInt("MaxFee")) err = group.CheckWithFork(true, true, 0, types.GInt("MinFee"), types.GInt("MaxFee"))
if err != nil { if err != nil {
fmt.Fprintln(os.Stderr, err) fmt.Fprintln(os.Stderr, err)
return return
......
...@@ -148,26 +148,6 @@ type GetTotalCoinsResult struct { ...@@ -148,26 +148,6 @@ type GetTotalCoinsResult struct {
DifferenceAmount string `json:"differenceAmount,omitempty"` DifferenceAmount string `json:"differenceAmount,omitempty"`
} }
// GetTicketStatisticResult defines ticketstatistic result rpc command
type GetTicketStatisticResult struct {
CurrentOpenCount int64 `json:"currentOpenCount"`
TotalMinerCount int64 `json:"totalMinerCount"`
TotalCloseCount int64 `json:"totalCloseCount"`
}
// GetTicketMinerInfoResult defines ticker minerinformation result rpc command
type GetTicketMinerInfoResult struct {
TicketID string `json:"ticketId"`
Status string `json:"status"`
PrevStatus string `json:"prevStatus"`
IsGenesis bool `json:"isGenesis"`
CreateTime string `json:"createTime"`
MinerTime string `json:"minerTime"`
CloseTime string `json:"closeTime"`
MinerValue int64 `json:"minerValue,omitempty"`
MinerAddress string `json:"minerAddress,omitempty"`
}
// UTXOGlobalIndex defines utxo globalindex command // UTXOGlobalIndex defines utxo globalindex command
type UTXOGlobalIndex struct { type UTXOGlobalIndex struct {
// Height int64 `json:"height,omitempty"` // Height int64 `json:"height,omitempty"`
......
...@@ -35,20 +35,28 @@ func Register(name string, create DriverCreate, height int64) { ...@@ -35,20 +35,28 @@ func Register(name string, create DriverCreate, height int64) {
if _, dup := registedExecDriver[name]; dup { if _, dup := registedExecDriver[name]; dup {
panic("Execute: Register called twice for driver " + name) panic("Execute: Register called twice for driver " + name)
} }
driverWithHeight := &driverWithHeight{ driverHeight := &driverWithHeight{
create: create, create: create,
height: height, height: height,
} }
registedExecDriver[name] = driverWithHeight registedExecDriver[name] = driverHeight
//考虑到前期平行链兼容性和防止误操作(平行链下转账到一个主链合约),也会注册主链合约(不带前缀)的地址
registerAddress(name)
execDrivers[ExecAddress(name)] = driverHeight
if types.IsPara() { if types.IsPara() {
paraHeight := types.GetFork("ForkEnableParaRegExec")
if paraHeight < height {
paraHeight = height
}
//平行链的合约地址是通过user.p.x.name计算的 //平行链的合约地址是通过user.p.x.name计算的
paraDriverName := types.ExecName(name) paraDriverName := types.ExecName(name)
registerAddress(paraDriverName) registerAddress(paraDriverName)
execDrivers[ExecAddress(paraDriverName)] = driverWithHeight execDrivers[ExecAddress(paraDriverName)] = &driverWithHeight{
create: create,
height: paraHeight,
}
} }
//考虑到前期平行链兼容性和防止误操作(平行链下转账到一个主链合约),也会注册主链合约(不带前缀)的地址
registerAddress(name)
execDrivers[ExecAddress(name)] = driverWithHeight
} }
// LoadDriver load driver // LoadDriver load driver
......
...@@ -214,6 +214,8 @@ func SetTestNetFork() { ...@@ -214,6 +214,8 @@ func SetTestNetFork() {
systemFork.SetFork("chain33", "ForkLocalDBAccess", 1572391) systemFork.SetFork("chain33", "ForkLocalDBAccess", 1572391)
systemFork.SetFork("chain33", "ForkTxGroupPara", 1687250) systemFork.SetFork("chain33", "ForkTxGroupPara", 1687250)
systemFork.SetFork("chain33", "ForkBase58AddressCheck", 1800000) systemFork.SetFork("chain33", "ForkBase58AddressCheck", 1800000)
//这个fork只影响平行链,注册类似user.p.x.exec的driver,新开的平行链设为0即可,老的平行链要设置新的高度
systemFork.SetFork("chain33", "ForkEnableParaRegExec", 0)
} }
......
...@@ -34,33 +34,6 @@ message IterateRangeByStateHash { ...@@ -34,33 +34,6 @@ message IterateRangeByStateHash {
int64 count = 4; int64 count = 4;
} }
message TicketStatistic {
//当前在挖的ticket
int64 currentOpenCount = 1;
//一共挖到的ticket
int64 totalMinerCount = 2;
//一共取消的ticket
int64 totalCancleCount = 3;
}
message TicketMinerInfo {
string ticketId = 1;
// 1 -> 可挖矿 2 -> 已挖成功 3-> 已关闭
int32 status = 2;
int32 prevStatus = 3;
// genesis 创建的私钥比较特殊
bool isGenesis = 4;
//创建ticket时间
int64 createTime = 5;
// ticket挖矿时间
int64 minerTime = 6;
//关闭ticket时间
int64 closeTime = 7;
//挖到的币的数目
int64 minerValue = 8;
string minerAddress = 9;
}
message TotalAmount { message TotalAmount {
// 统计的总数 // 统计的总数
int64 total = 1; int64 total = 1;
......
...@@ -176,6 +176,7 @@ ForkMultiSignAddress=1298600 ...@@ -176,6 +176,7 @@ ForkMultiSignAddress=1298600
ForkBlockCheck=1725000 ForkBlockCheck=1725000
ForkLocalDBAccess=1 ForkLocalDBAccess=1
ForkBase58AddressCheck=1800000 ForkBase58AddressCheck=1800000
ForkEnableParaRegExec=0
[fork.sub.coins] [fork.sub.coins]
Enable=0 Enable=0
......
...@@ -197,6 +197,7 @@ ForkMultiSignAddress=1298600 ...@@ -197,6 +197,7 @@ ForkMultiSignAddress=1298600
ForkBlockCheck=1 ForkBlockCheck=1
ForkLocalDBAccess=0 ForkLocalDBAccess=0
ForkBase58AddressCheck=1800000 ForkBase58AddressCheck=1800000
ForkEnableParaRegExec=0
[fork.sub.coins] [fork.sub.coins]
Enable=0 Enable=0
......
...@@ -11,7 +11,7 @@ import ( ...@@ -11,7 +11,7 @@ import (
"reflect" "reflect"
"time" "time"
"github.com/hashicorp/golang-lru" lru "github.com/hashicorp/golang-lru"
"strconv" "strconv"
...@@ -172,8 +172,8 @@ func (txgroup *Transactions) IsExpire(height, blocktime int64) bool { ...@@ -172,8 +172,8 @@ func (txgroup *Transactions) IsExpire(height, blocktime int64) bool {
return false return false
} }
//Check height == 0 的时候,不做检查 //CheckWithFork 和fork 无关的有个检查函数
func (txgroup *Transactions) Check(height, minfee, maxFee int64) error { func (txgroup *Transactions) CheckWithFork(checkFork, paraFork bool, height, minfee, maxFee int64) error {
txs := txgroup.Txs txs := txgroup.Txs
if len(txs) < 2 { if len(txs) < 2 {
return ErrTxGroupCountLessThanTwo return ErrTxGroupCountLessThanTwo
...@@ -193,7 +193,7 @@ func (txgroup *Transactions) Check(height, minfee, maxFee int64) error { ...@@ -193,7 +193,7 @@ func (txgroup *Transactions) Check(height, minfee, maxFee int64) error {
} }
//txgroup 只允许一条平行链的交易, 且平行链txgroup须全部是平行链tx //txgroup 只允许一条平行链的交易, 且平行链txgroup须全部是平行链tx
//如果平行链已经在主链分叉高度前运行了一段时间且有跨链交易,平行链需要自己设置这个fork //如果平行链已经在主链分叉高度前运行了一段时间且有跨链交易,平行链需要自己设置这个fork
if IsFork(height, "ForkTxGroupPara") { if paraFork {
if len(para) > 1 { if len(para) > 1 {
tlog.Info("txgroup has multi para transaction") tlog.Info("txgroup has multi para transaction")
return ErrTxGroupParaCount return ErrTxGroupParaCount
...@@ -225,7 +225,7 @@ func (txgroup *Transactions) Check(height, minfee, maxFee int64) error { ...@@ -225,7 +225,7 @@ func (txgroup *Transactions) Check(height, minfee, maxFee int64) error {
if txs[0].Fee < totalfee { if txs[0].Fee < totalfee {
return ErrTxFeeTooLow return ErrTxFeeTooLow
} }
if txs[0].Fee > maxFee && maxFee > 0 && IsFork(height, "ForkBlockCheck") { if txs[0].Fee > maxFee && maxFee > 0 && checkFork {
return ErrTxFeeTooHigh return ErrTxFeeTooHigh
} }
//检查hash是否符合要求 //检查hash是否符合要求
...@@ -261,6 +261,13 @@ func (txgroup *Transactions) Check(height, minfee, maxFee int64) error { ...@@ -261,6 +261,13 @@ func (txgroup *Transactions) Check(height, minfee, maxFee int64) error {
return nil return nil
} }
//Check height == 0 的时候,不做检查
func (txgroup *Transactions) Check(height, minfee, maxFee int64) error {
paraFork := IsFork(height, "ForkTxGroupPara")
checkFork := IsFork(height, "ForkBlockCheck")
return txgroup.CheckWithFork(checkFork, paraFork, height, minfee, maxFee)
}
//TransactionCache 交易缓存结构 //TransactionCache 交易缓存结构
type TransactionCache struct { type TransactionCache struct {
*Transaction *Transaction
......
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