Browse Source

rpc: update for API and protobuf changes

wip_broken_chromebook
George Tankersley 6 years ago
parent
commit
38d61b509c
  1. 15
      go.mod
  2. 20
      go.sum
  3. 24
      parser/block.go
  4. 4
      parser/block_header.go
  5. 2
      parser/block_header_test.go
  6. 4
      parser/block_test.go
  7. 12
      parser/testdata/compact_blocks.json
  8. 27
      parser/transaction.go
  9. 100
      rpc/compact_formats.pb.go
  10. 2
      rpc/compact_formats.proto
  11. 2
      rpc/generate.go
  12. 149
      rpc/service.pb.go
  13. 2
      rpc/service.proto
  14. 24
      storage/sqlite3.go
  15. 4
      storage/sqlite3_test.go
  16. 12
      storage/testdata/compact_blocks.json

15
go.mod

@ -1,11 +1,20 @@
module github.com/gtank/ctxd
require (
github.com/dvyukov/go-fuzz v0.0.0-20180902053217-4aff8368ef19 // indirect
cloud.google.com/go v0.33.1 // indirect
github.com/golang/lint v0.0.0-20181026193005-c67002cb31c3 // indirect
github.com/golang/protobuf v1.2.0
github.com/mattn/go-sqlite3 v1.10.0
github.com/pebbe/zmq4 v1.0.0
github.com/pkg/errors v0.8.0
golang.org/x/net v0.0.0-20180926154720-4dfa2610cdf3
google.golang.org/grpc v1.15.0
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3 // indirect
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890 // indirect
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f // indirect
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35 // indirect
golang.org/x/tools v0.0.0-20181204185109-3832e276fb48 // indirect
google.golang.org/appengine v1.3.0 // indirect
google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898 // indirect
google.golang.org/grpc v1.16.0
honnef.co/go/tools v0.0.0-20180920025451-e3ad64cb4ed3 // indirect
)

20
go.sum

@ -1,10 +1,10 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.33.1/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/dvyukov/go-fuzz v0.0.0-20180902053217-4aff8368ef19 h1:5cILK9eRg5plZe3r/1tGYjiET+0CrVfYE4Pk9fxDiHA=
github.com/dvyukov/go-fuzz v0.0.0-20180902053217-4aff8368ef19/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E=
github.com/golang/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
@ -16,20 +16,36 @@ github.com/pebbe/zmq4 v1.0.0/go.mod h1:7N4y5R18zBiu3l0vajMUWQgZyjv464prE8RCyBcmn
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180926154720-4dfa2610cdf3 h1:dgd4x4kJt7G4k4m93AYLzM8Ni6h2qLTfh9n9vXJT3/0=
golang.org/x/net v0.0.0-20180926154720-4dfa2610cdf3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181106065722-10aee1819953/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc h1:a3CU5tJYVj92DY2LaA1kUkrsqD5/3mLDhx2NcNqyW+0=
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522 h1:Ve1ORMCxvRmSXBwJK+t3Oy+V2vRW2OetUQBq4rJIkZE=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35 h1:YAFjXN64LMvktoUZH9zgY4lGc/msGN7HQfoSuKCgaDU=
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181204185109-3832e276fb48/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898 h1:yvw+zsSmSM02Z5H3ZdEV7B7Ql7eFrjQTnmByJvK+3J8=
google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg=
google.golang.org/grpc v1.15.0 h1:Az/KuahOM4NAidTEuJCv/RonAA7rYsTPkqXVjr+8OOw=
google.golang.org/grpc v1.15.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio=
google.golang.org/grpc v1.16.0 h1:dz5IJGuC2BB7qXR5AyHNwAUBhZscK2xVez7mznh72sY=
google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20180920025451-e3ad64cb4ed3/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

24
parser/block.go

@ -4,7 +4,7 @@ import (
"fmt"
"github.com/gtank/ctxd/parser/internal/bytestring"
"github.com/gtank/ctxd/proto"
"github.com/gtank/ctxd/rpc"
"github.com/pkg/errors"
)
@ -25,11 +25,13 @@ func (b *block) GetTxCount() int {
return len(b.vtx)
}
// GetHash returns the block hash in big-endian display order.
func (b *block) GetHash() []byte {
return b.hdr.GetHash()
// GetDisplayHash returns the block hash in big-endian display order.
func (b *block) GetDisplayHash() []byte {
return b.hdr.GetDisplayHash()
}
// TODO: encode hash endianness in a type?
// getEncodableHash returns the block hash in little-endian wire order.
func (b *block) getEncodableHash() []byte {
return b.hdr.getEncodableHash()
@ -66,14 +68,14 @@ func (b *block) GetHeight() int {
return int(blockHeight)
}
func (b *block) ToCompact() *proto.CompactBlock {
compactBlock := &proto.CompactBlock{
BlockID: &proto.BlockFilter{
BlockHeight: uint64(b.GetHeight()),
BlockHash: b.getEncodableHash(),
},
func (b *block) ToCompact() *rpc.CompactBlock {
compactBlock := &rpc.CompactBlock{
//TODO ProtoVersion: 1,
Height: uint64(b.GetHeight()),
Hash: b.getEncodableHash(),
//TODO Time: b.hdr.Time,
}
compactBlock.Vtx = make([]*proto.CompactTx, len(b.vtx))
compactBlock.Vtx = make([]*rpc.CompactTx, len(b.vtx))
for idx, tx := range b.vtx {
compactBlock.Vtx[idx] = tx.ToCompact(idx)
}

4
parser/block_header.go

@ -150,8 +150,8 @@ func parseNBits(b []byte) *big.Int {
return new(big.Int).SetBytes(targetBytes)
}
// GetHash returns the bytes of a block hash in big-endian order.
func (hdr *blockHeader) GetHash() []byte {
// GetDisplayHash returns the bytes of a block hash in big-endian order.
func (hdr *blockHeader) GetDisplayHash() []byte {
if hdr.cachedHash != nil {
return hdr.cachedHash
}

2
parser/block_header_test.go

@ -123,7 +123,7 @@ func TestBlockHeader(t *testing.T) {
break
}
hash := blockHeader.GetHash()
hash := blockHeader.GetDisplayHash()
// This is not necessarily true for anything but our current test cases.
for _, b := range hash[:4] {

4
parser/block_test.go

@ -76,7 +76,7 @@ func TestCompactBlocks(t *testing.T) {
t.Errorf("incorrect block height in testnet block %d", test.BlockHeight)
continue
}
if hex.EncodeToString(block.GetHash()) != test.BlockHash {
if hex.EncodeToString(block.GetDisplayHash()) != test.BlockHash {
t.Errorf("incorrect block hash in testnet block %x", test.BlockHash)
continue
}
@ -90,7 +90,7 @@ func TestCompactBlocks(t *testing.T) {
encodedCompact := hex.EncodeToString(marshaled)
if encodedCompact != test.Compact {
t.Errorf("wrong data for compact testnet block %d\nhave: %s\nwant: %s\n", test.BlockHeight, encodedCompact, test.Compact)
continue
break
}
}

12
parser/testdata/compact_blocks.json

File diff suppressed because one or more lines are too long

27
parser/transaction.go

@ -4,7 +4,7 @@ import (
"crypto/sha256"
"github.com/gtank/ctxd/parser/internal/bytestring"
"github.com/gtank/ctxd/proto"
"github.com/gtank/ctxd/rpc"
"github.com/pkg/errors"
)
@ -126,8 +126,8 @@ func (p *spend) ParseFromSlice(data []byte) ([]byte, error) {
return []byte(s), nil
}
func (p *spend) ToCompact() *proto.CompactSpend {
return &proto.CompactSpend{
func (p *spend) ToCompact() *rpc.CompactSpend {
return &rpc.CompactSpend{
Nf: p.nullifier,
}
}
@ -173,8 +173,8 @@ func (p *output) ParseFromSlice(data []byte) ([]byte, error) {
return []byte(s), nil
}
func (p *output) ToCompact() *proto.CompactOutput {
return &proto.CompactOutput{
func (p *output) ToCompact() *rpc.CompactOutput {
return &rpc.CompactOutput{
Cmu: p.cmu,
Epk: p.ephemeralKey,
Ciphertext: p.encCiphertext[:52],
@ -269,8 +269,8 @@ type transaction struct {
txId []byte
}
// GetHash returns the transaction hash in big-endian display order.
func (tx *transaction) GetHash() []byte {
// GetDisplayHash returns the transaction hash in big-endian display order.
func (tx *transaction) GetDisplayHash() []byte {
if tx.txId != nil {
return tx.txId
}
@ -300,12 +300,13 @@ 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
Hash: tx.getEncodableHash(),
Spends: make([]*proto.CompactSpend, len(tx.shieldedSpends)),
Outputs: make([]*proto.CompactOutput, len(tx.shieldedOutputs)),
func (tx *transaction) ToCompact(index int) *rpc.CompactTx {
ctx := &rpc.CompactTx{
Index: uint64(index), // index is contextual
Hash: tx.getEncodableHash(),
//Fee: 0, // TODO: calculate fees
Spends: make([]*rpc.CompactSpend, len(tx.shieldedSpends)),
Outputs: make([]*rpc.CompactOutput, len(tx.shieldedOutputs)),
}
for i, spend := range tx.shieldedSpends {
ctx.Spends[i] = spend.ToCompact()

100
proto/compact_formats.pb.go → rpc/compact_formats.pb.go

@ -1,13 +1,11 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: compact_formats.proto
package proto
package rpc
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
)
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
@ -18,7 +16,7 @@ var _ = math.Inf
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
// CompactBlock is a packaging of ONLY the data from a block that's needed to:
// 1. Detect a payment to your shielded Sapling address
@ -40,17 +38,16 @@ func (m *CompactBlock) Reset() { *m = CompactBlock{} }
func (m *CompactBlock) String() string { return proto.CompactTextString(m) }
func (*CompactBlock) ProtoMessage() {}
func (*CompactBlock) Descriptor() ([]byte, []int) {
return fileDescriptor_dce29fee3ee34899, []int{0}
return fileDescriptor_compact_formats_9dd2f8e478a3b8fc, []int{0}
}
func (m *CompactBlock) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CompactBlock.Unmarshal(m, b)
}
func (m *CompactBlock) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CompactBlock.Marshal(b, m, deterministic)
}
func (m *CompactBlock) XXX_Merge(src proto.Message) {
xxx_messageInfo_CompactBlock.Merge(m, src)
func (dst *CompactBlock) XXX_Merge(src proto.Message) {
xxx_messageInfo_CompactBlock.Merge(dst, src)
}
func (m *CompactBlock) XXX_Size() int {
return xxx_messageInfo_CompactBlock.Size(m)
@ -126,17 +123,16 @@ func (m *CompactTx) Reset() { *m = CompactTx{} }
func (m *CompactTx) String() string { return proto.CompactTextString(m) }
func (*CompactTx) ProtoMessage() {}
func (*CompactTx) Descriptor() ([]byte, []int) {
return fileDescriptor_dce29fee3ee34899, []int{1}
return fileDescriptor_compact_formats_9dd2f8e478a3b8fc, []int{1}
}
func (m *CompactTx) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CompactTx.Unmarshal(m, b)
}
func (m *CompactTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CompactTx.Marshal(b, m, deterministic)
}
func (m *CompactTx) XXX_Merge(src proto.Message) {
xxx_messageInfo_CompactTx.Merge(m, src)
func (dst *CompactTx) XXX_Merge(src proto.Message) {
xxx_messageInfo_CompactTx.Merge(dst, src)
}
func (m *CompactTx) XXX_Size() int {
return xxx_messageInfo_CompactTx.Size(m)
@ -193,17 +189,16 @@ func (m *CompactSpend) Reset() { *m = CompactSpend{} }
func (m *CompactSpend) String() string { return proto.CompactTextString(m) }
func (*CompactSpend) ProtoMessage() {}
func (*CompactSpend) Descriptor() ([]byte, []int) {
return fileDescriptor_dce29fee3ee34899, []int{2}
return fileDescriptor_compact_formats_9dd2f8e478a3b8fc, []int{2}
}
func (m *CompactSpend) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CompactSpend.Unmarshal(m, b)
}
func (m *CompactSpend) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CompactSpend.Marshal(b, m, deterministic)
}
func (m *CompactSpend) XXX_Merge(src proto.Message) {
xxx_messageInfo_CompactSpend.Merge(m, src)
func (dst *CompactSpend) XXX_Merge(src proto.Message) {
xxx_messageInfo_CompactSpend.Merge(dst, src)
}
func (m *CompactSpend) XXX_Size() int {
return xxx_messageInfo_CompactSpend.Size(m)
@ -234,17 +229,16 @@ func (m *CompactOutput) Reset() { *m = CompactOutput{} }
func (m *CompactOutput) String() string { return proto.CompactTextString(m) }
func (*CompactOutput) ProtoMessage() {}
func (*CompactOutput) Descriptor() ([]byte, []int) {
return fileDescriptor_dce29fee3ee34899, []int{3}
return fileDescriptor_compact_formats_9dd2f8e478a3b8fc, []int{3}
}
func (m *CompactOutput) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CompactOutput.Unmarshal(m, b)
}
func (m *CompactOutput) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CompactOutput.Marshal(b, m, deterministic)
}
func (m *CompactOutput) XXX_Merge(src proto.Message) {
xxx_messageInfo_CompactOutput.Merge(m, src)
func (dst *CompactOutput) XXX_Merge(src proto.Message) {
xxx_messageInfo_CompactOutput.Merge(dst, src)
}
func (m *CompactOutput) XXX_Size() int {
return xxx_messageInfo_CompactOutput.Size(m)
@ -277,33 +271,35 @@ func (m *CompactOutput) GetCiphertext() []byte {
}
func init() {
proto.RegisterType((*CompactBlock)(nil), "proto.CompactBlock")
proto.RegisterType((*CompactTx)(nil), "proto.CompactTx")
proto.RegisterType((*CompactSpend)(nil), "proto.CompactSpend")
proto.RegisterType((*CompactOutput)(nil), "proto.CompactOutput")
}
func init() { proto.RegisterFile("compact_formats.proto", fileDescriptor_dce29fee3ee34899) }
var fileDescriptor_dce29fee3ee34899 = []byte{
// 299 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x90, 0xcd, 0x4e, 0x84, 0x30,
0x14, 0x85, 0x53, 0xfe, 0x8c, 0x57, 0xc6, 0x4c, 0xea, 0x68, 0xba, 0x9a, 0x90, 0xae, 0x48, 0x4c,
0x66, 0xa1, 0x6f, 0xa0, 0x0f, 0x60, 0xd2, 0x31, 0x6e, 0x0d, 0x42, 0x11, 0x32, 0x42, 0x1b, 0x5a,
0x0c, 0x0f, 0xe4, 0xda, 0x67, 0x34, 0xbd, 0x54, 0x32, 0xac, 0x38, 0xf7, 0x9c, 0xd3, 0xf6, 0xe3,
0xc2, 0x6d, 0xa9, 0x3a, 0x5d, 0x94, 0xf6, 0xbd, 0x56, 0x43, 0x57, 0x58, 0x73, 0xd0, 0x83, 0xb2,
0x8a, 0xc6, 0xf8, 0xe1, 0xbf, 0x04, 0xd2, 0xe7, 0xb9, 0xf0, 0xf4, 0xa5, 0xca, 0x13, 0xe5, 0x90,
0x62, 0xf2, 0x26, 0x07, 0xd3, 0xaa, 0x9e, 0x91, 0x8c, 0xe4, 0x1b, 0xb1, 0xf2, 0xe8, 0x1d, 0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x01, 0x00, 0x00,
proto.RegisterType((*CompactBlock)(nil), "rpc.CompactBlock")
proto.RegisterType((*CompactTx)(nil), "rpc.CompactTx")
proto.RegisterType((*CompactSpend)(nil), "rpc.CompactSpend")
proto.RegisterType((*CompactOutput)(nil), "rpc.CompactOutput")
}
func init() {
proto.RegisterFile("compact_formats.proto", fileDescriptor_compact_formats_9dd2f8e478a3b8fc)
}
var fileDescriptor_compact_formats_9dd2f8e478a3b8fc = []byte{
// 302 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x51, 0x4b, 0x4e, 0xc3, 0x30,
0x10, 0x55, 0x3e, 0x0d, 0x62, 0x48, 0x2b, 0x18, 0x01, 0xf2, 0xaa, 0x8a, 0xb2, 0x0a, 0x12, 0xea,
0x02, 0x6e, 0x00, 0x07, 0x40, 0x72, 0x11, 0x5b, 0x14, 0x5c, 0x87, 0x44, 0x25, 0xb1, 0x65, 0xbb,
0x28, 0xc7, 0xe1, 0x00, 0x1c, 0x12, 0x79, 0x6a, 0xa2, 0x74, 0xf7, 0xe6, 0xbd, 0x37, 0x33, 0xcf,
0x63, 0xb8, 0x11, 0xaa, 0xd7, 0xb5, 0x70, 0xef, 0x8d, 0x32, 0x7d, 0xed, 0xec, 0x46, 0x1b, 0xe5,
0x14, 0x26, 0x46, 0x8b, 0xf2, 0x37, 0x82, 0xfc, 0xf9, 0x28, 0x3f, 0x7d, 0x29, 0xb1, 0xc7, 0x12,
0x72, 0x92, 0xdf, 0xa4, 0xb1, 0x9d, 0x1a, 0x58, 0x54, 0x44, 0xd5, 0x92, 0x9f, 0x70, 0x78, 0x0b,
0x59, 0x2b, 0xbb, 0xcf, 0xd6, 0xb1, 0xb8, 0x88, 0xaa, 0x94, 0x87, 0x0a, 0x11, 0xd2, 0xb6, 0xb6,
0x2d, 0x4b, 0x8a, 0xa8, 0xca, 0x39, 0x61, 0xcf, 0xb9, 0xae, 0x97, 0x2c, 0xa5, 0x39, 0x84, 0x8f,
0xfd, 0xf5, 0x4e, 0x1a, 0xb6, 0x20, 0x67, 0xa8, 0xb0, 0x80, 0xe4, 0xdb, 0x8d, 0x2c, 0x2b, 0x92,
0xea, 0xe2, 0x61, 0xb5, 0x31, 0x5a, 0x6c, 0x42, 0xb6, 0xd7, 0x91, 0x7b, 0xa9, 0xfc, 0x89, 0xe0,
0x7c, 0xa2, 0xf0, 0x1a, 0x16, 0xdd, 0xb0, 0x93, 0x23, 0x85, 0x4c, 0xf9, 0xb1, 0x98, 0x52, 0xc4,
0xb3, 0x14, 0x97, 0x90, 0x34, 0x52, 0x52, 0xb0, 0x25, 0xf7, 0x10, 0xef, 0x20, 0xb3, 0x5a, 0x0e,
0x3b, 0xcb, 0x52, 0x5a, 0x77, 0x35, 0x5f, 0xb7, 0xf5, 0x0a, 0x0f, 0x06, 0xbc, 0x87, 0x33, 0x75,
0x70, 0xfa, 0xe0, 0x2c, 0x5b, 0x90, 0x17, 0xe7, 0xde, 0x17, 0x92, 0xf8, 0xbf, 0xa5, 0x5c, 0x4f,
0x07, 0xa5, 0x29, 0xb8, 0x82, 0x78, 0x68, 0x28, 0x61, 0xce, 0xe3, 0xa1, 0x29, 0xb7, 0xb0, 0x3c,
0xe9, 0xf4, 0xd9, 0x44, 0x7f, 0x08, 0x0e, 0x0f, 0x3d, 0x23, 0xf5, 0x3e, 0x3c, 0xc0, 0x43, 0x5c,
0x03, 0x88, 0x4e, 0xb7, 0xd2, 0x38, 0x39, 0xba, 0x70, 0xdf, 0x19, 0xf3, 0x91, 0xd1, 0xff, 0x3c,
0xfe, 0x05, 0x00, 0x00, 0xff, 0xff, 0xd8, 0x23, 0xf6, 0xee, 0xeb, 0x01, 0x00, 0x00,
}

2
proto/compact_formats.proto → rpc/compact_formats.proto

@ -1,5 +1,5 @@
syntax = "proto3";
package proto;
package rpc;
// Remember that proto3 fields are all optional. A field that is not present will be set to its zero value.
// bytes fields of hashes are in canonical little-endian format.

2
proto/generate.go → rpc/generate.go

@ -1,4 +1,4 @@
package proto
package rpc
//go:generate protoc -I . ./compact_formats.proto --go_out=plugins=grpc:.
//go:generate protoc -I . ./service.proto --go_out=plugins=grpc:.

149
proto/service.pb.go → rpc/service.pb.go

@ -1,14 +1,15 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: service.proto
package proto
package rpc
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import (
context "context"
fmt "fmt"
proto "github.com/golang/protobuf/proto"
context "golang.org/x/net/context"
grpc "google.golang.org/grpc"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
@ -20,7 +21,7 @@ var _ = math.Inf
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
// A BlockID message contains identifiers to select a block: a height or a
// hash. If the hash is present it takes precedence.
@ -36,17 +37,16 @@ func (m *BlockID) Reset() { *m = BlockID{} }
func (m *BlockID) String() string { return proto.CompactTextString(m) }
func (*BlockID) ProtoMessage() {}
func (*BlockID) Descriptor() ([]byte, []int) {
return fileDescriptor_a0b84a42fa06f626, []int{0}
return fileDescriptor_service_a868da2f21e04b98, []int{0}
}
func (m *BlockID) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_BlockID.Unmarshal(m, b)
}
func (m *BlockID) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_BlockID.Marshal(b, m, deterministic)
}
func (m *BlockID) XXX_Merge(src proto.Message) {
xxx_messageInfo_BlockID.Merge(m, src)
func (dst *BlockID) XXX_Merge(src proto.Message) {
xxx_messageInfo_BlockID.Merge(dst, src)
}
func (m *BlockID) XXX_Size() int {
return xxx_messageInfo_BlockID.Size(m)
@ -86,17 +86,16 @@ func (m *BlockRange) Reset() { *m = BlockRange{} }
func (m *BlockRange) String() string { return proto.CompactTextString(m) }
func (*BlockRange) ProtoMessage() {}
func (*BlockRange) Descriptor() ([]byte, []int) {
return fileDescriptor_a0b84a42fa06f626, []int{1}
return fileDescriptor_service_a868da2f21e04b98, []int{1}
}
func (m *BlockRange) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_BlockRange.Unmarshal(m, b)
}
func (m *BlockRange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_BlockRange.Marshal(b, m, deterministic)
}
func (m *BlockRange) XXX_Merge(src proto.Message) {
xxx_messageInfo_BlockRange.Merge(m, src)
func (dst *BlockRange) XXX_Merge(src proto.Message) {
xxx_messageInfo_BlockRange.Merge(dst, src)
}
func (m *BlockRange) XXX_Size() int {
return xxx_messageInfo_BlockRange.Size(m)
@ -136,17 +135,16 @@ func (m *TxFilter) Reset() { *m = TxFilter{} }
func (m *TxFilter) String() string { return proto.CompactTextString(m) }
func (*TxFilter) ProtoMessage() {}
func (*TxFilter) Descriptor() ([]byte, []int) {
return fileDescriptor_a0b84a42fa06f626, []int{2}
return fileDescriptor_service_a868da2f21e04b98, []int{2}
}
func (m *TxFilter) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_TxFilter.Unmarshal(m, b)
}
func (m *TxFilter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_TxFilter.Marshal(b, m, deterministic)
}
func (m *TxFilter) XXX_Merge(src proto.Message) {
xxx_messageInfo_TxFilter.Merge(m, src)
func (dst *TxFilter) XXX_Merge(src proto.Message) {
xxx_messageInfo_TxFilter.Merge(dst, src)
}
func (m *TxFilter) XXX_Size() int {
return xxx_messageInfo_TxFilter.Size(m)
@ -190,17 +188,16 @@ func (m *RawTransaction) Reset() { *m = RawTransaction{} }
func (m *RawTransaction) String() string { return proto.CompactTextString(m) }
func (*RawTransaction) ProtoMessage() {}
func (*RawTransaction) Descriptor() ([]byte, []int) {
return fileDescriptor_a0b84a42fa06f626, []int{3}
return fileDescriptor_service_a868da2f21e04b98, []int{3}
}
func (m *RawTransaction) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_RawTransaction.Unmarshal(m, b)
}
func (m *RawTransaction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_RawTransaction.Marshal(b, m, deterministic)
}
func (m *RawTransaction) XXX_Merge(src proto.Message) {
xxx_messageInfo_RawTransaction.Merge(m, src)
func (dst *RawTransaction) XXX_Merge(src proto.Message) {
xxx_messageInfo_RawTransaction.Merge(dst, src)
}
func (m *RawTransaction) XXX_Size() int {
return xxx_messageInfo_RawTransaction.Size(m)
@ -230,17 +227,16 @@ func (m *SendResponse) Reset() { *m = SendResponse{} }
func (m *SendResponse) String() string { return proto.CompactTextString(m) }
func (*SendResponse) ProtoMessage() {}
func (*SendResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_a0b84a42fa06f626, []int{4}
return fileDescriptor_service_a868da2f21e04b98, []int{4}
}
func (m *SendResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SendResponse.Unmarshal(m, b)
}
func (m *SendResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_SendResponse.Marshal(b, m, deterministic)
}
func (m *SendResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_SendResponse.Merge(m, src)
func (dst *SendResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_SendResponse.Merge(dst, src)
}
func (m *SendResponse) XXX_Size() int {
return xxx_messageInfo_SendResponse.Size(m)
@ -276,17 +272,16 @@ func (m *ChainSpec) Reset() { *m = ChainSpec{} }
func (m *ChainSpec) String() string { return proto.CompactTextString(m) }
func (*ChainSpec) ProtoMessage() {}
func (*ChainSpec) Descriptor() ([]byte, []int) {
return fileDescriptor_a0b84a42fa06f626, []int{5}
return fileDescriptor_service_a868da2f21e04b98, []int{5}
}
func (m *ChainSpec) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ChainSpec.Unmarshal(m, b)
}
func (m *ChainSpec) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ChainSpec.Marshal(b, m, deterministic)
}
func (m *ChainSpec) XXX_Merge(src proto.Message) {
xxx_messageInfo_ChainSpec.Merge(m, src)
func (dst *ChainSpec) XXX_Merge(src proto.Message) {
xxx_messageInfo_ChainSpec.Merge(dst, src)
}
func (m *ChainSpec) XXX_Size() int {
return xxx_messageInfo_ChainSpec.Size(m)
@ -298,43 +293,12 @@ func (m *ChainSpec) XXX_DiscardUnknown() {
var xxx_messageInfo_ChainSpec proto.InternalMessageInfo
func init() {
proto.RegisterType((*BlockID)(nil), "proto.BlockID")
proto.RegisterType((*BlockRange)(nil), "proto.BlockRange")
proto.RegisterType((*TxFilter)(nil), "proto.TxFilter")
proto.RegisterType((*RawTransaction)(nil), "proto.RawTransaction")
proto.RegisterType((*SendResponse)(nil), "proto.SendResponse")
proto.RegisterType((*ChainSpec)(nil), "proto.ChainSpec")
}
func init() { proto.RegisterFile("service.proto", fileDescriptor_a0b84a42fa06f626) }
var fileDescriptor_a0b84a42fa06f626 = []byte{
// 385 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x51, 0x4f, 0x8f, 0xd2, 0x40,
0x14, 0x6f, 0x77, 0xe9, 0xba, 0xbc, 0xed, 0x82, 0x8c, 0x62, 0x48, 0xe3, 0x81, 0x4c, 0x38, 0x70,
0x22, 0x8a, 0x7a, 0xd1, 0x83, 0x89, 0x18, 0x89, 0x89, 0x26, 0x66, 0xe8, 0xc9, 0x8b, 0x19, 0xda,
0x27, 0x6d, 0x84, 0x99, 0x66, 0x66, 0xa2, 0x7c, 0x32, 0x3f, 0x9f, 0xe9, 0x9b, 0x82, 0x05, 0xe5,
0xd4, 0xce, 0xef, 0xdf, 0xfb, 0x07, 0xf7, 0x16, 0xcd, 0xcf, 0x32, 0xc3, 0x59, 0x65, 0xb4, 0xd3,
0x2c, 0xa2, 0x4f, 0x32, 0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, 0x30, 0x9b, 0xff, 0xbe, 0x82,
0xc1, 0xc2, 0xdf, 0x21, 0xdd, 0xaf, 0x9c, 0x41, 0xb9, 0x43, 0xc3, 0x5e, 0x42, 0x6f, 0x89, 0xee,
0x93, 0x74, 0x68, 0x1d, 0xcd, 0xc7, 0x1e, 0x36, 0xd3, 0x1e, 0x9d, 0xc9, 0xd9, 0xfc, 0x3c, 0x60,
0xcf, 0xe1, 0x76, 0x89, 0x8d, 0xfe, 0x8c, 0x4d, 0x1e, 0x1d, 0xfc, 0xbe, 0x16, 0xc1, 0x3c, 0x60,
0x6f, 0xe0, 0xfe, 0x60, 0xf1, 0x87, 0x1b, 0xb4, 0x7d, 0x04, 0x5d, 0xb0, 0x3e, 0x0b, 0xd9, 0x6b,
0xea, 0xb2, 0xbd, 0xc0, 0x7e, 0x23, 0x3d, 0xdc, 0x2c, 0x19, 0x36, 0xc0, 0xe9, 0xa2, 0x79, 0xc0,
0xde, 0x42, 0xbf, 0x5e, 0x6b, 0xdb, 0xfc, 0x7f, 0xed, 0xb1, 0x7c, 0xfb, 0x0a, 0x3c, 0x58, 0xdf,
0x10, 0xfa, 0xe2, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd9, 0x6b, 0xbf, 0xed, 0xdc, 0x02, 0x00,
0x00,
proto.RegisterType((*BlockID)(nil), "rpc.BlockID")
proto.RegisterType((*BlockRange)(nil), "rpc.BlockRange")
proto.RegisterType((*TxFilter)(nil), "rpc.TxFilter")
proto.RegisterType((*RawTransaction)(nil), "rpc.RawTransaction")
proto.RegisterType((*SendResponse)(nil), "rpc.SendResponse")
proto.RegisterType((*ChainSpec)(nil), "rpc.ChainSpec")
}
// Reference imports to suppress errors if they are not otherwise used.
@ -366,7 +330,7 @@ func NewCompactTxStreamerClient(cc *grpc.ClientConn) CompactTxStreamerClient {
func (c *compactTxStreamerClient) GetLatestBlock(ctx context.Context, in *ChainSpec, opts ...grpc.CallOption) (*BlockID, error) {
out := new(BlockID)
err := c.cc.Invoke(ctx, "/proto.CompactTxStreamer/GetLatestBlock", in, out, opts...)
err := c.cc.Invoke(ctx, "/rpc.CompactTxStreamer/GetLatestBlock", in, out, opts...)
if err != nil {
return nil, err
}
@ -375,7 +339,7 @@ func (c *compactTxStreamerClient) GetLatestBlock(ctx context.Context, in *ChainS
func (c *compactTxStreamerClient) GetBlock(ctx context.Context, in *BlockID, opts ...grpc.CallOption) (*CompactBlock, error) {
out := new(CompactBlock)
err := c.cc.Invoke(ctx, "/proto.CompactTxStreamer/GetBlock", in, out, opts...)
err := c.cc.Invoke(ctx, "/rpc.CompactTxStreamer/GetBlock", in, out, opts...)
if err != nil {
return nil, err
}
@ -383,7 +347,7 @@ func (c *compactTxStreamerClient) GetBlock(ctx context.Context, in *BlockID, opt
}
func (c *compactTxStreamerClient) GetBlockRange(ctx context.Context, in *BlockRange, opts ...grpc.CallOption) (CompactTxStreamer_GetBlockRangeClient, error) {
stream, err := c.cc.NewStream(ctx, &_CompactTxStreamer_serviceDesc.Streams[0], "/proto.CompactTxStreamer/GetBlockRange", opts...)
stream, err := c.cc.NewStream(ctx, &_CompactTxStreamer_serviceDesc.Streams[0], "/rpc.CompactTxStreamer/GetBlockRange", opts...)
if err != nil {
return nil, err
}
@ -416,7 +380,7 @@ func (x *compactTxStreamerGetBlockRangeClient) Recv() (*CompactBlock, error) {
func (c *compactTxStreamerClient) GetTransaction(ctx context.Context, in *TxFilter, opts ...grpc.CallOption) (*RawTransaction, error) {
out := new(RawTransaction)
err := c.cc.Invoke(ctx, "/proto.CompactTxStreamer/GetTransaction", in, out, opts...)
err := c.cc.Invoke(ctx, "/rpc.CompactTxStreamer/GetTransaction", in, out, opts...)
if err != nil {
return nil, err
}
@ -425,7 +389,7 @@ func (c *compactTxStreamerClient) GetTransaction(ctx context.Context, in *TxFilt
func (c *compactTxStreamerClient) SendTransaction(ctx context.Context, in *RawTransaction, opts ...grpc.CallOption) (*SendResponse, error) {
out := new(SendResponse)
err := c.cc.Invoke(ctx, "/proto.CompactTxStreamer/SendTransaction", in, out, opts...)
err := c.cc.Invoke(ctx, "/rpc.CompactTxStreamer/SendTransaction", in, out, opts...)
if err != nil {
return nil, err
}
@ -455,7 +419,7 @@ func _CompactTxStreamer_GetLatestBlock_Handler(srv interface{}, ctx context.Cont
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.CompactTxStreamer/GetLatestBlock",
FullMethod: "/rpc.CompactTxStreamer/GetLatestBlock",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CompactTxStreamerServer).GetLatestBlock(ctx, req.(*ChainSpec))
@ -473,7 +437,7 @@ func _CompactTxStreamer_GetBlock_Handler(srv interface{}, ctx context.Context, d
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.CompactTxStreamer/GetBlock",
FullMethod: "/rpc.CompactTxStreamer/GetBlock",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CompactTxStreamerServer).GetBlock(ctx, req.(*BlockID))
@ -512,7 +476,7 @@ func _CompactTxStreamer_GetTransaction_Handler(srv interface{}, ctx context.Cont
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.CompactTxStreamer/GetTransaction",
FullMethod: "/rpc.CompactTxStreamer/GetTransaction",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CompactTxStreamerServer).GetTransaction(ctx, req.(*TxFilter))
@ -530,7 +494,7 @@ func _CompactTxStreamer_SendTransaction_Handler(srv interface{}, ctx context.Con
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.CompactTxStreamer/SendTransaction",
FullMethod: "/rpc.CompactTxStreamer/SendTransaction",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CompactTxStreamerServer).SendTransaction(ctx, req.(*RawTransaction))
@ -539,7 +503,7 @@ func _CompactTxStreamer_SendTransaction_Handler(srv interface{}, ctx context.Con
}
var _CompactTxStreamer_serviceDesc = grpc.ServiceDesc{
ServiceName: "proto.CompactTxStreamer",
ServiceName: "rpc.CompactTxStreamer",
HandlerType: (*CompactTxStreamerServer)(nil),
Methods: []grpc.MethodDesc{
{
@ -568,3 +532,34 @@ var _CompactTxStreamer_serviceDesc = grpc.ServiceDesc{
},
Metadata: "service.proto",
}
func init() { proto.RegisterFile("service.proto", fileDescriptor_service_a868da2f21e04b98) }
var fileDescriptor_service_a868da2f21e04b98 = []byte{
// 386 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x52, 0xcd, 0x8f, 0x12, 0x31,
0x14, 0x9f, 0x59, 0x60, 0x5d, 0xde, 0x0e, 0x6c, 0xb6, 0x7e, 0x64, 0x33, 0x31, 0x86, 0x34, 0x1e,
0xb8, 0x48, 0x08, 0x46, 0x3d, 0x78, 0x13, 0x23, 0x31, 0xd1, 0x84, 0x14, 0x0e, 0xde, 0x4c, 0xe9,
0x3c, 0x99, 0x89, 0xd0, 0x4e, 0xda, 0x46, 0xf9, 0x7b, 0xfc, 0x4b, 0xcd, 0xbc, 0x0e, 0x30, 0xb3,
0xe1, 0xd6, 0xf7, 0x7e, 0x1f, 0xef, 0xab, 0x30, 0x70, 0x68, 0xff, 0x14, 0x0a, 0x27, 0xa5, 0x35,
0xde, 0xb0, 0x8e, 0x2d, 0x55, 0xfa, 0x5c, 0x99, 0x7d, 0x29, 0x95, 0xff, 0xf9, 0xcb, 0xd8, 0xbd,
0xf4, 0x2e, 0x60, 0xfc, 0x1d, 0x3c, 0xf9, 0xb4, 0x33, 0xea, 0xf7, 0xd7, 0xcf, 0xec, 0x05, 0x5c,
0xe7, 0x58, 0x6c, 0x73, 0xff, 0x10, 0x8f, 0xe2, 0x71, 0x57, 0xd4, 0x11, 0x63, 0xd0, 0xcd, 0xa5,
0xcb, 0x1f, 0xae, 0x46, 0xf1, 0x38, 0x11, 0xf4, 0xe6, 0x4b, 0x00, 0x92, 0x09, 0x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 0x7a, 0x38, 0xd5, 0xdd, 0x59, 0x43, 0x89, 0x8b, 0xb2, 0x69, 0xcc,
0xde, 0x53, 0x67, 0xcd, 0xa5, 0x0d, 0x88, 0x78, 0xbc, 0x51, 0xfa, 0x94, 0xc2, 0xf6, 0x62, 0x79,
0xc4, 0x3e, 0xc2, 0x5d, 0xb5, 0xc6, 0xa6, 0xf0, 0x12, 0xb3, 0x2e, 0xdb, 0xdc, 0x38, 0x8f, 0x36,
0xd7, 0xf4, 0x27, 0xdf, 0xfe, 0x0f, 0x00, 0x00, 0xff, 0xff, 0xc4, 0xe7, 0x91, 0x93, 0xc0, 0x02,
0x00, 0x00,
}

2
proto/service.proto → rpc/service.proto

@ -1,5 +1,5 @@
syntax = "proto3";
package proto;
package rpc;
import "compact_formats.proto";

24
storage/sqlite3.go

@ -4,8 +4,8 @@ import (
"database/sql"
"fmt"
protobuf "github.com/golang/protobuf/proto"
"github.com/gtank/ctxd/proto"
"github.com/golang/protobuf/proto"
"github.com/gtank/ctxd/rpc"
"github.com/pkg/errors"
)
@ -74,20 +74,20 @@ func SetCurrentHeight(conn *sql.DB, height int) error {
return nil
}
func GetBlock(conn *sql.DB, height int) (*proto.CompactBlock, error) {
func GetBlock(conn *sql.DB, height int) (*rpc.CompactBlock, error) {
var blockBytes []byte // avoid a copy with *RawBytes
query := "SELECT compact_encoding from blocks WHERE height = ?"
err := conn.QueryRow(query, height).Scan(&blockBytes)
if err != nil {
return nil, err
}
compactBlock := &proto.CompactBlock{}
err = protobuf.Unmarshal(blockBytes, compactBlock)
compactBlock := &rpc.CompactBlock{}
err = proto.Unmarshal(blockBytes, compactBlock)
return compactBlock, err
}
// [start, end]
func GetBlockRange(conn *sql.DB, start, end int) ([]*proto.CompactBlock, error) {
func GetBlockRange(conn *sql.DB, start, end int) ([]*rpc.CompactBlock, error) {
// TODO sanity check range bounds
query := "SELECT compact_encoding from blocks WHERE (height BETWEEN ? AND ?)"
result, err := conn.Query(query, start, end)
@ -96,15 +96,15 @@ func GetBlockRange(conn *sql.DB, start, end int) ([]*proto.CompactBlock, error)
}
defer result.Close()
compactBlocks := make([]*proto.CompactBlock, 0, (end-start)+1)
compactBlocks := make([]*rpc.CompactBlock, 0, (end-start)+1)
for result.Next() {
var blockBytes []byte // avoid a copy with *RawBytes
err = result.Scan(&blockBytes)
if err != nil {
return nil, err
}
newBlock := &proto.CompactBlock{}
err = protobuf.Unmarshal(blockBytes, newBlock)
newBlock := &rpc.CompactBlock{}
err = proto.Unmarshal(blockBytes, newBlock)
if err != nil {
return nil, err
}
@ -122,15 +122,15 @@ func GetBlockRange(conn *sql.DB, start, end int) ([]*proto.CompactBlock, error)
return compactBlocks, nil
}
func GetBlockByHash(conn *sql.DB, hash string) (*proto.CompactBlock, error) {
func GetBlockByHash(conn *sql.DB, hash string) (*rpc.CompactBlock, error) {
var blockBytes []byte // avoid a copy with *RawBytes
query := "SELECT compact_encoding from blocks WHERE hash = ?"
err := conn.QueryRow(query, hash).Scan(&blockBytes)
if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("getting block with hash %s", hash))
}
compactBlock := &proto.CompactBlock{}
err = protobuf.Unmarshal(blockBytes, compactBlock)
compactBlock := &rpc.CompactBlock{}
err = proto.Unmarshal(blockBytes, compactBlock)
return compactBlock, err
}

4
storage/sqlite3_test.go

@ -54,7 +54,7 @@ func TestSqliteStorage(t *testing.T) {
}
height := block.GetHeight()
hash := hex.EncodeToString(block.GetHash())
hash := hex.EncodeToString(block.GetDisplayHash())
hasSapling := block.HasSaplingTransactions()
protoBlock := block.ToCompact()
version := 1
@ -93,7 +93,7 @@ func TestSqliteStorage(t *testing.T) {
t.Error(errors.Wrap(err, "retrieving stored block"))
}
if int(retBlock.BlockID.BlockHeight) != lastBlockTest.BlockHeight {
if int(retBlock.Height) != lastBlockTest.BlockHeight {
t.Error("incorrect retrieval")
}

12
storage/testdata/compact_blocks.json

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save