storage: begin implementing sqlite3 storage

This commit is contained in:
George Tankersley
2018-11-18 03:02:49 +00:00
parent 7cc7095a81
commit 0dee0b425e
9 changed files with 158 additions and 3 deletions

View File

@@ -35,6 +35,15 @@ func (b *block) getEncodableHash() []byte {
return b.hdr.getEncodableHash()
}
func (b *block) HasSaplingTransactions() bool {
for _, tx := range b.vtx {
if tx.HasSaplingTransactions() {
return true
}
}
return false
}
// GetHeight() extracts the block height from the coinbase transaction. See
// BIP34. Returns block height on success, or -1 on error.
func (b *block) GetHeight() int {

View File

@@ -6,7 +6,6 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
"testing"
@@ -57,12 +56,12 @@ func TestCompactBlocks(t *testing.T) {
blockJSON, err := ioutil.ReadFile("testdata/compact_blocks.json")
if err != nil {
log.Fatal(err)
t.Fatal(err)
}
err = json.Unmarshal(blockJSON, &compactTests)
if err != nil {
log.Fatal(err)
t.Fatal(err)
}
for _, test := range compactTests {

View File

@@ -296,6 +296,10 @@ func (tx *transaction) getEncodableHash() []byte {
return digest[:]
}
func (tx *transaction) HasSaplingTransactions() bool {
return tx.version >= 4 && (len(tx.shieldedSpends)+len(tx.shieldedOutputs)) > 0
}
func (tx *transaction) ToCompact(index int) *proto.CompactTx {
ctx := &proto.CompactTx{
Index: uint64(index), // index is contextual