Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
2bb562c2
Y
YTBP
项目概览
YottaChain
/
YTBP
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
YTBP
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
2bb562c2
编写于
5月 29, 2018
作者:
D
Daniel Larimer
提交者:
GitHub
5月 29, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into more_fuzz
上级
889a9ea8
7218ea5d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
42 addition
and
27 deletion
+42
-27
plugins/chain_plugin/chain_plugin.cpp
plugins/chain_plugin/chain_plugin.cpp
+28
-15
tests/testUtils.py
tests/testUtils.py
+14
-12
未找到文件。
plugins/chain_plugin/chain_plugin.cpp
浏览文件 @
2bb562c2
...
...
@@ -176,6 +176,26 @@ if( options.count(name) ) { \
std::copy(ops.begin(), ops.end(), std::inserter(container, container.end())); \
}
fc
::
time_point
calculate_genesis_timestamp
(
string
tstr
)
{
fc
::
time_point
genesis_timestamp
;
if
(
strcasecmp
(
tstr
.
c_str
(),
"now"
)
==
0
)
{
genesis_timestamp
=
fc
::
time_point
::
now
();
}
else
{
genesis_timestamp
=
time_point
::
from_iso_string
(
tstr
);
}
auto
epoch_us
=
genesis_timestamp
.
time_since_epoch
().
count
();
auto
diff_us
=
epoch_us
%
config
::
block_interval_us
;
if
(
diff_us
>
0
)
{
auto
delay_us
=
(
config
::
block_interval_us
-
diff_us
);
genesis_timestamp
+=
fc
::
microseconds
(
delay_us
);
dlog
(
"pausing ${us} microseconds to the next interval"
,(
"us"
,
delay_us
));
}
ilog
(
"Adjusting genesis timestamp to ${timestamp}"
,
(
"timestamp"
,
genesis_timestamp
)
);
return
genesis_timestamp
;
}
void
chain_plugin
::
plugin_initialize
(
const
variables_map
&
options
)
{
ilog
(
"initializing chain plugin"
);
...
...
@@ -299,7 +319,7 @@ void chain_plugin::plugin_initialize(const variables_map& options) {
}
if
(
options
.
count
(
"genesis-json"
)
)
{
FC_ASSERT
(
!
fc
::
exists
(
my
->
blocks_dir
/
"blocks.log"
),
"Genesis
State can only be specified
on a fresh blockchain."
);
FC_ASSERT
(
!
fc
::
exists
(
my
->
blocks_dir
/
"blocks.log"
),
"Genesis
state can only be set
on a fresh blockchain."
);
auto
genesis_file
=
options
.
at
(
"genesis-json"
).
as
<
bfs
::
path
>
();
if
(
genesis_file
.
is_relative
()
)
{
...
...
@@ -315,23 +335,16 @@ void chain_plugin::plugin_initialize(const variables_map& options) {
ilog
(
"Using genesis state provided in '${genesis}'"
,
(
"genesis"
,
genesis_file
.
generic_string
())
);
if
(
options
.
count
(
"genesis-timestamp"
)
)
{
string
tstr
=
options
.
at
(
"genesis-timestamp"
).
as
<
string
>
();
if
(
strcasecmp
(
tstr
.
c_str
(),
"now"
)
==
0
)
{
my
->
chain_config
->
genesis
.
initial_timestamp
=
fc
::
time_point
::
now
();
auto
epoch_us
=
my
->
chain_config
->
genesis
.
initial_timestamp
.
time_since_epoch
().
count
();
auto
diff_us
=
epoch_us
%
config
::
block_interval_us
;
if
(
diff_us
>
0
)
{
auto
delay_us
=
(
config
::
block_interval_us
-
diff_us
);
my
->
chain_config
->
genesis
.
initial_timestamp
+=
fc
::
microseconds
(
delay_us
);
dlog
(
"pausing ${us} microseconds to the next interval"
,(
"us"
,
delay_us
));
}
}
else
{
my
->
chain_config
->
genesis
.
initial_timestamp
=
time_point
::
from_iso_string
(
tstr
);
}
ilog
(
"Adjusting genesis timestamp to ${timestamp}"
,
(
"timestamp"
,
my
->
chain_config
->
genesis
.
initial_timestamp
)
);
my
->
chain_config
->
genesis
.
initial_timestamp
=
calculate_genesis_timestamp
(
options
.
at
(
"genesis-timestamp"
).
as
<
string
>
()
);
}
wlog
(
"Starting up fresh blockchain with provided genesis state."
);
}
else
if
(
options
.
count
(
"genesis-timestamp"
)
)
{
FC_ASSERT
(
!
fc
::
exists
(
my
->
blocks_dir
/
"blocks.log"
),
"Genesis state can only be set on a fresh blockchain."
);
my
->
chain_config
->
genesis
.
initial_timestamp
=
calculate_genesis_timestamp
(
options
.
at
(
"genesis-timestamp"
).
as
<
string
>
()
);
wlog
(
"Starting up fresh blockchain with default genesis state but with adjusted genesis timestamp."
);
}
else
if
(
fc
::
is_regular_file
(
my
->
blocks_dir
/
"blocks.log"
)
)
{
my
->
chain_config
->
genesis
=
block_log
::
extract_genesis_state
(
my
->
blocks_dir
);
}
else
{
...
...
tests/testUtils.py
浏览文件 @
2bb562c2
...
...
@@ -448,7 +448,7 @@ class Node(object):
Utils
.
Print
(
"transaction parsing failed. Transaction: %s"
%
(
trans
))
raise
headBlockNum
=
self
.
get
Irreversible
BlockNum
()
headBlockNum
=
self
.
get
Head
BlockNum
()
assert
(
headBlockNum
)
try
:
headBlockNum
=
int
(
headBlockNum
)
...
...
@@ -706,8 +706,8 @@ class Node(object):
return
ret
def
waitForNextBlock
(
self
,
timeout
=
None
):
num
=
self
.
get
Irreversible
BlockNum
()
lam
=
lambda
:
self
.
get
Irreversible
BlockNum
()
>
num
num
=
self
.
get
Head
BlockNum
()
lam
=
lambda
:
self
.
get
Head
BlockNum
()
>
num
ret
=
Utils
.
waitForBool
(
lam
,
timeout
)
return
ret
...
...
@@ -833,7 +833,7 @@ class Node(object):
msg
=
ex
.
output
.
decode
(
"utf-8"
)
Utils
.
Print
(
"ERROR: Exception during actions by account retrieval. %s"
%
(
msg
))
return
None
# Gets accounts mapped to key. Returns array
def
getAccountsArrByKey
(
self
,
key
):
trans
=
self
.
getAccountsByKey
(
key
)
...
...
@@ -1032,6 +1032,7 @@ class Node(object):
headBlockNumTag
=
"head_block_num"
return
info
[
headBlockNumTag
]
else
:
# Either this implementation or the one in getIrreversibleBlockNum are likely wrong.
block
=
self
.
getBlockFromDb
(
-
1
)
if
block
is
not
None
:
blockNum
=
block
[
"block_num"
]
...
...
@@ -1044,6 +1045,7 @@ class Node(object):
if
info
is
not
None
:
return
info
[
"last_irreversible_block_num"
]
else
:
# Either this implementation or the one in getHeadBlockNum are likely wrong.
block
=
self
.
getBlockFromDb
(
-
1
)
if
block
is
not
None
:
blockNum
=
block
[
"block_num"
]
...
...
@@ -1104,7 +1106,7 @@ class Node(object):
self
.
killed
=
False
return
True
###########################################################################################
Wallet
=
namedtuple
(
"Wallet"
,
"name password host port"
)
...
...
@@ -1291,7 +1293,7 @@ class Cluster(object):
__localHost
=
"localhost"
__BiosHost
=
"localhost"
__BiosPort
=
8788
# pylint: disable=too-many-arguments
# walletd [True|False] Is keosd running. If not load the wallet plugin
def
__init__
(
self
,
walletd
=
False
,
localCluster
=
True
,
host
=
"localhost"
,
port
=
8888
,
walletHost
=
"localhost"
,
walletPort
=
8899
,
enableMongo
=
False
,
mongoHost
=
"localhost"
,
mongoPort
=
27017
,
mongoDb
=
"EOStest"
,
defproduceraPrvtKey
=
None
,
defproducerbPrvtKey
=
None
,
staging
=
False
):
...
...
@@ -1370,8 +1372,8 @@ class Cluster(object):
if
len
(
self
.
nodes
)
>
0
:
raise
RuntimeError
(
"Cluster already running."
)
cmd
=
"%s -p %s -n %s -s %s -d %s -f --p2p-plugin bnet"
%
(
Utils
.
EosLauncherPath
,
pnodes
,
totalNodes
,
topo
,
delay
)
cmd
=
"%s -p %s -n %s -s %s -d %s -
i %s -
f --p2p-plugin bnet"
%
(
Utils
.
EosLauncherPath
,
pnodes
,
totalNodes
,
topo
,
delay
,
datetime
.
datetime
.
utcnow
().
strftime
(
"%Y-%m-%dT%H:%M:%S.%f"
)[:
-
3
]
)
cmdArr
=
cmd
.
split
()
if
self
.
staging
:
cmdArr
.
append
(
"--nogen"
)
...
...
@@ -1782,7 +1784,7 @@ class Cluster(object):
m
=
re
.
search
(
r
"node_([\d]+)"
,
name
)
return
int
(
m
.
group
(
1
))
@
staticmethod
def
parseProducerKeys
(
configFile
,
nodeName
):
"""Parse node config file for producer keys. Returns dictionary. (Keys: account name; Values: dictionary objects (Keys: ["name", "node", "private","public"]; Values: account name, node id returned by nodeNameToId(nodeName), private key(string)and public key(string)))."""
...
...
@@ -1975,7 +1977,7 @@ class Cluster(object):
if
trans
is
None
:
Utils
.
Print
(
"ERROR: Failed to create account %s"
%
(
eosioTokenAccount
.
name
))
return
False
eosioRamAccount
=
copy
.
deepcopy
(
eosioAccount
)
eosioRamAccount
.
name
=
"eosio.ram"
trans
=
biosNode
.
createAccount
(
eosioRamAccount
,
eosioAccount
,
0
)
...
...
@@ -2010,7 +2012,7 @@ class Cluster(object):
if
trans
is
None
:
Utils
.
Print
(
"ERROR: Failed to publish contract %s."
%
(
contract
))
return
False
# Create currency0000, followed by issue currency0000
contract
=
eosioTokenAccount
.
name
Utils
.
Print
(
"push create action to %s contract"
%
(
contract
))
...
...
@@ -2089,7 +2091,7 @@ class Cluster(object):
return
True
# Populates list of EosInstanceInfo objects, matched to actual running instances
def
discoverLocalNodes
(
self
,
totalNodes
,
timeout
=
0
):
nodes
=
[]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录