-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
540 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package chain | ||
|
||
import ( | ||
"github.com/kwilteam/kwil-db/core/types" | ||
) | ||
|
||
type HealthRequest struct{} | ||
|
||
type BlockRequest struct { | ||
Height int64 `json:"height"` | ||
// Hash is the block hash. If both Height and Hash are provided, hash will | ||
// be used | ||
Hash types.Hash `json:"hash"` | ||
} | ||
|
||
type BlockResultRequest struct { | ||
Height int64 `json:"height"` | ||
// Hash is the block hash. If both Height and Hash are provided, hash will | ||
// be used | ||
Hash types.Hash `json:"hash"` | ||
} | ||
|
||
type TxRequest struct { | ||
Hash types.Hash `json:"hash"` | ||
} | ||
type ListTxsRequest struct { | ||
} | ||
|
||
type GenesisRequest struct{} | ||
type ValidatorsRequest struct { | ||
Height int64 `json:"height"` | ||
} | ||
type StatusRequest struct{} | ||
|
||
type UnconfirmedTxsRequest struct { | ||
Limit int `json:"limit"` | ||
} | ||
|
||
type TxSearchRequest struct { | ||
Query string `json:"query"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package chain | ||
|
||
import ( | ||
jsonrpc "github.com/kwilteam/kwil-db/core/rpc/json" | ||
) | ||
|
||
const ( | ||
MethodVersion jsonrpc.Method = "chain.version" | ||
MethodHealth jsonrpc.Method = "chain.health" | ||
MethodBlock jsonrpc.Method = "chain.block" | ||
MethodBlockResult jsonrpc.Method = "chain.block_result" | ||
MethodTx jsonrpc.Method = "chain.tx" | ||
MethodGenesis jsonrpc.Method = "chain.genesis" | ||
MethodValidators jsonrpc.Method = "chain.validators" | ||
MethodUnconfirmedTxs jsonrpc.Method = "chain.unconfirmed_txs" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package chain | ||
|
||
import ( | ||
"encoding/json" | ||
"github.com/kwilteam/kwil-db/core/types" | ||
) | ||
|
||
// HealthResponse is the health check response. | ||
type HealthResponse struct { | ||
ChainID string `json:"chain_id"` | ||
Height int64 `json:"height"` | ||
Healthy bool `json:"healthy"` | ||
} | ||
|
||
type BlockHeader types.BlockHeader | ||
|
||
func (b BlockHeader) MarshalJSON() ([]byte, error) { | ||
return json.Marshal(&struct { | ||
Version uint16 `json:"version"` | ||
Height int64 `json:"height"` | ||
NumTxns uint32 `json:"num_txns"` | ||
PrevHash types.Hash `json:"prev_hash"` | ||
PrevAppHash types.Hash `json:"prev_app_hash"` | ||
// Timestamp is the unix millisecond timestamp | ||
Timestamp int64 `json:"timestamp"` | ||
MerkleRoot types.Hash `json:"merkle_root"` | ||
ValidatorSetHash types.Hash `json:"validator_set_hash"` | ||
}{ | ||
Version: b.Version, | ||
Height: b.Height, | ||
NumTxns: b.NumTxns, | ||
PrevHash: b.PrevHash, | ||
PrevAppHash: b.PrevAppHash, | ||
Timestamp: b.Timestamp.UnixMilli(), | ||
MerkleRoot: b.MerkleRoot, | ||
ValidatorSetHash: b.ValidatorSetHash, | ||
}) | ||
} | ||
|
||
// BlockResponse is the block information | ||
type BlockResponse struct { | ||
Header *BlockHeader `json:"header"` | ||
Txns [][]byte `json:"txns"` | ||
Signature []byte `json:"signature"` | ||
Hash types.Hash `json:"hash"` | ||
AppHash types.Hash `json:"app_hash"` | ||
} | ||
|
||
type BlockResultResponse struct { | ||
Height int64 `json:"height"` | ||
TxResults []types.TxResult `json:"tx_results"` | ||
} | ||
|
||
type GenesisResponse struct { | ||
ChainID string `json:"chain_id"` | ||
// Leader is the leader's public key. | ||
Leader types.HexBytes `json:"leader"` | ||
// Validators is the list of genesis validators (including the leader). | ||
Validators []*types.Validator `json:"validators"` | ||
|
||
// MaxBlockSize is the maximum size of a block in bytes. | ||
MaxBlockSize int64 `json:"max_block_size"` | ||
// JoinExpiry is the number of blocks after which the validators | ||
// join request expires if not approved. | ||
JoinExpiry int64 `json:"join_expiry"` | ||
// VoteExpiry is the default number of blocks after which the validators | ||
// vote expires if not approved. | ||
VoteExpiry int64 `json:"vote_expiry"` | ||
// DisabledGasCosts dictates whether gas costs are disabled. | ||
DisabledGasCosts bool `json:"disabled_gas_costs"` | ||
// MaxVotesPerTx is the maximum number of votes that can be included in a | ||
// single transaction. | ||
MaxVotesPerTx int64 `json:"max_votes_per_tx"` | ||
} | ||
type ValidatorsResponse struct { | ||
Height int64 `json:"height"` | ||
Validators []*types.Validator `json:"validators"` | ||
} | ||
|
||
type NamedTx struct { | ||
Hash types.Hash `json:"hash"` | ||
Tx []byte `json:"tx"` | ||
} | ||
|
||
type UnconfirmedTxsResponse struct { | ||
Total int `json:"total"` | ||
Txs []NamedTx `json:"txs"` | ||
} | ||
|
||
type TxSearchResponse struct{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Package types contains the type used by the chain stat RPC client and | ||
// servers. | ||
package types | ||
|
||
import "github.com/kwilteam/kwil-db/core/types" | ||
|
||
type ChainTx struct { | ||
Hash types.Hash `json:"hash"` | ||
Height int64 `json:"height"` | ||
Index uint32 `json:"index"` | ||
Tx []byte `json:"tx"` | ||
TxResult *types.TxResult `json:"tx_result"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.