Documentation ¶
Index ¶
- Constants
- func NodesRegister(router *gin.RouterGroup, env *NodesEnv)
- func RunDomain(r *gin.Engine, nodeService *NodeService, state models.State, ...) error
- type BlockHeaderResponse
- type BlockHeight
- type BlockResponse
- type BlockSerializer
- type BlocksResponse
- type BlocksSerializer
- type ListBlocksParam
- type NetworkNode
- type NetworkNodeAddress
- type NetworkNodeFromDB
- type NetworkNodeName
- type NetworkNodeRecord
- type NetworkNodeResponse
- type NetworkNodeStatus
- type NetworkNodesResponse
- type NodeGetStatusResponse
- type NodeSerializer
- type NodeService
- type NodeTaskManager
- type NodesEnv
- type TransactionResponse
Constants ¶
View Source
const ( STATUS_NODE_ENDPOINT = "/status" BLOCKS_NODE_ENDPOINT = "/blocks" )
View Source
const NODES_DOMAIN_URL = "/api/nodes"
Variables ¶
This section is empty.
Functions ¶
func NodesRegister ¶
func NodesRegister(router *gin.RouterGroup, env *NodesEnv)
func RunDomain ¶
func RunDomain( r *gin.Engine, nodeService *NodeService, state models.State, transactionService services.TransactionService, blockService services.BlockService, syncNodeRefreshIntervalInSeconds uint32, createNewBlockIntervalInSeconds uint32, middlewares ...gin.HandlerFunc, ) error
Types ¶
type BlockHeaderResponse ¶
type BlockHeight ¶
type BlockHeight uint64
type BlockResponse ¶
type BlockResponse struct { Header BlockHeaderResponse `json:"header"` Txs []TransactionResponse `json:"transactions"` }
type BlockSerializer ¶
type BlockSerializer struct {
// contains filtered or unexported fields
}
blocks
func (*BlockSerializer) Response ¶
func (n *BlockSerializer) Response() BlockResponse
type BlocksResponse ¶
type BlocksResponse struct {
Blocks []BlockResponse `json:"blocks"`
}
type BlocksSerializer ¶
type BlocksSerializer struct {
// contains filtered or unexported fields
}
func (*BlocksSerializer) Response ¶
func (n *BlocksSerializer) Response() BlocksResponse
type ListBlocksParam ¶
type ListBlocksParam struct {
From string `json:"from" binding:"required,hash"`
}
type NetworkNode ¶
type NetworkNodeAddress ¶
type NetworkNodeAddress struct {
// contains filtered or unexported fields
}
func NewNetworkNodeAddress ¶
func NewNetworkNodeAddress(ip string, port uint64) NetworkNodeAddress
func (NetworkNodeAddress) Ip ¶
func (n NetworkNodeAddress) Ip() string
func (NetworkNodeAddress) Port ¶
func (n NetworkNodeAddress) Port() uint64
func (NetworkNodeAddress) String ¶
func (n NetworkNodeAddress) String() string
type NetworkNodeFromDB ¶
type NetworkNodeFromDB struct {
Nodes map[NetworkNodeName]NetworkNodeRecord
}
type NetworkNodeName ¶
type NetworkNodeName string
type NetworkNodeRecord ¶
type NetworkNodeResponse ¶
type NetworkNodeStatus ¶
type NetworkNodeStatus struct { Hash models.Hash Height uint64 NetworkNodes map[NetworkNodeAddress]NetworkNode }
type NetworkNodesResponse ¶
type NetworkNodesResponse struct { Hash models.Hash `json:"block_hash"` Height uint64 `json:"block_height"` NetworkNodeResponse []NetworkNodeResponse `json:"network_nodes"` }
type NodeGetStatusResponse ¶
type NodeGetStatusResponse struct {
Status NetworkNodesResponse `json:"status"`
}
type NodeSerializer ¶
nodes
func (*NodeSerializer) Response ¶
func (n *NodeSerializer) Response() NetworkNodesResponse
type NodeService ¶
type NodeService struct {
// contains filtered or unexported fields
}
func NewNodeService ¶
func NewNodeService(nodeDatabasePath string) (*NodeService, error)
func (*NodeService) Add ¶
func (u *NodeService) Add(nodes map[NetworkNodeAddress]NetworkNode) error
Add nodes in the database, return error otherwise
func (*NodeService) List ¶
func (u *NodeService) List() (map[NetworkNodeAddress]NetworkNode, error)
List nodes in the network if found, nil otherwise
type NodeTaskManager ¶
type NodeTaskManager struct {
// contains filtered or unexported fields
}
func NewNodeTaskManager ¶
func NewNodeTaskManager( syncNodeRefreshIntervalInSeconds uint32, createNewBlockIntervalInSeconds uint32, nodeService *NodeService, state models.State, transactionService services.TransactionService, blockService services.BlockService, ) (*NodeTaskManager, error)
NewNodeTaskManager handles all the background tasks needed for a node to sync its status as well as mining new blocks
func (*NodeTaskManager) RunMine ¶
func (n *NodeTaskManager) RunMine(ctx context.Context)
RunMine starts mining a new block when a new transaction is being submitted
func (*NodeTaskManager) RunSync ¶
func (n *NodeTaskManager) RunSync(ctx context.Context)
RunSync starts the process of syncing the list of nodes within the network as well as this node's database
type NodesEnv ¶
type NodesEnv struct {
// contains filtered or unexported fields
}
func (NodesEnv) NodeListBlocks ¶
NodeListBlocks Get blocks from a specific hash specified in the payload
func (NodesEnv) NodeStatus ¶
Click to show internal directories.
Click to hide internal directories.