From fbdd5eccaed9c24a78a42a2eae19eca47a198b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E6=98=BE=E6=9D=BE?= Date: Mon, 14 Dec 2020 19:14:08 +0800 Subject: [PATCH] =?UTF-8?q?BBC=20API=20=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/bbc/tx_builder.go | 28 ++++++++++++++++++++-------- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/core/bbc/tx_builder.go b/core/bbc/tx_builder.go index ed88944..ec20ad2 100644 --- a/core/bbc/tx_builder.go +++ b/core/bbc/tx_builder.go @@ -107,20 +107,32 @@ func (b *TxBuilder) SetFee(fee float64) *TxBuilder { return b } -// SetData 原始data设置,参考 UtilDataEncoding -func (b *TxBuilder) SetData(data []byte) *TxBuilder { - b.TXBuilder.SetData(data) +// SetRawData 原始data设置,需自行编码uuid time等 +func (b *TxBuilder) SetRawData(data []byte) *TxBuilder { + b.TXBuilder.SetRawData(data) return b } -// SetDataWithUUID 指定uuid,timestamp,data -func (b *TxBuilder) SetDataWithUUID(_uuid string, timestamp int64, data string) *TxBuilder { - b.TXBuilder.SetDataWithUUID(_uuid, timestamp, data) +// SetDataWithUUID 该函数已废弃,请使用SetDataWith +func (b *TxBuilder) SetDataWithUUID(_uuid string, timestamp int64, data []byte) *TxBuilder { + b.TXBuilder.SetErr(errors.New("该函数已废弃,请使用SetDataWith")) return b } -// SetStringData 自动编码数据,自动生成uuid和时间戳 +// SetDataWith 指定uuid,timestamp,data, , dataFmtDesc: 空字符串或格式如 JSON +func (b *TxBuilder) SetDataWith(_uuid string, timestamp int64, dataFmtDesc string, data []byte) *TxBuilder { + b.TXBuilder.SetDataWith(_uuid, timestamp, dataFmtDesc, data) + return b +} + +// SetStringData 该函数已废弃,请使用SetData func (b *TxBuilder) SetStringData(data string) *TxBuilder { - b.TXBuilder.SetStringData(data) + b.TXBuilder.SetErr(errors.New("该函数已废弃,请使用SetData")) + return b +} + +// SetData 自动编码数据,自动生成uuid和时间戳, dataFmtDesc: 空字符串或格式如 JSON +func (b *TxBuilder) SetData(dataFmtDesc string, data []byte) *TxBuilder { + b.TXBuilder.SetData(dataFmtDesc, data) return b } diff --git a/go.mod b/go.mod index 0595b7d..bdcabef 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/cespare/cp v1.1.1 // indirect github.com/dabankio/bbrpc v1.2.0-beta.9 github.com/dabankio/devtools4chains v0.1.1-beta.2020091203 - github.com/dabankio/gobbc v1.0.15 + github.com/dabankio/gobbc v1.0.18 github.com/davecgh/go-spew v1.1.1 github.com/edsrzf/mmap-go v1.0.0 // indirect github.com/ethereum/go-ethereum v1.9.20 diff --git a/go.sum b/go.sum index ba41910..3f063b9 100644 --- a/go.sum +++ b/go.sum @@ -84,8 +84,8 @@ github.com/dabankio/bbrpc v1.2.0-beta.9 h1:NLNBjgpKUHXKicRxwM0SKfSUyhOl9xWR6aoA4 github.com/dabankio/bbrpc v1.2.0-beta.9/go.mod h1:Bf/Qbhd4l/+gk7ezUgnsr8xntOm6asjEj44hInMtHPg= github.com/dabankio/devtools4chains v0.1.1-beta.2020091203 h1:nb2CedxLzAe4TXYbVjEP3z3kPSJjtfeyZv6TmFPnlXA= github.com/dabankio/devtools4chains v0.1.1-beta.2020091203/go.mod h1:Oyk5lNDLSTHlYv41kfXki3Hy+t/UL5Jij75Eop8syd8= -github.com/dabankio/gobbc v1.0.15 h1:BZx/n9ozGo4Q+p5iiHWJO3OroqQO0gq4kgAtqR1GSt4= -github.com/dabankio/gobbc v1.0.15/go.mod h1:Ylc42lFMYJCaSodmQifwfLwhovMaxDiC/Ub1hIP7AQE= +github.com/dabankio/gobbc v1.0.18 h1:qUX0ZYOFDmbvoDIoBBaz52XvkNNVh7U9GmA7CWT42aQ= +github.com/dabankio/gobbc v1.0.18/go.mod h1:Ylc42lFMYJCaSodmQifwfLwhovMaxDiC/Ub1hIP7AQE= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=