Switch bytes.Buffer to Reader where possible.
bytes.Reader is a little bit more efficient than a bytes.Buffer when just reading, so in situations where only an io.Reader is needed (for Block and Tx deserialization), switch to a bytes.Reader. ok @davecgh
This commit is contained in:
parent
c54649be41
commit
9a3f83d493
2 changed files with 2 additions and 2 deletions
2
block.go
2
block.go
|
@ -208,7 +208,7 @@ func NewBlock(msgBlock *btcwire.MsgBlock) *Block {
|
|||
func NewBlockFromBytes(serializedBlock []byte) (*Block, error) {
|
||||
// Deserialize the bytes into a MsgBlock.
|
||||
var msgBlock btcwire.MsgBlock
|
||||
br := bytes.NewBuffer(serializedBlock)
|
||||
br := bytes.NewReader(serializedBlock)
|
||||
err := msgBlock.Deserialize(br)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
2
tx.go
2
tx.go
|
@ -74,7 +74,7 @@ func NewTx(msgTx *btcwire.MsgTx) *Tx {
|
|||
func NewTxFromBytes(serializedTx []byte) (*Tx, error) {
|
||||
// Deserialize the bytes into a MsgTx.
|
||||
var msgTx btcwire.MsgTx
|
||||
br := bytes.NewBuffer(serializedTx)
|
||||
br := bytes.NewReader(serializedTx)
|
||||
err := msgTx.Deserialize(br)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Reference in a new issue