io: add type-specific read/write methods
This seriously improves the serialization/deserialization performance for several reasons: * no time spent in `binary` reflection * no memory allocations being made on every read/write * uses fast ReadBytes everywhere it's appropriate It also makes Fixed8 Serializable just for convenience.
This commit is contained in:
parent
89d7f6d26e
commit
54d888ba70
43 changed files with 441 additions and 205 deletions
|
@ -22,9 +22,7 @@ func TestCreateMultiSigRedeemScript(t *testing.T) {
|
|||
}
|
||||
|
||||
br := io.NewBinReaderFromBuf(out)
|
||||
var b uint8
|
||||
br.ReadLE(&b)
|
||||
assert.Equal(t, opcode.PUSH3, opcode.Opcode(b))
|
||||
assert.Equal(t, opcode.PUSH3, opcode.Opcode(br.ReadByte()))
|
||||
|
||||
for i := 0; i < len(validators); i++ {
|
||||
bb := br.ReadVarBytes()
|
||||
|
@ -34,8 +32,6 @@ func TestCreateMultiSigRedeemScript(t *testing.T) {
|
|||
assert.Equal(t, validators[i].Bytes(), bb)
|
||||
}
|
||||
|
||||
br.ReadLE(&b)
|
||||
assert.Equal(t, opcode.PUSH3, opcode.Opcode(b))
|
||||
br.ReadLE(&b)
|
||||
assert.Equal(t, opcode.CHECKMULTISIG, opcode.Opcode(b))
|
||||
assert.Equal(t, opcode.PUSH3, opcode.Opcode(br.ReadByte()))
|
||||
assert.Equal(t, opcode.CHECKMULTISIG, opcode.Opcode(br.ReadByte()))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue