Skip to content

Commit 3b7bffc

Browse files
committed
Rename serialization methods from Data() to Bytes()
1 parent bd93f74 commit 3b7bffc

File tree

7 files changed

+22
-22
lines changed

7 files changed

+22
-22
lines changed

kernel/block.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ func (b *Block) Hash() (*BlockHash, error) {
4747
return hash, nil
4848
}
4949

50-
// Data returns the serialized block data
51-
func (b *Block) Data() ([]byte, error) {
50+
// Bytes returns the serialized block
51+
func (b *Block) Bytes() ([]byte, error) {
5252
checkReady(b)
5353

5454
// Use the callback helper to collect bytes from btck_block_to_bytes

kernel/block_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ func TestBlockFromRaw(t *testing.T) {
5454
t.Logf("Expected hash: %s", expectedHash)
5555
}
5656

57-
// Test getting block data
58-
data, err := block.Data()
57+
// Test getting the serialized block
58+
data, err := block.Bytes()
5959
if err != nil {
60-
t.Fatalf("Block.Data() error = %v", err)
60+
t.Fatalf("Block.Bytes() error = %v", err)
6161
}
6262

6363
if len(data) != len(genesisBytes) {

kernel/script_pubkey.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ func NewScriptPubkeyFromRaw(rawScriptPubkey []byte) (*ScriptPubkey, error) {
3131
return scriptPubkey, nil
3232
}
3333

34-
// Data returns the serialized script pubkey data
35-
func (s *ScriptPubkey) Data() ([]byte, error) {
34+
// Bytes returns the serialized script pubkey
35+
func (s *ScriptPubkey) Bytes() ([]byte, error) {
3636
checkReady(s)
3737

3838
return writeToBytes(func(writer C.btck_WriteBytes, user_data unsafe.Pointer) C.int {

kernel/script_pubkey_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ func TestScriptPubkeyFromRaw(t *testing.T) {
2727
}
2828
defer scriptPubkey.Destroy()
2929

30-
// Test getting script pubkey data
31-
data, err := scriptPubkey.Data()
30+
// Test getting the serialized script pubkey
31+
data, err := scriptPubkey.Bytes()
3232
if err != nil {
33-
t.Fatalf("ScriptPubkey.Data() error = %v", err)
33+
t.Fatalf("ScriptPubkey.Bytes() error = %v", err)
3434
}
3535

3636
if len(data) != len(scriptBytes) {
@@ -71,22 +71,22 @@ func TestScriptPubkeyCopy(t *testing.T) {
7171
}
7272

7373
// Verify copy has same data
74-
originalData, err := scriptPubkey.Data()
74+
originalData, err := scriptPubkey.Bytes()
7575
if err != nil {
76-
t.Fatalf("Original ScriptPubkey.Data() error = %v", err)
76+
t.Fatalf("Original ScriptPubkey.Bytes() error = %v", err)
7777
}
7878

79-
copyData, err := scriptCopy.Data()
79+
copyData, err := scriptCopy.Bytes()
8080
if err != nil {
81-
t.Fatalf("Copied ScriptPubkey.Data() error = %v", err)
81+
t.Fatalf("Copied ScriptPubkey.Bytes() error = %v", err)
8282
}
8383

8484
if hex.EncodeToString(originalData) != hex.EncodeToString(copyData) {
8585
t.Error("Copied script pubkey data doesn't match original")
8686
}
8787
}
8888

89-
func TestScriptPubkeyData(t *testing.T) {
89+
func TestScriptPubkeyBytes(t *testing.T) {
9090
scriptHex := "76a914389ffce9cd9ae88dcc0631e88a821ffdbe9bfe26158088ac"
9191
scriptBytes, err := hex.DecodeString(scriptHex)
9292
if err != nil {
@@ -100,9 +100,9 @@ func TestScriptPubkeyData(t *testing.T) {
100100
defer scriptPubkey.Destroy()
101101

102102
// Test serializing script to bytes
103-
serialized, err := scriptPubkey.Data()
103+
serialized, err := scriptPubkey.Bytes()
104104
if err != nil {
105-
t.Fatalf("ScriptPubkey.Data() error = %v", err)
105+
t.Fatalf("ScriptPubkey.Bytes() error = %v", err)
106106
}
107107

108108
if len(serialized) == 0 {

kernel/transaction_output_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ func TestTransactionOutputCreation(t *testing.T) {
5050
}
5151
defer gotScript.Destroy()
5252

53-
scriptData, err := gotScript.Data()
53+
scriptData, err := gotScript.Bytes()
5454
if err != nil {
55-
t.Fatalf("ScriptPubkey.Data() error = %v", err)
55+
t.Fatalf("ScriptPubkey.Bytes() error = %v", err)
5656
}
5757

5858
if len(scriptData) != len(scriptBytes) {

kernel/validation_interface_callbacks.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ func (bp *BlockPointer) GetHash() (*BlockHash, error) {
4747
return &BlockHash{ptr: hashPtr}, nil
4848
}
4949

50-
// CopyData copies the block data into a byte array
51-
func (bp *BlockPointer) CopyData() ([]byte, error) {
50+
// Bytes returns the serialized block
51+
func (bp *BlockPointer) Bytes() ([]byte, error) {
5252
if bp.ptr == nil {
5353
return nil, ErrBlockUninitialized
5454
}

kernel/validation_interface_callbacks_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func TestValidationInterfaceCallbacks(t *testing.T) {
1515
blockCheckedCalled = true
1616
lastValidationMode = state.ValidationMode()
1717
var err error
18-
lastBlockData, err = block.CopyData()
18+
lastBlockData, err = block.Bytes()
1919
if err != nil {
2020
t.Fatal(err)
2121
}

0 commit comments

Comments
 (0)