This commit is contained in:
qgzhao197504050036 2018-02-22 13:41:01 +08:00
parent 5a8e314719
commit 010447853d
26 changed files with 534 additions and 99 deletions

21
.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,21 @@
{
// 使 IntelliSense
//
// 访: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${fileDirname}",
"env": {},
"args": [],
"showLog": true
}
]
}

View file

@ -1,6 +1,6 @@
## Go Ethereum ## Go Ethereum
消品链GO-thereum项目 链GO-thereum项目
## 源码创建 ## 源码创建

BIN
cmd/abigen/abigen.exe Normal file

Binary file not shown.

Binary file not shown.

View file

@ -39,12 +39,14 @@ import (
"gopkg.in/urfave/cli.v1" "gopkg.in/urfave/cli.v1"
) )
const ( const (
clientIdentifier = "geth" // Client identifier to advertise over the network clientIdentifier = "geth" // Client identifier to advertise over the network
) )
var ( var (
// Git SHA1 commit hash of the release (set via linker flags) // Git SHA1 commit hash of the release (set via linker flags)
gitCommit = "" gitCommit = ""
// Ethereum address of the Geth release oracle. // Ethereum address of the Geth release oracle.
relOracle = common.HexToAddress("0xfa7b9770ca4cb04296cac84f37736d4041251cdf") relOracle = common.HexToAddress("0xfa7b9770ca4cb04296cac84f37736d4041251cdf")

View file

@ -31,6 +31,8 @@ import (
"github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/log"
set "gopkg.in/fatih/set.v0" set "gopkg.in/fatih/set.v0"
) )
@ -38,9 +40,9 @@ import (
var ( var (
//BlockReward *big.Int = big.NewInt(4e+18) // Block reward in wei for successfully mining a block //BlockReward *big.Int = big.NewInt(4e+18) // Block reward in wei for successfully mining a block
//lockReward *big.Int = big.NewInt(2e+18) // Block reward in wei for successfully mining a block upward from Byzantium //lockReward *big.Int = big.NewInt(2e+18) // Block reward in wei for successfully mining a block upward from Byzantium
blockReward *big.Int = big.NewInt(18e17) // Block reward in wei for successfully mining a block blockReward *big.Int = big.NewInt(8e+18) // Block reward in wei for successfully mining a block
XF_reward *big.Int = big.NewInt(9e17) //XF_reward *big.Int = big.NewInt(9e17)
KY_reward *big.Int = big.NewInt(3e17) // Block reward in wei for successfully mining a block //KY_reward *big.Int = big.NewInt(3e17) // Block reward in wei for successfully mining a block
//KY_blockReward *big.Int = big.NewInt(1e0) //KY_blockReward *big.Int = big.NewInt(1e0)
maxUncles = 2 // Maximum number of uncles allowed in a single block maxUncles = 2 // Maximum number of uncles allowed in a single block
) )
@ -512,7 +514,7 @@ func (ethash *Ethash) VerifySeal(chain consensus.ChainReader, header *types.Head
if new(big.Int).SetBytes(result).Cmp(target) > 0 { if new(big.Int).SetBytes(result).Cmp(target) > 0 {
return errInvalidPoW return errInvalidPoW
} }
//log.Info("消品链验证","区块号",header.Number, "消品权重",header.Tokentime,"封装难度",header.Difficulty) //log.Info("应链验证","区块号",header.Number, "应链权重",header.Tokentime,"封装难度",header.Difficulty)
return nil return nil
} }
@ -550,30 +552,8 @@ var (
// included uncles. The coinbase of each uncle block is also rewarded. // included uncles. The coinbase of each uncle block is also rewarded.
// TODO (karalabe): Move the chain maker into this package and make this private! // TODO (karalabe): Move the chain maker into this package and make this private!
func AccumulateRewards(config *params.ChainConfig, state *state.StateDB, header *types.Header, uncles []*types.Header) { func AccumulateRewards(config *params.ChainConfig, state *state.StateDB, header *types.Header, uncles []*types.Header) {
// Select the correct block reward based on chain progression //挖矿成功将1%奖励给矿池将99%存入挖矿合约帐户
//blockReward := FrontierBlockReward
//if config.IsByzantium(header.Number) {
// blockReward = ByzantiumBlockReward
//}
// Accumulate the rewards for the miner and any included uncles
//reward := new(big.Int).Set(blockReward)
//r := new(big.Int)
//for _, uncle := range uncles {
// r.Add(uncle.Number, big8)
// r.Sub(r, header.Number)
// r.Mul(r, blockReward)
// r.Div(r, big8)
// state.AddBalance(uncle.Coinbase, r)
// r.Div(blockReward, big32)
// reward.Add(reward, r)
//}
//state.AddBalance(header.Coinbase, reward)
reward := new(big.Int).Set(blockReward) reward := new(big.Int).Set(blockReward)
//var XP_GD = common.HexToAddress("0xf933b0CF38a270938B9D6bb41f004374363C3EC0")
var XP_XF = params.XP_XF
var XP_KY = params.XP_KY
r := new(big.Int) r := new(big.Int)
for _, uncle := range uncles { for _, uncle := range uncles {
r.Add(uncle.Number, big8) r.Add(uncle.Number, big8)
@ -585,12 +565,21 @@ func AccumulateRewards(config *params.ChainConfig, state *state.StateDB, header
r.Div(blockReward, big32) r.Div(blockReward, big32)
reward.Add(reward, r) reward.Add(reward, r)
} }
state.AddBalance(header.Coinbase, reward) TotalReward:=new(big.Int).Set(reward.Mul(reward,big.NewInt(100)))
// log.Info("计算挖矿", "算力帐号:", header.Coinbase, "奖励数量", XP_blockReward, "单位", "XPing") Reward_justnum:=new(big.Int).Set(header.Number)
//state.AddBalance(XP_GD, reward) Reward_justnum.Div(header.Number, big.NewInt(50000000)) //计算调整系数,每隔五千万个区块减半发行
// log.Info("投资挖矿", "股东帐号:", XP_GD, "奖励数量", XP_blockReward, "单位", "XPing") //log.Info("参数变量","TotalReward",TotalReward,"Reward_Justnum",Reward_justnum)
state.AddBalance(XP_XF, XF_reward) TotalReward.Div(TotalReward,math.Exp(big.NewInt(2),Reward_justnum)) // reward/2**justnum
// log.Info("消费挖矿", "基金帐号:", XP_XF, "奖励数量", XP_blockReward, "单位", "XPing") //log.Info("参数变量","TotalReward",TotalReward)
state.AddBalance(XP_KY, KY_reward) if header.Number.Cmp(big.NewInt(100))>0 { //必须在区块号100以前完成挖矿智能合约的部署。
// log.Info("技术挖矿", "科研帐号:", XP_KY, "奖励数量", KY_blockReward, "单位", "XPing") minerpool:=TotalReward.Div(TotalReward,big.NewInt(100))
state.AddBalance(header.Coinbase, minerpool)
// log.Info("参数变量","minerpool",minerpool)
// reward.Sub(reward,minerpool)
state.AddBalance(params.PosMinerContractAddr, TotalReward.Mul(TotalReward,big.NewInt(99)))
log.Info("参数变量","TotalReward",TotalReward)
}else{
state.AddBalance(header.Coinbase, TotalReward)
log.Info("参数变量","TotalReward",TotalReward)
}
} }

File diff suppressed because one or more lines are too long

View file

@ -42,6 +42,9 @@ import (
"github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie" "github.com/ethereum/go-ethereum/trie"
"github.com/hashicorp/golang-lru" "github.com/hashicorp/golang-lru"
"github.com/ethereum/go-ethereum/contracts/posminer"
"github.com/ethereum/go-ethereum/ethclient"
) )
var ( var (
@ -606,7 +609,7 @@ func (bc *BlockChain) Stop() {
atomic.StoreInt32(&bc.procInterrupt, 1) atomic.StoreInt32(&bc.procInterrupt, 1)
bc.wg.Wait() bc.wg.Wait()
log.Info("消品链管理器停止工作") log.Info("链管理器停止工作")
} }
func (bc *BlockChain) procFutureBlocks() { func (bc *BlockChain) procFutureBlocks() {
@ -854,19 +857,65 @@ func (bc *BlockChain) WriteBlockAndState(block *types.Block, receipts []*types.R
return status, nil return status, nil
} }
//计算币龄的函数,根据收币数量与时间计算当前币量的币龄,传入参数:待计算地址及起始时间 //统计移动应用权重帐户的用户权重
func (bc *BlockChain) CalcTokenTime(Coinbase common.Address) (Tokentime *big.Int) { func (bc *BlockChain) CalcTokenTime(Coinbase common.Address) (Tokentime *big.Int) {
//var sumToken *big.Int = big.NewInt(0) //var sumToken *big.Int = big.NewInt(0)
//var Tokentime *big.Int = big.NewInt(0) //var Tokentime *big.Int = big.NewInt(0)
statedb, _ := state.New(bc.GetBlockByHash(bc.currentBlock.Hash()).Root(), bc.stateCache) var exist bool
exist=false
//bc, _ := Tokentime=big.NewInt(0)
//log.Error("所查帐号的余额为", "ETHER", statedb.GetBalance(common.HexToAddress("0x3656E9cE021f6454906687FF615915235f8E510f"))) var ActiveMiners []common.Address
//取出待查币龄值帐号的帐户余额 State,_:=bc.State()
Tokentime = statedb.GetBalance(Coinbase) if State.Exist(params.PosMinerContractAddr)!=true{
Tokentime.Div(Tokentime, new(big.Int).Mul(big.NewInt(1), big.NewInt(1e18))) //log.Info("警告","RPC未使能",Tokentime)
return Tokentime return Tokentime
} }
//log.Info("posminer.PosConn",posminer.PosConn)
if posminer.PosConn==nil {
posminer.PosConn, _ = ethclient.Dial("//./pipe/geth.ipc")
log.Info("AppChain连接", "连接IPC服务")
}
//if err != nil {
// log.Info("警告", "设置了ipcdisable不能使用权重挖矿!",err)
// return Tokentime
//}
PosMiner, err := posminer.NewPosminer(params.PosMinerContractAddr, posminer.PosConn)
//log.Info("错误码","err",err,"PosMiner",PosMiner)
if err !=nil{
log.Info("调用挖矿智能合约posminer失败","错误",err)
return Tokentime
}
//M,err:=PosMiner.RegLength(nil)
for i:=uint64(0);i<bc.currentBlock.NumberU64() ;i++{
for _,tx:=range bc.GetBlockByNumber(i).Transactions() {
msg,err:= tx.AsMessage(types.MakeSigner(bc.Config(), bc.GetBlockByNumber(i).Header().Number))
if err != nil {
return Tokentime
}
CmpMiner,err:= PosMiner.Registers(nil, msg.From())
if err != nil {
return Tokentime
}
RegistryTime := new(big.Int).Set(CmpMiner.RegistryTime)
if RegistryTime.Add(RegistryTime,big.NewInt(86400)).Cmp(bc.currentBlock.Time())>0 &&CmpMiner.MinerPool==Coinbase {
for j:=0;j<len(ActiveMiners);j++{
if ActiveMiners[j]==msg.From(){
exist=true
break
}
}
if exist==false {
Tokentime.Add(Tokentime,big.NewInt(1))
ActiveMiners=append(ActiveMiners,msg.From())
}
exist=false
}
}
}
return Tokentime
}
// InsertChain attempts to insert the given batch of blocks in to the canonical // InsertChain attempts to insert the given batch of blocks in to the canonical
// chain or, otherwise, create a fork. If an error is returned it will return // chain or, otherwise, create a fork. If an error is returned it will return
@ -923,13 +972,8 @@ func (bc *BlockChain) insertChain(chain types.Blocks) (int, []interface{}, []*ty
//此处检查区块时间时帐号币龄 //此处检查区块时间时帐号币龄
if new(big.Int).Sub(big.NewInt(time.Now().Unix()), bc.currentBlock.Time()).Cmp(big.NewInt(100)) < 0 { if new(big.Int).Sub(big.NewInt(time.Now().Unix()), bc.currentBlock.Time()).Cmp(big.NewInt(100)) < 0 {
Tokentime := bc.CalcTokenTime(bc.currentBlock.Coinbase()) Tokentime := bc.CalcTokenTime(bc.currentBlock.Coinbase())
// Tokentime2 := bc.CalcTokenTime(common.HexToAddress("0xac9d739c4d83e3501d824c4e308e7812aba8306d"))
//Tokentime3 := bc.CalcTokenTime(common.HexToAddress("0xed867421dabc9dc2785e54411497ae2327f28dfe"))
//log.Error("各帐号币权值", "帐号1币权", Tokentime, "帐号2币权", Tokentime2, "帐号3币权", Tokentime3)
//验证区块登记币权与根据区块时间计算币权的差值的绝对值是否小于一个数100若是则通过。
//log.Error("币权验证", "帐号1币权", bc.CalcTokenTime(bc.currentBlock.Coinbase()), "区块登记币权", bc.currentBlock.Header().Tokentime)
if Tokentime.Cmp(bc.currentBlock.Header().Tokentime) < 0 { if Tokentime.Cmp(bc.currentBlock.Header().Tokentime) < 0 {
//log.Info("消品权重验证失败","区块号", bc.currentBlock.NumberU64,"消品权重",Tokentime,"区块封装难度",bc.currentBlock.Difficulty) //log.Info("应链权重验证失败","区块号", bc.currentBlock.NumberU64,"应链权重",Tokentime,"区块封装难度",bc.currentBlock.Difficulty)
abort := make(chan struct{}) abort := make(chan struct{})
defer close(abort) defer close(abort)
@ -1080,7 +1124,7 @@ func (st *insertStats) report(chain []*types.Block, index int) {
if st.ignored > 0 { if st.ignored > 0 {
context = append(context, []interface{}{"忽略", st.ignored}...) context = append(context, []interface{}{"忽略", st.ignored}...)
} }
log.Info("导入消品新链块", context...) log.Info("导入应链新区块", context...)
*st = insertStats{startTime: now, lastIndex: index + 1} *st = insertStats{startTime: now, lastIndex: index + 1}
} }
@ -1270,7 +1314,7 @@ func (bc *BlockChain) reportBlock(block *types.Block, receipts types.Receipts, e
receiptString += fmt.Sprintf("\t%v\n", receipt) receiptString += fmt.Sprintf("\t%v\n", receipt)
} }
log.Error(fmt.Sprintf(` log.Error(fmt.Sprintf(`
########## 不符合消品链规则的区块 ######### ########## 不符合链规则的区块 #########
区块链配置: %v 区块链配置: %v
区块编号: %v 区块编号: %v

View file

@ -279,7 +279,7 @@ func (c *ChainIndexer) updateLoop() {
if time.Since(updated) > 8*time.Second { if time.Since(updated) > 8*time.Second {
if c.knownSections > c.storedSections+1 { if c.knownSections > c.storedSections+1 {
updating = true updating = true
c.log.Info("更新消品链索引", "百分比", c.storedSections*100/c.knownSections) c.log.Info("更新链索引", "百分比", c.storedSections*100/c.knownSections)
} }
updated = time.Now() updated = time.Now()
} }
@ -303,7 +303,7 @@ func (c *ChainIndexer) updateLoop() {
c.setValidSections(section + 1) c.setValidSections(section + 1)
if c.storedSections == c.knownSections && updating { if c.storedSections == c.knownSections && updating {
updating = false updating = false
c.log.Info("完成消品链索引更新") c.log.Info("完成链索引更新")
} }
c.cascadedHead = c.storedSections*c.sectionSize - 1 c.cascadedHead = c.storedSections*c.sectionSize - 1

View file

@ -212,8 +212,8 @@ func (st *StateTransition) preCheck() error {
func (st *StateTransition) TransitionDb() (ret []byte, requiredGas, usedGas *big.Int, failed bool, err error) { func (st *StateTransition) TransitionDb() (ret []byte, requiredGas, usedGas *big.Int, failed bool, err error) {
// var XP_GD = common.HexToAddress("0xf933b0CF38a270938B9D6bb41f004374363C3EC0") // var XP_GD = common.HexToAddress("0xf933b0CF38a270938B9D6bb41f004374363C3EC0")
var XP_XF = params.XP_XF //var XP_XF = params.XP_XF
var XP_KY = params.XP_KY //var XP_KY = params.XP_KY
if err = st.preCheck(); err != nil { if err = st.preCheck(); err != nil {
@ -261,20 +261,18 @@ func (st *StateTransition) TransitionDb() (ret []byte, requiredGas, usedGas *big
requiredGas = new(big.Int).Set(st.gasUsed()) requiredGas = new(big.Int).Set(st.gasUsed())
st.refundGas() st.refundGas()
// 在算力、股东、消费、科研帐户之间分配交易费。
XP_gas := new(big.Int).Mul(st.gasUsed(), st.gasPrice)
XP_KYgas := new(big.Int).Div(XP_gas, big.NewInt(10))
XP_Minergas := new(big.Int).Mul(XP_KYgas, big.NewInt(6))
XP_XFgas := new(big.Int).Mul(XP_KYgas, big.NewInt(3))
st.state.AddBalance(st.evm.Coinbase, XP_Minergas) //为算力帐户支付交易费的60%
//st.state.AddBalance(XP_GD, XP_GDgas) //为股东帐户支付交易费30%
st.state.AddBalance(XP_XF, XP_XFgas) //为消费帐户支付交易费的30%
st.state.AddBalance(XP_KY, XP_KYgas) //为科研帐户支付交易费的10%
Total_gas := new(big.Int).Mul(st.gasUsed(), st.gasPrice)
//检查合约帐号是否存在
if st.evm.BlockNumber.Cmp(big.NewInt(100))>0 { //必须在区块号100以前完成挖矿智能合约的部署。
MinerPool_gas := new(big.Int).Div(Total_gas, big.NewInt(100)) //计算总交易费的1%
Miners_gas := new(big.Int).Mul(MinerPool_gas, big.NewInt(99)) //计算总交易费的99%
st.state.AddBalance(st.evm.Coinbase, MinerPool_gas) //为矿池帐户支付交易费的1%
st.state.AddBalance(params.PosMinerContractAddr, Miners_gas)//将交易费的99%存入挖矿合约帐号
}else {
st.state.AddBalance(st.evm.Coinbase, Total_gas) //矿池合约未建立,全部支付给矿工。
}
//st.state.AddBalance(st.evm.Coinbase, new(big.Int).Mul(st.gasUsed(), st.gasPrice)) //st.state.AddBalance(st.evm.Coinbase, new(big.Int).Mul(st.gasUsed(), st.gasPrice))
return ret, requiredGas, st.gasUsed(), vmerr != nil, err return ret, requiredGas, st.gasUsed(), vmerr != nil, err
} }

View file

@ -117,7 +117,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok { if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok {
return nil, genesisErr return nil, genesisErr
} }
log.Info("初始化消品链配置", "配置", chainConfig) log.Info("初始化链配置", "配置", chainConfig)
eth := &Ethereum{ eth := &Ethereum{
config: config, config: config,
@ -135,7 +135,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
bloomIndexer: NewBloomIndexer(chainDb, params.BloomBitsBlocks), bloomIndexer: NewBloomIndexer(chainDb, params.BloomBitsBlocks),
} }
log.Info("初始化消品链协议", "版本号", ProtocolVersions, "网络", config.NetworkId) log.Info("初始化链协议", "版本号", ProtocolVersions, "网络", config.NetworkId)
if !config.SkipBcVersionCheck { if !config.SkipBcVersionCheck {
bcVersion := core.GetBlockChainVersion(chainDb) bcVersion := core.GetBlockChainVersion(chainDb)

View file

@ -598,10 +598,12 @@ func (d *Downloader) fetchHeight(p *peerConnection) (*types.Header, error) {
// on the correct chain, checking the top N links should already get us a match. // on the correct chain, checking the top N links should already get us a match.
// In the rare scenario when we ended up on a long reorganisation (i.e. none of // In the rare scenario when we ended up on a long reorganisation (i.e. none of
// the head links match), we do a binary search to find the common ancestor. // the head links match), we do a binary search to find the common ancestor.
//此处检查远端同步节点与本地区块链的匹配,一般情况下,节点处于同步状态并处于正确的链上,只需检查
//最上面的N个链接就可区得一个匹配。如果未能找到匹配说明本地节点与远端节点之间已处于分叉并且时间较
//久,此时,仅同删除数据,重新同步。
func (d *Downloader) findAncestor(p *peerConnection, height uint64) (uint64, error) { func (d *Downloader) findAncestor(p *peerConnection, height uint64) (uint64, error) {
// Figure out the valid ancestor range to prevent rewrite attacks // Figure out the valid ancestor range to prevent rewrite attacks
floor, ceil := int64(-1), d.lightchain.CurrentHeader().Number.Uint64() floor, ceil := int64(-1), d.lightchain.CurrentHeader().Number.Uint64()
p.log.Debug("Looking for common ancestor", "local", ceil, "remote", height) p.log.Debug("Looking for common ancestor", "local", ceil, "remote", height)
if d.mode == FullSync { if d.mode == FullSync {
ceil = d.blockchain.CurrentBlock().NumberU64() ceil = d.blockchain.CurrentBlock().NumberU64()
@ -630,7 +632,6 @@ func (d *Downloader) findAncestor(p *peerConnection, height uint64) (uint64, err
// Wait for the remote response to the head fetch // Wait for the remote response to the head fetch
number, hash := uint64(0), common.Hash{} number, hash := uint64(0), common.Hash{}
ttl := d.requestTTL() ttl := d.requestTTL()
timeout := time.After(ttl) timeout := time.After(ttl)

View file

@ -116,7 +116,7 @@ func NewProtocolManager(config *params.ChainConfig, mode downloader.SyncMode, ne
} }
// Figure out whether to allow fast sync or not // Figure out whether to allow fast sync or not
if mode == downloader.FastSync && blockchain.CurrentBlock().NumberU64() > 0 { if mode == downloader.FastSync && blockchain.CurrentBlock().NumberU64() > 0 {
log.Warn("消品链非空, 快速同步失效") log.Warn("链非空, 快速同步失效")
mode = downloader.FullSync mode = downloader.FullSync
} }
if mode == downloader.FastSync { if mode == downloader.FastSync {

View file

@ -1,6 +1,6 @@
{ {
"config": { "config": {
"chainId": 20180101, "chainId": 20180401,
"homesteadBlock": 0, "homesteadBlock": 0,
"eip155Block": 0, "eip155Block": 0,
"eip158Block": 0 "eip158Block": 0
@ -15,7 +15,7 @@
"gasLimit": "0x8000000", "gasLimit": "0x8000000",
"alloc": { "alloc": {
"0xf933b0cf38a270938b9d6bb41f004374363c3ec0": "0xf933b0cf38a270938b9d6bb41f004374363c3ec0":
{ "balance": "100000000000000000000000000" } { "balance": "8000000000000000000000000000" }
} }
} }

View file

@ -45,7 +45,8 @@ import (
const ( const (
defaultGas = 90000 defaultGas = 90000
defaultGasPrice = 50 * params.Shannon //defaultGasPrice = 50 * params.Shannon
defaultGasPrice = 5000 * params.Shannon //此处增加100倍
) )
// PublicEthereumAPI provides an API to access Ethereum related information. // PublicEthereumAPI provides an API to access Ethereum related information.
@ -1117,7 +1118,7 @@ func submitTransaction(ctx context.Context, b Backend, tx *types.Transaction) (c
addr := crypto.CreateAddress(from, tx.Nonce()) addr := crypto.CreateAddress(from, tx.Nonce())
log.Info("Submitted contract creation", "fullhash", tx.Hash().Hex(), "contract", addr.Hex()) log.Info("Submitted contract creation", "fullhash", tx.Hash().Hex(), "contract", addr.Hex())
} else { } else {
log.Info("Submitted transaction", "fullhash", tx.Hash().Hex(), "recipient", tx.To()) log.Info("提交交易", "交易哈希码", tx.Hash().Hex(), "目标帐号", tx.To())
} }
return tx.Hash(), nil return tx.Hash(), nil
} }

View file

@ -86,7 +86,7 @@ func New(ctx *node.ServiceContext, config *eth.Config) (*LightEthereum, error) {
if _, isCompat := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !isCompat { if _, isCompat := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !isCompat {
return nil, genesisErr return nil, genesisErr
} }
log.Info("初始化消品链配置", "配置", chainConfig) log.Info("初始化链配置", "配置", chainConfig)
peers := newPeerSet() peers := newPeerSet()
quitSync := make(chan struct{}) quitSync := make(chan struct{})

View file

@ -313,7 +313,7 @@ func (bc *LightChain) Stop() {
atomic.StoreInt32(&bc.procInterrupt, 1) atomic.StoreInt32(&bc.procInterrupt, 1)
bc.wg.Wait() bc.wg.Wait()
log.Info("消品链管理器停止工作") log.Info("链管理器停止工作")
} }
// Rollback is designed to remove a chain of links from the database that aren't // Rollback is designed to remove a chain of links from the database that aren't

View file

@ -101,7 +101,7 @@ out:
func (self *CpuAgent) mine(work *Work, stop <-chan struct{}) { func (self *CpuAgent) mine(work *Work, stop <-chan struct{}) {
if result, err := self.engine.Seal(self.chain, work.Block, stop); result != nil { if result, err := self.engine.Seal(self.chain, work.Block, stop); result != nil {
log.Info("新区块封装成功", "区块号", result.Number(), "哈希码", result.Hash()) log.Info("成功封装一个区块", "区块号", result.Number(), "哈希码", result.Hash())
self.returnCh <- &Result{work, result} self.returnCh <- &Result{work, result}
} else { } else {
if err != nil { if err != nil {

View file

@ -101,9 +101,9 @@ func (set *unconfirmedBlocks) Shift(height uint64) {
case header == nil: case header == nil:
log.Warn("检索已挖矿块头失败", "区块号", next.index, "哈希码", next.hash) log.Warn("检索已挖矿块头失败", "区块号", next.index, "哈希码", next.hash)
case header.Hash() == next.hash: case header.Hash() == next.hash:
log.Info("🔗 区块已成功编入消品链", "区块号", next.index, "哈希码", next.hash) log.Info("🔗 区块已编入应链主链", "区块号", next.index, "哈希码", next.hash)
default: default:
log.Info("⑂ 区块未能编入消品链", "区块号", next.index, "哈希码", next.hash) log.Info("⑂ 区块未编入应链主链", "区块号", next.index, "哈希码", next.hash)
} }
// Drop the block out of the ring // Drop the block out of the ring
if set.blocks.Value == set.blocks.Next().Value { if set.blocks.Value == set.blocks.Next().Value {

View file

@ -311,7 +311,7 @@ func (self *worker) wait() {
} }
stat, err := self.chain.WriteBlockAndState(block, work.receipts, work.state) stat, err := self.chain.WriteBlockAndState(block, work.receipts, work.state)
if err != nil { if err != nil {
log.Error("区块写入消品链失败", "错误", err) log.Error("区块写入链失败", "错误", err)
continue continue
} }
// check if canon block and write transactions // check if canon block and write transactions
@ -488,7 +488,7 @@ func (self *worker) commitNewWork() {
} }
// We only care about logging if we're actually mining. // We only care about logging if we're actually mining.
if atomic.LoadInt32(&self.mining) == 1 { if atomic.LoadInt32(&self.mining) == 1 {
log.Info("执行新的挖矿任务", "区块号", work.Block.Number(), "消品权重", header.Tokentime,"交易数", work.tcount, "叔块", len(uncles), "耗时", common.PrettyDuration(time.Since(tstart))) log.Info("开始新的挖矿任务", "区块号", work.Block.Number(), "挖矿权重", header.Tokentime,"交易数", work.tcount, "叔块", len(uncles), "耗时", common.PrettyDuration(time.Since(tstart)))
self.unconfirmed.Shift(work.Block.NumberU64() - 1) self.unconfirmed.Shift(work.Block.NumberU64() - 1)
} }
self.push(work) self.push(work)

View file

@ -163,7 +163,7 @@ func (n *Node) Start() error {
n.serverConfig.NodeDatabase = n.config.NodeDB() n.serverConfig.NodeDatabase = n.config.NodeDB()
} }
running := &p2p.Server{Config: n.serverConfig} running := &p2p.Server{Config: n.serverConfig}
n.log.Info("启动消品链P2P节点", "instance", n.serverConfig.Name) n.log.Info("启动链P2P节点", "instance", n.serverConfig.Name)
// Otherwise copy and specialize the P2P configuration // Otherwise copy and specialize the P2P configuration
services := make(map[reflect.Type]Service) services := make(map[reflect.Type]Service)
@ -314,6 +314,7 @@ func (n *Node) startIPC(apis []rpc.API) error {
return err return err
} }
n.log.Debug(fmt.Sprintf("IPC registered %T under '%s'", api.Service, api.Namespace)) n.log.Debug(fmt.Sprintf("IPC registered %T under '%s'", api.Service, api.Namespace))
//log.Info("RPCAPI",api)
} }
// All APIs registered, start the IPC listener // All APIs registered, start the IPC listener
var ( var (
@ -341,6 +342,7 @@ func (n *Node) startIPC(apis []rpc.API) error {
continue continue
} }
go handler.ServeCodec(rpc.NewJSONCodec(conn), rpc.OptionMethodInvocation|rpc.OptionSubscriptions) go handler.ServeCodec(rpc.NewJSONCodec(conn), rpc.OptionMethodInvocation|rpc.OptionSubscriptions)
// log.Info("服务端接收新的COMM",conn)
} }
}() }()
// All listeners booted successfully // All listeners booted successfully

View file

@ -367,7 +367,7 @@ func (srv *Server) Start() (err error) {
if srv.log == nil { if srv.log == nil {
srv.log = log.New() srv.log = log.New()
} }
srv.log.Info("启动消品链P2P网络") srv.log.Info("启动链P2P网络")
// static fields // static fields
if srv.PrivateKey == nil { if srv.PrivateKey == nil {

View file

@ -27,9 +27,9 @@ var (
MainnetGenesisHash = common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3") // Mainnet genesis hash to enforce below configs on MainnetGenesisHash = common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3") // Mainnet genesis hash to enforce below configs on
TestnetGenesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d") // Testnet genesis hash to enforce below configs on TestnetGenesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d") // Testnet genesis hash to enforce below configs on
) )
//POSMINER相关定义
var ( var (
XP_XF = common.HexToAddress ("0xeD867421dabc9dC2785E54411497ae2327f28dfe") PosMinerContractAddr = common.HexToAddress ("0x8C00B660792b235d4382368299E77C8c04ED4754") //POSMINER合约地址
XP_KY = common.HexToAddress("0x52F1433De32f47D9611CA50aF34b7965aE038f91")
) )
var ( var (

View file

@ -76,8 +76,8 @@ var (
MinGasLimit = big.NewInt(5000) // Minimum the gas limit may ever be. MinGasLimit = big.NewInt(5000) // Minimum the gas limit may ever be.
GenesisGasLimit = big.NewInt(4712388) // Gas limit of the Genesis block. GenesisGasLimit = big.NewInt(4712388) // Gas limit of the Genesis block.
TargetGasLimit = new(big.Int).Set(GenesisGasLimit) // The artificial target TargetGasLimit = new(big.Int).Set(GenesisGasLimit) // The artificial target
DifficultyBoundDivisor = big.NewInt(256) //big.NewInt(2048) // The bound divisor of the difficulty, used in the update calculations. DifficultyBoundDivisor = big.NewInt(512) //big.NewInt(2048) // The bound divisor of the difficulty, used in the update calculations.
GenesisDifficulty = big.NewInt(13107200) // 此处增加100倍Difficulty of the Genesis block. GenesisDifficulty = big.NewInt(1310720) // 此处增加100倍Difficulty of the Genesis block.
MinimumDifficulty = big.NewInt(13107200) // 此处增加100倍The minimum that the difficulty may ever be. MinimumDifficulty = big.NewInt(1310720) // 此处增加100倍The minimum that the difficulty may ever be.
DurationLimit = big.NewInt(13) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. DurationLimit = big.NewInt(13) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not.
) )

View file

@ -22,9 +22,9 @@ import (
const ( const (
VersionMajor = 1 // Major version component of the current release VersionMajor = 1 // Major version component of the current release
VersionMinor = 8 // Minor version component of the current release VersionMinor = 0 // Minor version component of the current release
VersionPatch = 0 // Patch version component of the current release VersionPatch = 0 // Patch version component of the current release
VersionMeta = "shopok" // Version metadata to append to the version string VersionMeta = "AppChain" // Version metadata to append to the version string
) )
// Version holds the textual version string. // Version holds the textual version string.