Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FISCO BCOS plugin #20

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

FISCO BCOS plugin #20

wants to merge 5 commits into from

Conversation

cuiyuchain
Copy link

实现了通用区块链性能测试平台Hyperbench对于FISCO BCOS 2.x以及3.x的适配,基于go语言开发了fisco-bcos plugin以及benchmark用例

"log"
"path"
"strings"
"time"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按照系统依赖、其他依赖用空格对导入的包进行分类,详细可参考其他链的插件实现的导包分类

}

path_cert := configPath + "/sdk.crt"
data_cert, err := ioutil.ReadFile(path_cert)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

上述需要从configPath路径下读取的配置文件,需要在使用手册中增加说明。另有由于文件名是固定写死的,那么使用手册中也应说明配置路径下文件的命名形式。避免由于使用时命名不同导致读取出错

GroupID: 1,
NodeURL: "127.0.0.1:20200",
}
path_priv := configPath + "/accounts/0x48eac900f9e862c94e1e38ec205b6a991a349217.pem"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

上述文件路径、节点地址、账户私钥等都是固定写死的,应写成可通过配置文件配置的

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

会导致viper出现冲突和覆盖

}
func (f *FISCO) DeployContract() error {
fmt.Println("======================Deploy Contract ======================")
if f.BlockchainBase.ContractPath != "" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

日志可通过BlockchainBase中的logger输出

f.contract.parsedAbi = parsed

input := "Store deployment 1.0"
contractAddress, tx, contractInstance, err := DeployStore(f.Cli.GetTransactOpts(), f.Cli, input)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

部署合约的入参这样使用写死没问题吗,还是这里部署的是一个写死的合约?


// contract write interface
key := [32]byte{}
value := [32]byte{}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

定义成常量

copy(key[:], bytesArgs[0])
copy(value[:], bytesArgs[1])

tx, receipt, err := storeSession.SetItem(key, value)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这是只能执行setHash类似的合约吗,我们预期的是可以部署任意合约,根据部署的合约调用合约中的函数,而不是固定的某一个合约。

另这里还需要注意判断一下参数的长度,避免panic

endTime := time.Now().UnixNano()

fmt.Printf("tx sent: %s\n", tx.Hash().Hex())
fmt.Printf("transaction hash of receipt: %s\n", receipt.GetTransactionHash())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

使用logger打印

f.Logger.Errorf("can not unmarshal msg: %v \n err: %v", context, err)
return err
}
return nil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里unmarshal出来的msg并没有用到

duration := float64(to - from)

for i := statistic.From.BlockHeight; i < statistic.To.BlockHeight; i++ {
block, err := f.Cli.GetBlockByNumber(context.Background(), i, true) // includeTx不知道传入什么
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里只需要统计有多少区块,每个区块有多少比交易。不需要交易的详细内容,可根据接口实际情况进行传参

@liuxiaomeiG
Copy link
Collaborator

有了fisco-bcos3这个文件夹目录,为什么外层还要放config.toml,以及cert、account等相关配置。如果用不上就删除

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants