Skip to content

Commit

Permalink
BBC API 改进
Browse files Browse the repository at this point in the history
  • Loading branch information
孙显松 committed Dec 14, 2020
1 parent 87d56c5 commit fbdd5ec
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
28 changes: 20 additions & 8 deletions core/bbc/tx_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit fbdd5ec

Please sign in to comment.