diff --git a/domain/consensus/database/serialization/acceptancedata.go b/domain/consensus/database/serialization/acceptancedata.go new file mode 100644 index 000000000..ee41752e7 --- /dev/null +++ b/domain/consensus/database/serialization/acceptancedata.go @@ -0,0 +1,56 @@ +package serialization + +import "github.com/kaspanet/kaspad/domain/consensus/model" + +// DomainAcceptanceDataToDbAcceptanceData converts model.AcceptanceData to DbAcceptanceData +func DomainAcceptanceDataToDbAcceptanceData(domainAcceptanceData model.AcceptanceData) *DbAcceptanceData { + dbBlockAcceptanceData := make([]*DbBlockAcceptanceData, len(domainAcceptanceData)) + for i, blockAcceptanceData := range domainAcceptanceData { + dbTransactionAcceptanceData := make([]*DbTransactionAcceptanceData, + len(blockAcceptanceData.TransactionAcceptanceData)) + + for j, transactionAcceptanceData := range blockAcceptanceData.TransactionAcceptanceData { + dbTransaction := DomainTransactionToDbTransaction(transactionAcceptanceData.Transaction) + dbTransactionAcceptanceData[j] = &DbTransactionAcceptanceData{ + Transaction: dbTransaction, + Fee: transactionAcceptanceData.Fee, + IsAccepted: transactionAcceptanceData.IsAccepted, + } + } + + dbBlockAcceptanceData[i] = &DbBlockAcceptanceData{ + TransactionAcceptanceData: dbTransactionAcceptanceData, + } + } + + return &DbAcceptanceData{ + BlockAcceptanceData: dbBlockAcceptanceData, + } +} + +// DbAcceptanceDataToDomainAcceptanceData converts DbAcceptanceData to model.AcceptanceData +func DbAcceptanceDataToDomainAcceptanceData(dbAcceptanceData *DbAcceptanceData) (model.AcceptanceData, error) { + domainAcceptanceData := make(model.AcceptanceData, len(dbAcceptanceData.BlockAcceptanceData)) + for i, dbBlockAcceptanceData := range dbAcceptanceData.BlockAcceptanceData { + domainTransactionAcceptanceData := make([]*model.TransactionAcceptanceData, + len(dbBlockAcceptanceData.TransactionAcceptanceData)) + + for j, dbTransactionAcceptanceData := range dbBlockAcceptanceData.TransactionAcceptanceData { + domainTransaction, err := DbTransactionToDomainTransaction(dbTransactionAcceptanceData.Transaction) + if err != nil { + return nil, err + } + domainTransactionAcceptanceData[j] = &model.TransactionAcceptanceData{ + Transaction: domainTransaction, + Fee: dbTransactionAcceptanceData.Fee, + IsAccepted: dbTransactionAcceptanceData.IsAccepted, + } + } + + domainAcceptanceData[i] = &model.BlockAcceptanceData{ + TransactionAcceptanceData: domainTransactionAcceptanceData, + } + } + + return domainAcceptanceData, nil +} diff --git a/domain/consensus/database/serialization/block.go b/domain/consensus/database/serialization/block.go new file mode 100644 index 000000000..4247dc8fc --- /dev/null +++ b/domain/consensus/database/serialization/block.go @@ -0,0 +1,40 @@ +package serialization + +import ( + "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" +) + +// DomainBlockToDbBlock converts DomainBlocks to DbBlock +func DomainBlockToDbBlock(domainBlock *externalapi.DomainBlock) *DbBlock { + dbTransactions := make([]*DbTransaction, len(domainBlock.Transactions)) + for i, domainTransaction := range domainBlock.Transactions { + dbTransactions[i] = DomainTransactionToDbTransaction(domainTransaction) + } + + return &DbBlock{ + Header: DomainBlockHeaderToDbBlockHeader(domainBlock.Header), + Transactions: dbTransactions, + } +} + +// DbBlockToDomainBlock converts DbBlock to DomainBlock +func DbBlockToDomainBlock(dbBlock *DbBlock) (*externalapi.DomainBlock, error) { + domainBlockHeader, err := DbBlockHeaderToDomainBlockHeader(dbBlock.Header) + if err != nil { + return nil, err + } + + domainTransactions := make([]*externalapi.DomainTransaction, len(dbBlock.Transactions)) + for i, dbTransaction := range dbBlock.Transactions { + var err error + domainTransactions[i], err = DbTransactionToDomainTransaction(dbTransaction) + if err != nil { + return nil, err + } + } + + return &externalapi.DomainBlock{ + Header: domainBlockHeader, + Transactions: domainTransactions, + }, nil +} diff --git a/domain/consensus/database/serialization/blockheader.go b/domain/consensus/database/serialization/blockheader.go new file mode 100644 index 000000000..e8981daa7 --- /dev/null +++ b/domain/consensus/database/serialization/blockheader.go @@ -0,0 +1,50 @@ +package serialization + +import ( + "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" +) + +// DomainBlockHeaderToDbBlockHeader converts DomainBlockHeader to DbBlockHeader +func DomainBlockHeaderToDbBlockHeader(domainBlockHeader *externalapi.DomainBlockHeader) *DbBlockHeader { + return &DbBlockHeader{ + Version: domainBlockHeader.Version, + ParentHashes: DomainHashesToDbHashes(domainBlockHeader.ParentHashes), + HashMerkleRoot: DomainHashToDbHash(&domainBlockHeader.HashMerkleRoot), + AcceptedIDMerkleRoot: DomainHashToDbHash(&domainBlockHeader.AcceptedIDMerkleRoot), + UtxoCommitment: DomainHashToDbHash(&domainBlockHeader.UTXOCommitment), + TimeInMilliseconds: domainBlockHeader.TimeInMilliseconds, + Bits: domainBlockHeader.Bits, + Nonce: domainBlockHeader.Nonce, + } +} + +// DbBlockHeaderToDomainBlockHeader converts DbBlockHeader to DomainBlockHeader +func DbBlockHeaderToDomainBlockHeader(dbBlockHeader *DbBlockHeader) (*externalapi.DomainBlockHeader, error) { + parentHashes, err := DbHashesToDomainHashes(dbBlockHeader.ParentHashes) + if err != nil { + return nil, err + } + hashMerkleRoot, err := DbHashToDomainHash(dbBlockHeader.HashMerkleRoot) + if err != nil { + return nil, err + } + acceptedIDMerkleRoot, err := DbHashToDomainHash(dbBlockHeader.AcceptedIDMerkleRoot) + if err != nil { + return nil, err + } + utxoCommitment, err := DbHashToDomainHash(dbBlockHeader.UtxoCommitment) + if err != nil { + return nil, err + } + + return &externalapi.DomainBlockHeader{ + Version: dbBlockHeader.Version, + ParentHashes: parentHashes, + HashMerkleRoot: *hashMerkleRoot, + AcceptedIDMerkleRoot: *acceptedIDMerkleRoot, + UTXOCommitment: *utxoCommitment, + TimeInMilliseconds: dbBlockHeader.TimeInMilliseconds, + Bits: dbBlockHeader.Bits, + Nonce: dbBlockHeader.Nonce, + }, nil +} diff --git a/domain/consensus/database/serialization/blockrelations.go b/domain/consensus/database/serialization/blockrelations.go new file mode 100644 index 000000000..4a06dcb59 --- /dev/null +++ b/domain/consensus/database/serialization/blockrelations.go @@ -0,0 +1,30 @@ +package serialization + +import ( + "github.com/kaspanet/kaspad/domain/consensus/model" +) + +// DomainBlockRelationsToDbBlockRelations converts model.BlockRelations to DbBlockRelations +func DomainBlockRelationsToDbBlockRelations(domainBlockRelations *model.BlockRelations) *DbBlockRelations { + return &DbBlockRelations{ + Parents: DomainHashesToDbHashes(domainBlockRelations.Parents), + Children: DomainHashesToDbHashes(domainBlockRelations.Children), + } +} + +// DbBlockRelationsToDomainBlockRelations converts DbBlockRelations to model.BlockRelations +func DbBlockRelationsToDomainBlockRelations(dbBlockRelations *DbBlockRelations) (*model.BlockRelations, error) { + domainParentHashes, err := DbHashesToDomainHashes(dbBlockRelations.Parents) + if err != nil { + return nil, err + } + domainChildHashes, err := DbHashesToDomainHashes(dbBlockRelations.Children) + if err != nil { + return nil, err + } + + return &model.BlockRelations{ + Parents: domainParentHashes, + Children: domainChildHashes, + }, nil +} diff --git a/domain/consensus/database/serialization/blockstatus.go b/domain/consensus/database/serialization/blockstatus.go new file mode 100644 index 000000000..16522380e --- /dev/null +++ b/domain/consensus/database/serialization/blockstatus.go @@ -0,0 +1,15 @@ +package serialization + +import "github.com/kaspanet/kaspad/domain/consensus/model" + +// DomainBlockStatusToDbBlockStatus converts model.BlockStatus to DbBlockStatus +func DomainBlockStatusToDbBlockStatus(domainBlockStatus model.BlockStatus) *DbBlockStatus { + return &DbBlockStatus{ + Status: uint32(domainBlockStatus), + } +} + +// DbBlockStatusToDomainBlockStatus converts DbBlockStatus to model.BlockStatus +func DbBlockStatusToDomainBlockStatus(dbBlockStatus *DbBlockStatus) model.BlockStatus { + return model.BlockStatus(dbBlockStatus.Status) +} diff --git a/domain/consensus/database/serialization/hash.go b/domain/consensus/database/serialization/hash.go new file mode 100644 index 000000000..f09bc290a --- /dev/null +++ b/domain/consensus/database/serialization/hash.go @@ -0,0 +1,38 @@ +package serialization + +import ( + "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" + "github.com/kaspanet/kaspad/domain/consensus/utils/hashes" +) + +// DbHashToDomainHash converts a DbHash to a DomainHash +func DbHashToDomainHash(dbHash *DbHash) (*externalapi.DomainHash, error) { + return hashes.FromBytes(dbHash.Hash) +} + +// DomainHashToDbHash converts a DomainHash to a DbHash +func DomainHashToDbHash(domainHash *externalapi.DomainHash) *DbHash { + return &DbHash{Hash: domainHash[:]} +} + +// DomainHashesToDbHashes converts a slice of DomainHash to a slice of DbHash +func DomainHashesToDbHashes(domainHashes []*externalapi.DomainHash) []*DbHash { + dbHashes := make([]*DbHash, len(domainHashes)) + for i, domainHash := range domainHashes { + dbHashes[i] = DomainHashToDbHash(domainHash) + } + return dbHashes +} + +// DbHashesToDomainHashes converts a slice of DbHash to a slice of DomainHash +func DbHashesToDomainHashes(dbHashes []*DbHash) ([]*externalapi.DomainHash, error) { + domainHashes := make([]*externalapi.DomainHash, len(dbHashes)) + for i, domainHash := range dbHashes { + var err error + domainHashes[i], err = DbHashToDomainHash(domainHash) + if err != nil { + return nil, err + } + } + return domainHashes, nil +} diff --git a/domain/consensus/database/serialization/messages.pb.go b/domain/consensus/database/serialization/messages.pb.go index e0e1c1b3f..3ba94f913 100644 --- a/domain/consensus/database/serialization/messages.pb.go +++ b/domain/consensus/database/serialization/messages.pb.go @@ -242,7 +242,7 @@ type DbTransaction struct { SubnetworkID *DbSubnetworkId `protobuf:"bytes,5,opt,name=subnetworkID,proto3" json:"subnetworkID,omitempty"` Gas uint64 `protobuf:"varint,6,opt,name=gas,proto3" json:"gas,omitempty"` PayloadHash *DbHash `protobuf:"bytes,7,opt,name=payloadHash,proto3" json:"payloadHash,omitempty"` - Payload *DbHash `protobuf:"bytes,8,opt,name=payload,proto3" json:"payload,omitempty"` + Payload []byte `protobuf:"bytes,8,opt,name=payload,proto3" json:"payload,omitempty"` } func (x *DbTransaction) Reset() { @@ -326,7 +326,7 @@ func (x *DbTransaction) GetPayloadHash() *DbHash { return nil } -func (x *DbTransaction) GetPayload() *DbHash { +func (x *DbTransaction) GetPayload() []byte { if x != nil { return x.Payload } @@ -1480,7 +1480,7 @@ var file_messages_proto_rawDesc = []byte{ 0x0d, 0x52, 0x04, 0x62, 0x69, 0x74, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x6f, 0x6e, 0x63, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x6e, 0x6f, 0x6e, 0x63, 0x65, 0x22, 0x1c, 0x0a, 0x06, 0x44, 0x62, 0x48, 0x61, 0x73, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x22, 0xfd, 0x02, 0x0a, 0x0d, + 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x22, 0xe6, 0x02, 0x0a, 0x0d, 0x44, 0x62, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x39, 0x0a, 0x06, 0x69, 0x6e, 0x70, 0x75, 0x74, @@ -1501,164 +1501,163 @@ var file_messages_proto_rawDesc = []byte{ 0x73, 0x12, 0x37, 0x0a, 0x0b, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x48, 0x61, 0x73, 0x68, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x48, 0x61, 0x73, 0x68, 0x52, 0x0b, 0x70, - 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x48, 0x61, 0x73, 0x68, 0x12, 0x2f, 0x0a, 0x07, 0x70, 0x61, - 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x73, 0x65, - 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x48, 0x61, - 0x73, 0x68, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0xa1, 0x01, 0x0a, 0x12, - 0x44, 0x62, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x70, - 0x75, 0x74, 0x12, 0x45, 0x0a, 0x10, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x4f, 0x75, - 0x74, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x73, - 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x4f, - 0x75, 0x74, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x10, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, - 0x73, 0x4f, 0x75, 0x74, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x28, 0x0a, 0x0f, 0x73, 0x69, 0x67, - 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x0f, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x63, 0x72, - 0x69, 0x70, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x22, - 0x68, 0x0a, 0x0a, 0x44, 0x62, 0x4f, 0x75, 0x74, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x44, 0x0a, - 0x0d, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x44, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x49, 0x64, 0x52, 0x0d, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x49, 0x44, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0d, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x22, 0x37, 0x0a, 0x0f, 0x44, 0x62, 0x54, - 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x24, 0x0a, 0x0d, - 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x49, 0x64, 0x22, 0x55, 0x0a, 0x13, 0x44, 0x62, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, - 0x28, 0x0a, 0x0f, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, - 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0f, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x22, 0x34, 0x0a, 0x0e, 0x44, 0x62, 0x53, - 0x75, 0x62, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x73, - 0x75, 0x62, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x0c, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x64, 0x22, - 0x6a, 0x0a, 0x10, 0x44, 0x62, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x44, - 0x61, 0x74, 0x61, 0x12, 0x56, 0x0a, 0x13, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x63, 0x63, 0x65, - 0x70, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x44, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x24, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x2e, 0x44, 0x62, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x61, 0x6e, - 0x63, 0x65, 0x44, 0x61, 0x74, 0x61, 0x52, 0x13, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x63, 0x63, - 0x65, 0x70, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x44, 0x61, 0x74, 0x61, 0x22, 0x81, 0x01, 0x0a, 0x15, - 0x44, 0x62, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x61, 0x6e, 0x63, - 0x65, 0x44, 0x61, 0x74, 0x61, 0x12, 0x68, 0x0a, 0x19, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x44, 0x61, - 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, - 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x54, 0x72, 0x61, 0x6e, 0x73, - 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x61, 0x6e, 0x63, 0x65, - 0x44, 0x61, 0x74, 0x61, 0x52, 0x19, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x44, 0x61, 0x74, 0x61, 0x22, - 0x8f, 0x01, 0x0a, 0x1b, 0x44, 0x62, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x44, 0x61, 0x74, 0x61, 0x12, - 0x3e, 0x0a, 0x0b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x52, 0x0b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x10, 0x0a, 0x03, 0x66, 0x65, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x66, 0x65, - 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x73, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x69, 0x73, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, - 0x64, 0x22, 0x76, 0x0a, 0x10, 0x44, 0x62, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x6c, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2f, 0x0a, 0x07, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x73, - 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, - 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x48, 0x61, 0x73, 0x68, 0x52, 0x07, 0x70, - 0x61, 0x72, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x31, 0x0a, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, - 0x65, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, - 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x48, 0x61, 0x73, 0x68, 0x52, - 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x22, 0x27, 0x0a, 0x0d, 0x44, 0x62, 0x42, - 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x22, 0xbf, 0x02, 0x0a, 0x13, 0x44, 0x62, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x47, 0x68, - 0x6f, 0x73, 0x74, 0x64, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x12, 0x1c, 0x0a, 0x09, 0x62, 0x6c, - 0x75, 0x65, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x62, - 0x6c, 0x75, 0x65, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x3d, 0x0a, 0x0e, 0x73, 0x65, 0x6c, 0x65, - 0x63, 0x74, 0x65, 0x64, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x2e, 0x44, 0x62, 0x48, 0x61, 0x73, 0x68, 0x52, 0x0e, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x65, - 0x64, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x3b, 0x0a, 0x0d, 0x6d, 0x65, 0x72, 0x67, 0x65, - 0x53, 0x65, 0x74, 0x42, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, + 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x48, 0x61, 0x73, 0x68, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, + 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x79, + 0x6c, 0x6f, 0x61, 0x64, 0x22, 0xa1, 0x01, 0x0a, 0x12, 0x44, 0x62, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x12, 0x45, 0x0a, 0x10, 0x70, + 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x4f, 0x75, 0x74, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x4f, 0x75, 0x74, 0x70, 0x6f, 0x69, 0x6e, 0x74, + 0x52, 0x10, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x4f, 0x75, 0x74, 0x70, 0x6f, 0x69, + 0x6e, 0x74, 0x12, 0x28, 0x0a, 0x0f, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0f, 0x73, 0x69, 0x67, + 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x12, 0x1a, 0x0a, 0x08, + 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, + 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x22, 0x68, 0x0a, 0x0a, 0x44, 0x62, 0x4f, 0x75, + 0x74, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x44, 0x0a, 0x0d, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, + 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, + 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x52, 0x0d, 0x74, + 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x44, 0x12, 0x14, 0x0a, 0x05, + 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x69, 0x6e, 0x64, + 0x65, 0x78, 0x22, 0x37, 0x0a, 0x0f, 0x44, 0x62, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x24, 0x0a, 0x0d, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x74, 0x72, + 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0x55, 0x0a, 0x13, 0x44, + 0x62, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x75, 0x74, 0x70, + 0x75, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x0f, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, + 0x65, 0x79, 0x22, 0x34, 0x0a, 0x0e, 0x44, 0x62, 0x53, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x77, 0x6f, + 0x72, 0x6b, 0x49, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x77, 0x6f, + 0x72, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x73, 0x75, 0x62, 0x6e, + 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x64, 0x22, 0x6a, 0x0a, 0x10, 0x44, 0x62, 0x41, 0x63, + 0x63, 0x65, 0x70, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x44, 0x61, 0x74, 0x61, 0x12, 0x56, 0x0a, 0x13, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x44, + 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x73, 0x65, 0x72, 0x69, + 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x44, 0x61, 0x74, 0x61, 0x52, + 0x13, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x61, 0x6e, 0x63, 0x65, + 0x44, 0x61, 0x74, 0x61, 0x22, 0x81, 0x01, 0x0a, 0x15, 0x44, 0x62, 0x42, 0x6c, 0x6f, 0x63, 0x6b, + 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x44, 0x61, 0x74, 0x61, 0x12, 0x68, + 0x0a, 0x19, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x63, 0x63, + 0x65, 0x70, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x44, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x2a, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x2e, 0x44, 0x62, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x41, + 0x63, 0x63, 0x65, 0x70, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x44, 0x61, 0x74, 0x61, 0x52, 0x19, 0x74, + 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, + 0x61, 0x6e, 0x63, 0x65, 0x44, 0x61, 0x74, 0x61, 0x22, 0x8f, 0x01, 0x0a, 0x1b, 0x44, 0x62, 0x54, + 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, + 0x61, 0x6e, 0x63, 0x65, 0x44, 0x61, 0x74, 0x61, 0x12, 0x3e, 0x0a, 0x0b, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, + 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, + 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x74, 0x72, 0x61, + 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x66, 0x65, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x66, 0x65, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x73, + 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, + 0x69, 0x73, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x22, 0x76, 0x0a, 0x10, 0x44, 0x62, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2f, + 0x0a, 0x07, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x15, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, + 0x44, 0x62, 0x48, 0x61, 0x73, 0x68, 0x52, 0x07, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x73, 0x12, + 0x31, 0x0a, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x2e, 0x44, 0x62, 0x48, 0x61, 0x73, 0x68, 0x52, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, + 0x65, 0x6e, 0x22, 0x27, 0x0a, 0x0d, 0x44, 0x62, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0xbf, 0x02, 0x0a, 0x13, + 0x44, 0x62, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x47, 0x68, 0x6f, 0x73, 0x74, 0x64, 0x61, 0x67, 0x44, + 0x61, 0x74, 0x61, 0x12, 0x1c, 0x0a, 0x09, 0x62, 0x6c, 0x75, 0x65, 0x53, 0x63, 0x6f, 0x72, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x62, 0x6c, 0x75, 0x65, 0x53, 0x63, 0x6f, 0x72, + 0x65, 0x12, 0x3d, 0x0a, 0x0e, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x65, 0x64, 0x50, 0x61, 0x72, + 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x69, + 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x48, 0x61, 0x73, 0x68, + 0x52, 0x0e, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x65, 0x64, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, + 0x12, 0x3b, 0x0a, 0x0d, 0x6d, 0x65, 0x72, 0x67, 0x65, 0x53, 0x65, 0x74, 0x42, 0x6c, 0x75, 0x65, + 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, + 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x48, 0x61, 0x73, 0x68, 0x52, 0x0d, + 0x6d, 0x65, 0x72, 0x67, 0x65, 0x53, 0x65, 0x74, 0x42, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x39, 0x0a, + 0x0c, 0x6d, 0x65, 0x72, 0x67, 0x65, 0x53, 0x65, 0x74, 0x52, 0x65, 0x64, 0x73, 0x18, 0x04, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x48, 0x61, 0x73, 0x68, 0x52, 0x0c, 0x6d, 0x65, 0x72, 0x67, + 0x65, 0x53, 0x65, 0x74, 0x52, 0x65, 0x64, 0x73, 0x12, 0x53, 0x0a, 0x12, 0x62, 0x6c, 0x75, 0x65, + 0x73, 0x41, 0x6e, 0x74, 0x69, 0x63, 0x6f, 0x6e, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x73, 0x18, 0x05, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x42, 0x6c, 0x75, 0x65, 0x73, 0x41, 0x6e, 0x74, 0x69, + 0x63, 0x6f, 0x6e, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x73, 0x52, 0x12, 0x62, 0x6c, 0x75, 0x65, 0x73, + 0x41, 0x6e, 0x74, 0x69, 0x63, 0x6f, 0x6e, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x73, 0x22, 0x6d, 0x0a, + 0x14, 0x44, 0x62, 0x42, 0x6c, 0x75, 0x65, 0x73, 0x41, 0x6e, 0x74, 0x69, 0x63, 0x6f, 0x6e, 0x65, + 0x53, 0x69, 0x7a, 0x65, 0x73, 0x12, 0x31, 0x0a, 0x08, 0x62, 0x6c, 0x75, 0x65, 0x48, 0x61, 0x73, + 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, + 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x48, 0x61, 0x73, 0x68, 0x52, 0x08, + 0x62, 0x6c, 0x75, 0x65, 0x48, 0x61, 0x73, 0x68, 0x12, 0x22, 0x0a, 0x0c, 0x61, 0x6e, 0x74, 0x69, + 0x63, 0x6f, 0x6e, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, + 0x61, 0x6e, 0x74, 0x69, 0x63, 0x6f, 0x6e, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x28, 0x0a, 0x0a, + 0x44, 0x62, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x73, 0x65, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x75, + 0x6c, 0x74, 0x69, 0x73, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x6d, 0x75, + 0x6c, 0x74, 0x69, 0x73, 0x65, 0x74, 0x22, 0x46, 0x0a, 0x09, 0x44, 0x62, 0x55, 0x74, 0x78, 0x6f, + 0x53, 0x65, 0x74, 0x12, 0x39, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x55, 0x74, 0x78, 0x6f, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x87, + 0x01, 0x0a, 0x14, 0x44, 0x62, 0x55, 0x74, 0x78, 0x6f, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x35, 0x0a, 0x08, 0x6f, 0x75, 0x74, 0x70, 0x6f, + 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x73, 0x65, 0x72, 0x69, + 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x4f, 0x75, 0x74, 0x70, + 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x08, 0x6f, 0x75, 0x74, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x38, + 0x0a, 0x09, 0x75, 0x74, 0x78, 0x6f, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1a, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x2e, 0x44, 0x62, 0x55, 0x74, 0x78, 0x6f, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x75, + 0x74, 0x78, 0x6f, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x22, 0x97, 0x01, 0x0a, 0x0b, 0x44, 0x62, 0x55, + 0x74, 0x78, 0x6f, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, + 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, + 0x12, 0x28, 0x0a, 0x0f, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, + 0x4b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0f, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x26, 0x0a, 0x0e, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x42, 0x6c, 0x75, 0x65, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x0e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x42, 0x6c, 0x75, 0x65, 0x53, 0x63, 0x6f, + 0x72, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x73, 0x43, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x69, 0x73, 0x43, 0x6f, 0x69, 0x6e, 0x62, 0x61, + 0x73, 0x65, 0x22, 0x9c, 0x01, 0x0a, 0x12, 0x44, 0x62, 0x52, 0x65, 0x61, 0x63, 0x68, 0x61, 0x62, + 0x69, 0x6c, 0x69, 0x74, 0x79, 0x44, 0x61, 0x74, 0x61, 0x12, 0x41, 0x0a, 0x08, 0x74, 0x72, 0x65, + 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, + 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x52, 0x65, + 0x61, 0x63, 0x68, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, + 0x64, 0x65, 0x52, 0x08, 0x74, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x43, 0x0a, 0x11, + 0x66, 0x75, 0x74, 0x75, 0x72, 0x65, 0x43, 0x6f, 0x76, 0x65, 0x72, 0x69, 0x6e, 0x67, 0x53, 0x65, + 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, + 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x48, 0x61, 0x73, 0x68, 0x52, 0x11, + 0x66, 0x75, 0x74, 0x75, 0x72, 0x65, 0x43, 0x6f, 0x76, 0x65, 0x72, 0x69, 0x6e, 0x67, 0x53, 0x65, + 0x74, 0x22, 0xbd, 0x01, 0x0a, 0x16, 0x44, 0x62, 0x52, 0x65, 0x61, 0x63, 0x68, 0x61, 0x62, 0x69, + 0x6c, 0x69, 0x74, 0x79, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x31, 0x0a, 0x08, + 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, - 0x62, 0x48, 0x61, 0x73, 0x68, 0x52, 0x0d, 0x6d, 0x65, 0x72, 0x67, 0x65, 0x53, 0x65, 0x74, 0x42, - 0x6c, 0x75, 0x65, 0x73, 0x12, 0x39, 0x0a, 0x0c, 0x6d, 0x65, 0x72, 0x67, 0x65, 0x53, 0x65, 0x74, - 0x52, 0x65, 0x64, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x73, 0x65, 0x72, - 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x48, 0x61, 0x73, - 0x68, 0x52, 0x0c, 0x6d, 0x65, 0x72, 0x67, 0x65, 0x53, 0x65, 0x74, 0x52, 0x65, 0x64, 0x73, 0x12, - 0x53, 0x0a, 0x12, 0x62, 0x6c, 0x75, 0x65, 0x73, 0x41, 0x6e, 0x74, 0x69, 0x63, 0x6f, 0x6e, 0x65, - 0x53, 0x69, 0x7a, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x65, - 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x42, 0x6c, - 0x75, 0x65, 0x73, 0x41, 0x6e, 0x74, 0x69, 0x63, 0x6f, 0x6e, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x73, - 0x52, 0x12, 0x62, 0x6c, 0x75, 0x65, 0x73, 0x41, 0x6e, 0x74, 0x69, 0x63, 0x6f, 0x6e, 0x65, 0x53, - 0x69, 0x7a, 0x65, 0x73, 0x22, 0x6d, 0x0a, 0x14, 0x44, 0x62, 0x42, 0x6c, 0x75, 0x65, 0x73, 0x41, - 0x6e, 0x74, 0x69, 0x63, 0x6f, 0x6e, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x73, 0x12, 0x31, 0x0a, 0x08, - 0x62, 0x6c, 0x75, 0x65, 0x48, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, - 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, - 0x62, 0x48, 0x61, 0x73, 0x68, 0x52, 0x08, 0x62, 0x6c, 0x75, 0x65, 0x48, 0x61, 0x73, 0x68, 0x12, - 0x22, 0x0a, 0x0c, 0x61, 0x6e, 0x74, 0x69, 0x63, 0x6f, 0x6e, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x61, 0x6e, 0x74, 0x69, 0x63, 0x6f, 0x6e, 0x65, 0x53, - 0x69, 0x7a, 0x65, 0x22, 0x28, 0x0a, 0x0a, 0x44, 0x62, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x73, 0x65, - 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x73, 0x65, 0x74, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x08, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x73, 0x65, 0x74, 0x22, 0x46, 0x0a, - 0x09, 0x44, 0x62, 0x55, 0x74, 0x78, 0x6f, 0x53, 0x65, 0x74, 0x12, 0x39, 0x0a, 0x05, 0x69, 0x74, - 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x65, 0x72, 0x69, - 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x55, 0x74, 0x78, 0x6f, - 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x05, - 0x69, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x87, 0x01, 0x0a, 0x14, 0x44, 0x62, 0x55, 0x74, 0x78, 0x6f, - 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x35, - 0x0a, 0x08, 0x6f, 0x75, 0x74, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x19, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x2e, 0x44, 0x62, 0x4f, 0x75, 0x74, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x08, 0x6f, 0x75, 0x74, - 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x75, 0x74, 0x78, 0x6f, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, - 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x55, 0x74, 0x78, 0x6f, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x75, 0x74, 0x78, 0x6f, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x22, - 0x97, 0x01, 0x0a, 0x0b, 0x44, 0x62, 0x55, 0x74, 0x78, 0x6f, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, - 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x28, 0x0a, 0x0f, 0x73, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x0f, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, - 0x79, 0x12, 0x26, 0x0a, 0x0e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x42, 0x6c, 0x75, 0x65, 0x53, 0x63, - 0x6f, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, - 0x42, 0x6c, 0x75, 0x65, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x73, 0x43, - 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x69, - 0x73, 0x43, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x22, 0x9c, 0x01, 0x0a, 0x12, 0x44, 0x62, - 0x52, 0x65, 0x61, 0x63, 0x68, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x44, 0x61, 0x74, 0x61, - 0x12, 0x41, 0x0a, 0x08, 0x74, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x52, 0x65, 0x61, 0x63, 0x68, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, - 0x79, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x08, 0x74, 0x72, 0x65, 0x65, 0x4e, - 0x6f, 0x64, 0x65, 0x12, 0x43, 0x0a, 0x11, 0x66, 0x75, 0x74, 0x75, 0x72, 0x65, 0x43, 0x6f, 0x76, - 0x65, 0x72, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, - 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, - 0x62, 0x48, 0x61, 0x73, 0x68, 0x52, 0x11, 0x66, 0x75, 0x74, 0x75, 0x72, 0x65, 0x43, 0x6f, 0x76, - 0x65, 0x72, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x74, 0x22, 0xbd, 0x01, 0x0a, 0x16, 0x44, 0x62, 0x52, - 0x65, 0x61, 0x63, 0x68, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x54, 0x72, 0x65, 0x65, 0x4e, - 0x6f, 0x64, 0x65, 0x12, 0x31, 0x0a, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x18, - 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x48, 0x61, 0x73, 0x68, 0x52, 0x08, 0x63, 0x68, - 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x12, 0x2d, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, - 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x48, 0x61, 0x73, 0x68, 0x52, 0x06, 0x70, - 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x41, 0x0a, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, - 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, - 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x52, 0x65, 0x61, 0x63, 0x68, 0x61, - 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x52, 0x08, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x22, 0x40, 0x0a, 0x16, 0x44, 0x62, 0x52, 0x65, - 0x61, 0x63, 0x68, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, - 0x61, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x04, 0x52, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x65, 0x6e, 0x64, 0x22, 0x88, 0x01, 0x0a, 0x0a, 0x44, - 0x62, 0x55, 0x74, 0x78, 0x6f, 0x44, 0x69, 0x66, 0x66, 0x12, 0x39, 0x0a, 0x05, 0x74, 0x6f, 0x41, - 0x64, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, - 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x55, 0x74, 0x78, 0x6f, 0x43, - 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x05, 0x74, - 0x6f, 0x41, 0x64, 0x64, 0x12, 0x3f, 0x0a, 0x08, 0x74, 0x6f, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, - 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x62, 0x55, 0x74, 0x78, 0x6f, 0x43, 0x6f, 0x6c, - 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x08, 0x74, 0x6f, 0x52, - 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x42, 0x2a, 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x6e, 0x65, 0x74, 0x2f, 0x6b, 0x61, 0x73, - 0x70, 0x61, 0x64, 0x2f, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x62, 0x48, 0x61, 0x73, 0x68, 0x52, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x12, + 0x2d, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x15, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, + 0x44, 0x62, 0x48, 0x61, 0x73, 0x68, 0x52, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x41, + 0x0a, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x2e, 0x44, 0x62, 0x52, 0x65, 0x61, 0x63, 0x68, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x49, + 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, + 0x6c, 0x22, 0x40, 0x0a, 0x16, 0x44, 0x62, 0x52, 0x65, 0x61, 0x63, 0x68, 0x61, 0x62, 0x69, 0x6c, + 0x69, 0x74, 0x79, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x73, + 0x74, 0x61, 0x72, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x73, 0x74, 0x61, 0x72, + 0x74, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, + 0x65, 0x6e, 0x64, 0x22, 0x88, 0x01, 0x0a, 0x0a, 0x44, 0x62, 0x55, 0x74, 0x78, 0x6f, 0x44, 0x69, + 0x66, 0x66, 0x12, 0x39, 0x0a, 0x05, 0x74, 0x6f, 0x41, 0x64, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x2e, 0x44, 0x62, 0x55, 0x74, 0x78, 0x6f, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x05, 0x74, 0x6f, 0x41, 0x64, 0x64, 0x12, 0x3f, 0x0a, + 0x08, 0x74, 0x6f, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x23, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, + 0x44, 0x62, 0x55, 0x74, 0x78, 0x6f, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x49, 0x74, 0x65, 0x6d, 0x52, 0x08, 0x74, 0x6f, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x42, 0x2a, + 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x61, 0x73, + 0x70, 0x61, 0x6e, 0x65, 0x74, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x2f, 0x73, 0x65, 0x72, + 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -1711,34 +1710,33 @@ var file_messages_proto_depIdxs = []int32{ 7, // 7: serialization.DbTransaction.outputs:type_name -> serialization.DbTransactionOutput 8, // 8: serialization.DbTransaction.subnetworkID:type_name -> serialization.DbSubnetworkId 2, // 9: serialization.DbTransaction.payloadHash:type_name -> serialization.DbHash - 2, // 10: serialization.DbTransaction.payload:type_name -> serialization.DbHash - 5, // 11: serialization.DbTransactionInput.previousOutpoint:type_name -> serialization.DbOutpoint - 6, // 12: serialization.DbOutpoint.transactionID:type_name -> serialization.DbTransactionId - 10, // 13: serialization.DbAcceptanceData.blockAcceptanceData:type_name -> serialization.DbBlockAcceptanceData - 11, // 14: serialization.DbBlockAcceptanceData.transactionAcceptanceData:type_name -> serialization.DbTransactionAcceptanceData - 3, // 15: serialization.DbTransactionAcceptanceData.transaction:type_name -> serialization.DbTransaction - 2, // 16: serialization.DbBlockRelations.parents:type_name -> serialization.DbHash - 2, // 17: serialization.DbBlockRelations.children:type_name -> serialization.DbHash - 2, // 18: serialization.DbBlockGhostdagData.selectedParent:type_name -> serialization.DbHash - 2, // 19: serialization.DbBlockGhostdagData.mergeSetBlues:type_name -> serialization.DbHash - 2, // 20: serialization.DbBlockGhostdagData.mergeSetReds:type_name -> serialization.DbHash - 15, // 21: serialization.DbBlockGhostdagData.bluesAnticoneSizes:type_name -> serialization.DbBluesAnticoneSizes - 2, // 22: serialization.DbBluesAnticoneSizes.blueHash:type_name -> serialization.DbHash - 18, // 23: serialization.DbUtxoSet.items:type_name -> serialization.DbUtxoCollectionItem - 5, // 24: serialization.DbUtxoCollectionItem.outpoint:type_name -> serialization.DbOutpoint - 19, // 25: serialization.DbUtxoCollectionItem.utxoEntry:type_name -> serialization.DbUtxoEntry - 21, // 26: serialization.DbReachabilityData.treeNode:type_name -> serialization.DbReachabilityTreeNode - 2, // 27: serialization.DbReachabilityData.futureCoveringSet:type_name -> serialization.DbHash - 2, // 28: serialization.DbReachabilityTreeNode.children:type_name -> serialization.DbHash - 2, // 29: serialization.DbReachabilityTreeNode.parent:type_name -> serialization.DbHash - 22, // 30: serialization.DbReachabilityTreeNode.interval:type_name -> serialization.DbReachabilityInterval - 18, // 31: serialization.DbUtxoDiff.toAdd:type_name -> serialization.DbUtxoCollectionItem - 18, // 32: serialization.DbUtxoDiff.toRemove:type_name -> serialization.DbUtxoCollectionItem - 33, // [33:33] is the sub-list for method output_type - 33, // [33:33] is the sub-list for method input_type - 33, // [33:33] is the sub-list for extension type_name - 33, // [33:33] is the sub-list for extension extendee - 0, // [0:33] is the sub-list for field type_name + 5, // 10: serialization.DbTransactionInput.previousOutpoint:type_name -> serialization.DbOutpoint + 6, // 11: serialization.DbOutpoint.transactionID:type_name -> serialization.DbTransactionId + 10, // 12: serialization.DbAcceptanceData.blockAcceptanceData:type_name -> serialization.DbBlockAcceptanceData + 11, // 13: serialization.DbBlockAcceptanceData.transactionAcceptanceData:type_name -> serialization.DbTransactionAcceptanceData + 3, // 14: serialization.DbTransactionAcceptanceData.transaction:type_name -> serialization.DbTransaction + 2, // 15: serialization.DbBlockRelations.parents:type_name -> serialization.DbHash + 2, // 16: serialization.DbBlockRelations.children:type_name -> serialization.DbHash + 2, // 17: serialization.DbBlockGhostdagData.selectedParent:type_name -> serialization.DbHash + 2, // 18: serialization.DbBlockGhostdagData.mergeSetBlues:type_name -> serialization.DbHash + 2, // 19: serialization.DbBlockGhostdagData.mergeSetReds:type_name -> serialization.DbHash + 15, // 20: serialization.DbBlockGhostdagData.bluesAnticoneSizes:type_name -> serialization.DbBluesAnticoneSizes + 2, // 21: serialization.DbBluesAnticoneSizes.blueHash:type_name -> serialization.DbHash + 18, // 22: serialization.DbUtxoSet.items:type_name -> serialization.DbUtxoCollectionItem + 5, // 23: serialization.DbUtxoCollectionItem.outpoint:type_name -> serialization.DbOutpoint + 19, // 24: serialization.DbUtxoCollectionItem.utxoEntry:type_name -> serialization.DbUtxoEntry + 21, // 25: serialization.DbReachabilityData.treeNode:type_name -> serialization.DbReachabilityTreeNode + 2, // 26: serialization.DbReachabilityData.futureCoveringSet:type_name -> serialization.DbHash + 2, // 27: serialization.DbReachabilityTreeNode.children:type_name -> serialization.DbHash + 2, // 28: serialization.DbReachabilityTreeNode.parent:type_name -> serialization.DbHash + 22, // 29: serialization.DbReachabilityTreeNode.interval:type_name -> serialization.DbReachabilityInterval + 18, // 30: serialization.DbUtxoDiff.toAdd:type_name -> serialization.DbUtxoCollectionItem + 18, // 31: serialization.DbUtxoDiff.toRemove:type_name -> serialization.DbUtxoCollectionItem + 32, // [32:32] is the sub-list for method output_type + 32, // [32:32] is the sub-list for method input_type + 32, // [32:32] is the sub-list for extension type_name + 32, // [32:32] is the sub-list for extension extendee + 0, // [0:32] is the sub-list for field type_name } func init() { file_messages_proto_init() } diff --git a/domain/consensus/database/serialization/messages.proto b/domain/consensus/database/serialization/messages.proto index edef53493..3fe5091c1 100644 --- a/domain/consensus/database/serialization/messages.proto +++ b/domain/consensus/database/serialization/messages.proto @@ -31,7 +31,7 @@ message DbTransaction { DbSubnetworkId subnetworkID = 5; uint64 gas = 6; DbHash payloadHash = 7; - DbHash payload = 8; + bytes payload = 8; } message DbTransactionInput { diff --git a/domain/consensus/database/serialization/outpoint.go b/domain/consensus/database/serialization/outpoint.go new file mode 100644 index 000000000..aa3b5e155 --- /dev/null +++ b/domain/consensus/database/serialization/outpoint.go @@ -0,0 +1,26 @@ +package serialization + +import ( + "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" +) + +// DomainOutpointToDbOutpoint converts DomainOutpoint to DbOutpoint +func DomainOutpointToDbOutpoint(domainOutpoint *externalapi.DomainOutpoint) *DbOutpoint { + return &DbOutpoint{ + TransactionID: DomainTransactionIDToDbTransactionID(&domainOutpoint.TransactionID), + Index: domainOutpoint.Index, + } +} + +// DbOutpointToDomainOutpoint converts DbOutpoint to DomainOutpoint +func DbOutpointToDomainOutpoint(dbOutpoint *DbOutpoint) (*externalapi.DomainOutpoint, error) { + domainTransactionID, err := DbTransactionIDToDomainTransactionID(dbOutpoint.TransactionID) + if err != nil { + return nil, err + } + + return &externalapi.DomainOutpoint{ + TransactionID: *domainTransactionID, + Index: dbOutpoint.Index, + }, nil +} diff --git a/domain/consensus/database/serialization/subnetworkid.go b/domain/consensus/database/serialization/subnetworkid.go new file mode 100644 index 000000000..f1775b3fb --- /dev/null +++ b/domain/consensus/database/serialization/subnetworkid.go @@ -0,0 +1,16 @@ +package serialization + +import ( + "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" + "github.com/kaspanet/kaspad/domain/consensus/utils/subnetworks" +) + +// DbSubnetworkIDToDomainSubnetworkID converts DbSubnetworkId to DomainSubnetworkID +func DbSubnetworkIDToDomainSubnetworkID(dbSubnetworkID *DbSubnetworkId) (*externalapi.DomainSubnetworkID, error) { + return subnetworks.FromBytes(dbSubnetworkID.SubnetworkId) +} + +// DomainSubnetworkIDToDbSubnetworkID converts DomainSubnetworkID to DbSubnetworkId +func DomainSubnetworkIDToDbSubnetworkID(domainSubnetworkID *externalapi.DomainSubnetworkID) *DbSubnetworkId { + return &DbSubnetworkId{SubnetworkId: domainSubnetworkID[:]} +} diff --git a/domain/consensus/database/serialization/transaction.go b/domain/consensus/database/serialization/transaction.go new file mode 100644 index 000000000..60d8a30eb --- /dev/null +++ b/domain/consensus/database/serialization/transaction.go @@ -0,0 +1,80 @@ +package serialization + +import ( + "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" +) + +// DomainTransactionToDbTransaction converts DomainTransaction to DbTransaction +func DomainTransactionToDbTransaction(domainTransaction *externalapi.DomainTransaction) *DbTransaction { + dbInputs := make([]*DbTransactionInput, len(domainTransaction.Inputs)) + for i, domainTransactionInput := range domainTransaction.Inputs { + dbInputs[i] = &DbTransactionInput{ + PreviousOutpoint: DomainOutpointToDbOutpoint(&domainTransactionInput.PreviousOutpoint), + SignatureScript: domainTransactionInput.SignatureScript, + Sequence: domainTransactionInput.Sequence, + } + } + + dbOutputs := make([]*DbTransactionOutput, len(domainTransaction.Outputs)) + for i, domainTransactionOutput := range domainTransaction.Outputs { + dbOutputs[i] = &DbTransactionOutput{ + Value: domainTransactionOutput.Value, + ScriptPublicKey: domainTransactionOutput.ScriptPublicKey, + } + } + + return &DbTransaction{ + Version: domainTransaction.Version, + Inputs: dbInputs, + Outputs: dbOutputs, + LockTime: domainTransaction.LockTime, + SubnetworkID: DomainSubnetworkIDToDbSubnetworkID(&domainTransaction.SubnetworkID), + Gas: domainTransaction.Gas, + PayloadHash: DomainHashToDbHash(&domainTransaction.PayloadHash), + Payload: domainTransaction.Payload, + } +} + +// DbTransactionToDomainTransaction converts DbTransaction to DomainTransaction +func DbTransactionToDomainTransaction(dbTransaction *DbTransaction) (*externalapi.DomainTransaction, error) { + domainSubnetworkID, err := DbSubnetworkIDToDomainSubnetworkID(dbTransaction.SubnetworkID) + if err != nil { + return nil, err + } + domainPayloadHash, err := DbHashToDomainHash(dbTransaction.PayloadHash) + if err != nil { + return nil, err + } + + domainInputs := make([]*externalapi.DomainTransactionInput, len(dbTransaction.Inputs)) + for i, dbTransactionInput := range dbTransaction.Inputs { + domainPreviousOutpoint, err := DbOutpointToDomainOutpoint(dbTransactionInput.PreviousOutpoint) + if err != nil { + return nil, err + } + domainInputs[i] = &externalapi.DomainTransactionInput{ + PreviousOutpoint: *domainPreviousOutpoint, + SignatureScript: dbTransactionInput.SignatureScript, + Sequence: dbTransactionInput.Sequence, + } + } + + domainOutputs := make([]*externalapi.DomainTransactionOutput, len(dbTransaction.Outputs)) + for i, dbTransactionOutput := range dbTransaction.Outputs { + domainOutputs[i] = &externalapi.DomainTransactionOutput{ + Value: dbTransactionOutput.Value, + ScriptPublicKey: dbTransactionOutput.ScriptPublicKey, + } + } + + return &externalapi.DomainTransaction{ + Version: dbTransaction.Version, + Inputs: domainInputs, + Outputs: domainOutputs, + LockTime: dbTransaction.LockTime, + SubnetworkID: *domainSubnetworkID, + Gas: dbTransaction.Gas, + PayloadHash: *domainPayloadHash, + Payload: dbTransaction.Payload, + }, nil +} diff --git a/domain/consensus/database/serialization/transactionid.go b/domain/consensus/database/serialization/transactionid.go new file mode 100644 index 000000000..dab925b7b --- /dev/null +++ b/domain/consensus/database/serialization/transactionid.go @@ -0,0 +1,16 @@ +package serialization + +import ( + "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" + "github.com/kaspanet/kaspad/domain/consensus/utils/transactionid" +) + +// DbTransactionIDToDomainTransactionID converts DbTransactionId to DomainTransactionID +func DbTransactionIDToDomainTransactionID(dbTransactionID *DbTransactionId) (*externalapi.DomainTransactionID, error) { + return transactionid.FromBytes(dbTransactionID.TransactionId) +} + +// DomainTransactionIDToDbTransactionID converts DomainTransactionID to DbTransactionId +func DomainTransactionIDToDbTransactionID(domainTransactionID *externalapi.DomainTransactionID) *DbTransactionId { + return &DbTransactionId{TransactionId: domainTransactionID[:]} +} diff --git a/domain/consensus/datastructures/acceptancedatastore/acceptancedatastore.go b/domain/consensus/datastructures/acceptancedatastore/acceptancedatastore.go index cedb186af..fc2c4e282 100644 --- a/domain/consensus/datastructures/acceptancedatastore/acceptancedatastore.go +++ b/domain/consensus/datastructures/acceptancedatastore/acceptancedatastore.go @@ -1,9 +1,11 @@ package acceptancedatastore import ( + "github.com/kaspanet/kaspad/domain/consensus/database/serialization" "github.com/kaspanet/kaspad/domain/consensus/model" "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" "github.com/kaspanet/kaspad/domain/consensus/utils/dbkeys" + "google.golang.org/protobuf/proto" ) var bucket = dbkeys.MakeBucket([]byte("acceptance-data")) @@ -35,7 +37,11 @@ func (ads *acceptanceDataStore) Discard() { func (ads *acceptanceDataStore) Commit(dbTx model.DBTransaction) error { for hash, acceptanceData := range ads.staging { - err := dbTx.Put(ads.hashAsKey(&hash), ads.serializeAcceptanceData(acceptanceData)) + acceptanceDataBytes, err := ads.serializeAcceptanceData(acceptanceData) + if err != nil { + return err + } + err = dbTx.Put(ads.hashAsKey(&hash), acceptanceDataBytes) if err != nil { return err } @@ -68,12 +74,18 @@ func (ads *acceptanceDataStore) Delete(dbTx model.DBTransaction, blockHash *exte return dbTx.Delete(ads.hashAsKey(blockHash)) } -func (ads *acceptanceDataStore) serializeAcceptanceData(acceptanceData model.AcceptanceData) []byte { - panic("implement me") +func (ads *acceptanceDataStore) serializeAcceptanceData(acceptanceData model.AcceptanceData) ([]byte, error) { + dbAcceptanceData := serialization.DomainAcceptanceDataToDbAcceptanceData(acceptanceData) + return proto.Marshal(dbAcceptanceData) } func (ads *acceptanceDataStore) deserializeAcceptanceData(acceptanceDataBytes []byte) (model.AcceptanceData, error) { - panic("implement me") + dbAcceptanceData := &serialization.DbAcceptanceData{} + err := proto.Unmarshal(acceptanceDataBytes, dbAcceptanceData) + if err != nil { + return nil, err + } + return serialization.DbAcceptanceDataToDomainAcceptanceData(dbAcceptanceData) } func (ads *acceptanceDataStore) hashAsKey(hash *externalapi.DomainHash) model.DBKey { diff --git a/domain/consensus/datastructures/blockheaderstore/blockheaderstore.go b/domain/consensus/datastructures/blockheaderstore/blockheaderstore.go index 42ffe2b50..0e1892ece 100644 --- a/domain/consensus/datastructures/blockheaderstore/blockheaderstore.go +++ b/domain/consensus/datastructures/blockheaderstore/blockheaderstore.go @@ -6,7 +6,6 @@ import ( "github.com/kaspanet/kaspad/domain/consensus/model" "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" "github.com/kaspanet/kaspad/domain/consensus/utils/dbkeys" - "github.com/kaspanet/kaspad/domain/consensus/utils/hashes" ) var bucket = dbkeys.MakeBucket([]byte("block-headers")) @@ -107,22 +106,7 @@ func (bms *blockHeaderStore) hashAsKey(hash *externalapi.DomainHash) model.DBKey } func (bms *blockHeaderStore) serializeHeader(header *externalapi.DomainBlockHeader) ([]byte, error) { - dbParentHashes := make([]*serialization.DbHash, len(header.ParentHashes)) - for i, parentHash := range header.ParentHashes { - dbParentHashes[i] = &serialization.DbHash{Hash: parentHash[:]} - } - - dbBlockHeader := &serialization.DbBlockHeader{ - Version: header.Version, - ParentHashes: dbParentHashes, - HashMerkleRoot: &serialization.DbHash{Hash: header.HashMerkleRoot[:]}, - AcceptedIDMerkleRoot: &serialization.DbHash{Hash: header.AcceptedIDMerkleRoot[:]}, - UtxoCommitment: &serialization.DbHash{Hash: header.UTXOCommitment[:]}, - TimeInMilliseconds: header.TimeInMilliseconds, - Bits: header.Bits, - Nonce: header.Nonce, - } - + dbBlockHeader := serialization.DomainBlockHeaderToDbBlockHeader(header) return proto.Marshal(dbBlockHeader) } @@ -132,35 +116,5 @@ func (bms *blockHeaderStore) deserializeHeader(headerBytes []byte) (*externalapi if err != nil { return nil, err } - - parentHashes := make([]*externalapi.DomainHash, len(dbBlockHeader.ParentHashes)) - for i, dbParentHash := range dbBlockHeader.ParentHashes { - parentHashes[i], err = hashes.FromBytes(dbParentHash.Hash) - if err != nil { - return nil, err - } - } - hashMerkleRoot, err := hashes.FromBytes(dbBlockHeader.HashMerkleRoot.Hash) - if err != nil { - return nil, err - } - acceptedIDMerkleRoot, err := hashes.FromBytes(dbBlockHeader.AcceptedIDMerkleRoot.Hash) - if err != nil { - return nil, err - } - utxoCommitment, err := hashes.FromBytes(dbBlockHeader.UtxoCommitment.Hash) - if err != nil { - return nil, err - } - - return &externalapi.DomainBlockHeader{ - Version: dbBlockHeader.Version, - ParentHashes: parentHashes, - HashMerkleRoot: *hashMerkleRoot, - AcceptedIDMerkleRoot: *acceptedIDMerkleRoot, - UTXOCommitment: *utxoCommitment, - TimeInMilliseconds: dbBlockHeader.TimeInMilliseconds, - Bits: dbBlockHeader.Bits, - Nonce: dbBlockHeader.Nonce, - }, nil + return serialization.DbBlockHeaderToDomainBlockHeader(dbBlockHeader) } diff --git a/domain/consensus/datastructures/blockrelationstore/blockrelationstore.go b/domain/consensus/datastructures/blockrelationstore/blockrelationstore.go index bfd5a5de6..28bfdb901 100644 --- a/domain/consensus/datastructures/blockrelationstore/blockrelationstore.go +++ b/domain/consensus/datastructures/blockrelationstore/blockrelationstore.go @@ -1,6 +1,8 @@ package blockrelationstore import ( + "github.com/golang/protobuf/proto" + "github.com/kaspanet/kaspad/domain/consensus/database/serialization" "github.com/kaspanet/kaspad/domain/consensus/model" "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" "github.com/kaspanet/kaspad/domain/consensus/utils/dbkeys" @@ -34,7 +36,11 @@ func (brs *blockRelationStore) Discard() { func (brs *blockRelationStore) Commit(dbTx model.DBTransaction) error { for hash, blockRelations := range brs.staging { - err := dbTx.Put(brs.hashAsKey(&hash), brs.serializeBlockRelations(blockRelations)) + blockRelationBytes, err := brs.serializeBlockRelations(blockRelations) + if err != nil { + return err + } + err = dbTx.Put(brs.hashAsKey(&hash), blockRelationBytes) if err != nil { return err } @@ -57,14 +63,20 @@ func (brs *blockRelationStore) BlockRelation(dbContext model.DBReader, blockHash return brs.deserializeBlockRelations(blockRelationsBytes) } -func (brs *blockRelationStore) serializeBlockRelations(blockRelations *model.BlockRelations) []byte { - panic("implement me") -} - -func (brs *blockRelationStore) deserializeBlockRelations(blockRelationsBytes []byte) (*model.BlockRelations, error) { - panic("implement me") -} - func (brs *blockRelationStore) hashAsKey(hash *externalapi.DomainHash) model.DBKey { return bucket.Key(hash[:]) } + +func (brs *blockRelationStore) serializeBlockRelations(blockRelations *model.BlockRelations) ([]byte, error) { + dbBlockRelations := serialization.DomainBlockRelationsToDbBlockRelations(blockRelations) + return proto.Marshal(dbBlockRelations) +} + +func (brs *blockRelationStore) deserializeBlockRelations(blockRelationsBytes []byte) (*model.BlockRelations, error) { + dbBlockRelations := &serialization.DbBlockRelations{} + err := proto.Unmarshal(blockRelationsBytes, dbBlockRelations) + if err != nil { + return nil, err + } + return serialization.DbBlockRelationsToDomainBlockRelations(dbBlockRelations) +} diff --git a/domain/consensus/datastructures/blockstatusstore/blockstatusstore.go b/domain/consensus/datastructures/blockstatusstore/blockstatusstore.go index 342a36804..7dc718640 100644 --- a/domain/consensus/datastructures/blockstatusstore/blockstatusstore.go +++ b/domain/consensus/datastructures/blockstatusstore/blockstatusstore.go @@ -1,6 +1,8 @@ package blockstatusstore import ( + "github.com/golang/protobuf/proto" + "github.com/kaspanet/kaspad/domain/consensus/database/serialization" "github.com/kaspanet/kaspad/domain/consensus/model" "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" "github.com/kaspanet/kaspad/domain/consensus/utils/dbkeys" @@ -35,7 +37,11 @@ func (bss *blockStatusStore) Discard() { func (bss *blockStatusStore) Commit(dbTx model.DBTransaction) error { for hash, status := range bss.staging { - err := dbTx.Put(bss.hashAsKey(&hash), bss.serializeBlockStatus(status)) + blockStatusBytes, err := bss.serializeBlockStatus(status) + if err != nil { + return err + } + err = dbTx.Put(bss.hashAsKey(&hash), blockStatusBytes) if err != nil { return err } @@ -73,12 +79,18 @@ func (bss *blockStatusStore) Exists(dbContext model.DBReader, blockHash *externa return exists, nil } -func (bss *blockStatusStore) serializeBlockStatus(status model.BlockStatus) []byte { - panic("implement me") +func (bss *blockStatusStore) serializeBlockStatus(status model.BlockStatus) ([]byte, error) { + dbBlockStatus := serialization.DomainBlockStatusToDbBlockStatus(status) + return proto.Marshal(dbBlockStatus) } func (bss *blockStatusStore) deserializeHeader(statusBytes []byte) (model.BlockStatus, error) { - panic("implement me") + dbBlockStatus := &serialization.DbBlockStatus{} + err := proto.Unmarshal(statusBytes, dbBlockStatus) + if err != nil { + return 0, err + } + return serialization.DbBlockStatusToDomainBlockStatus(dbBlockStatus), nil } func (bss *blockStatusStore) hashAsKey(hash *externalapi.DomainHash) model.DBKey { diff --git a/domain/consensus/datastructures/blockstore/blockstore.go b/domain/consensus/datastructures/blockstore/blockstore.go index 1cd9a8c5b..c8f164cc5 100644 --- a/domain/consensus/datastructures/blockstore/blockstore.go +++ b/domain/consensus/datastructures/blockstore/blockstore.go @@ -1,6 +1,8 @@ package blockstore import ( + "github.com/golang/protobuf/proto" + "github.com/kaspanet/kaspad/domain/consensus/database/serialization" "github.com/kaspanet/kaspad/domain/consensus/model" "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" "github.com/kaspanet/kaspad/domain/consensus/utils/dbkeys" @@ -35,7 +37,11 @@ func (bms *blockStore) Discard() { func (bms *blockStore) Commit(dbTx model.DBTransaction) error { for hash, block := range bms.staging { - err := dbTx.Put(bms.hashAsKey(&hash), bms.serializeBlock(block)) + blockBytes, err := bms.serializeBlock(block) + if err != nil { + return err + } + err = dbTx.Put(bms.hashAsKey(&hash), blockBytes) if err != nil { return err } @@ -95,12 +101,18 @@ func (bms *blockStore) Delete(dbTx model.DBTransaction, blockHash *externalapi.D return dbTx.Delete(bms.hashAsKey(blockHash)) } -func (bms *blockStore) serializeBlock(block *externalapi.DomainBlock) []byte { - panic("implement me") +func (bms *blockStore) serializeBlock(block *externalapi.DomainBlock) ([]byte, error) { + dbBlock := serialization.DomainBlockToDbBlock(block) + return proto.Marshal(dbBlock) } func (bms *blockStore) deserializeBlock(blockBytes []byte) (*externalapi.DomainBlock, error) { - panic("implement me") + dbBlock := &serialization.DbBlock{} + err := proto.Unmarshal(blockBytes, dbBlock) + if err != nil { + return nil, err + } + return serialization.DbBlockToDomainBlock(dbBlock) } func (bms *blockStore) hashAsKey(hash *externalapi.DomainHash) model.DBKey { diff --git a/domain/consensus/utils/subnetworks/from_bytes.go b/domain/consensus/utils/subnetworks/from_bytes.go new file mode 100644 index 000000000..a2e612d80 --- /dev/null +++ b/domain/consensus/utils/subnetworks/from_bytes.go @@ -0,0 +1,17 @@ +package subnetworks + +import ( + "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" + "github.com/pkg/errors" +) + +// FromBytes creates a DomainSubnetworkID from the given byte slice +func FromBytes(subnetworkIDBytes []byte) (*externalapi.DomainSubnetworkID, error) { + if len(subnetworkIDBytes) != externalapi.DomainSubnetworkIDSize { + return nil, errors.Errorf("invalid hash size. Want: %d, got: %d", + externalapi.DomainSubnetworkIDSize, len(subnetworkIDBytes)) + } + var domainSubnetworkID externalapi.DomainSubnetworkID + copy(domainSubnetworkID[:], subnetworkIDBytes) + return &domainSubnetworkID, nil +} diff --git a/domain/consensus/utils/transactionid/from_bytes.go b/domain/consensus/utils/transactionid/from_bytes.go new file mode 100644 index 000000000..d407f4b88 --- /dev/null +++ b/domain/consensus/utils/transactionid/from_bytes.go @@ -0,0 +1,17 @@ +package transactionid + +import ( + "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" + "github.com/pkg/errors" +) + +// FromBytes creates a DomainTransactionID from the given byte slice +func FromBytes(transactionIDBytes []byte) (*externalapi.DomainTransactionID, error) { + if len(transactionIDBytes) != externalapi.DomainHashSize { + return nil, errors.Errorf("invalid hash size. Want: %d, got: %d", + externalapi.DomainHashSize, len(transactionIDBytes)) + } + var domainTransactionID externalapi.DomainTransactionID + copy(domainTransactionID[:], transactionIDBytes) + return &domainTransactionID, nil +}