Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d945029f33 | |||
| 621e359817 |
@@ -25,3 +25,16 @@ func (bc *BlockClient) Get(ctx context.Context, blockID string) (*models.Block,
|
|||||||
}
|
}
|
||||||
return &resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetInterchain traces a block to the validator (verification) blocks that
|
||||||
|
// validated it and the public-chain interchain anchors those validator blocks
|
||||||
|
// were bundled into.
|
||||||
|
func (bc *BlockClient) GetInterchain(ctx context.Context, blockID string) (*models.InterchainTrace, error) {
|
||||||
|
var resp models.InterchainTrace
|
||||||
|
path := fmt.Sprintf("/api/v1/block/%s/interchain", blockID)
|
||||||
|
err := bc.client.Get(ctx, path, &resp)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &resp, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -121,18 +121,23 @@ type SmartContractExecutionInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Block struct {
|
type Block struct {
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
ID string `json:"block_id"`
|
Header BlockHeader `json:"header"`
|
||||||
Timestamp string `json:"timestamp"`
|
Transactions []string `json:"transactions"`
|
||||||
PrevID string `json:"prev_id"`
|
Proof BlockProof `json:"proof"`
|
||||||
PrevProof string `json:"prev_proof"`
|
}
|
||||||
Transactions []string `json:"transactions"`
|
|
||||||
Proof BlockProof `json:"proof"`
|
type BlockHeader struct {
|
||||||
|
BlockId string `json:"blockId"`
|
||||||
|
DcId string `json:"dcId"`
|
||||||
|
PrevId string `json:"prevId"`
|
||||||
|
PrevProof string `json:"prevProof"`
|
||||||
|
Timestamp string `json:"timestamp"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type BlockProof struct {
|
type BlockProof struct {
|
||||||
Scheme string `json:"scheme"`
|
|
||||||
Proof string `json:"proof"`
|
Proof string `json:"proof"`
|
||||||
|
Scheme string `json:"scheme,omitempty"`
|
||||||
Nonce int64 `json:"nonce,omitempty"`
|
Nonce int64 `json:"nonce,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,3 +170,39 @@ type ListResponse struct {
|
|||||||
Items []interface{} `json:"items"`
|
Items []interface{} `json:"items"`
|
||||||
TotalCount int `json:"total_count"`
|
TotalCount int `json:"total_count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// VerificationBlock is a validator's verification of a prime block.
|
||||||
|
type VerificationBlock struct {
|
||||||
|
Version string `json:"version"`
|
||||||
|
PrimeChainId string `json:"primeChainId"`
|
||||||
|
PrimeBlockId string `json:"primeBlockId"`
|
||||||
|
Timestamp string `json:"timestamp"`
|
||||||
|
VerifierPublicKey string `json:"verifierPublicKey"`
|
||||||
|
VerifierSignature string `json:"verifierSignature"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// InterchainTransaction is an anchor broadcast to a public blockchain (e.g. ETH
|
||||||
|
// or BTC) that bundles one or more validator blocks. ValidatorBlocks holds the
|
||||||
|
// prime block ids covered; CoveredPrimeChainIds the prime chains they belong to.
|
||||||
|
type InterchainTransaction struct {
|
||||||
|
Id int `json:"id"`
|
||||||
|
Version string `json:"version"`
|
||||||
|
Timestamp string `json:"timestamp"`
|
||||||
|
ChainId string `json:"chainId"`
|
||||||
|
TransHash string `json:"transHash"`
|
||||||
|
BlockId string `json:"blockId"`
|
||||||
|
ValidatorBlocks []string `json:"validatorBlocks"`
|
||||||
|
ValidatorBlockhash string `json:"validatorBlockhash"`
|
||||||
|
Signature string `json:"signature"`
|
||||||
|
CoveredPrimeChainIds []string `json:"coveredPrimeChainIds"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// InterchainTrace links a prime block to the validator (verification) blocks
|
||||||
|
// that validated it and the public-chain interchain anchors those validator
|
||||||
|
// blocks were bundled into. Returned by Transaction.GetInterchain and
|
||||||
|
// Block.GetInterchain.
|
||||||
|
type InterchainTrace struct {
|
||||||
|
BlockId string `json:"blockId"`
|
||||||
|
ValidatorBlocks []VerificationBlock `json:"validatorBlocks"`
|
||||||
|
InterchainTransactions []InterchainTransaction `json:"interchainTransactions"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -52,6 +52,20 @@ func (tc *TransactionClient) Get(ctx context.Context, transactionID string) (*mo
|
|||||||
return &resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetInterchain traces a transaction to the validator (verification) blocks that
|
||||||
|
// validated its prime block and the public-chain interchain anchors those
|
||||||
|
// validator blocks were bundled into. If the transaction is still pending (not
|
||||||
|
// yet in a block) the trace's slices are empty.
|
||||||
|
func (tc *TransactionClient) GetInterchain(ctx context.Context, transactionID string) (*models.InterchainTrace, error) {
|
||||||
|
var resp models.InterchainTrace
|
||||||
|
path := fmt.Sprintf("/api/v1/transaction/%s/interchain", transactionID)
|
||||||
|
err := tc.client.Get(ctx, path, &resp)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (tc *TransactionClient) List(ctx context.Context) (*models.ListTransactionsResponse, error) {
|
func (tc *TransactionClient) List(ctx context.Context) (*models.ListTransactionsResponse, error) {
|
||||||
var resp models.ListTransactionsResponse
|
var resp models.ListTransactionsResponse
|
||||||
path := "/api/v1/transaction/"
|
path := "/api/v1/transaction/"
|
||||||
|
|||||||
Reference in New Issue
Block a user