jsonrpc

package
v0.0.0-...-d94a70f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2026 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Overview

Package jsonrpc is the json-rpc2 server of ngcore.

Encoding conventions, identical on every human-facing surface (see docs.ngchain.org/rpc for the method reference):

  • addresses (and keys) are bs58 strings
  • all other raw bytes (hashes, code, calldata, RLP payloads) are lowercase hex, never base64
  • money never touches a float: tx-composition `value`/`fee` params are DECIMAL STRINGS of whole NG ("1.5", parsed exactly); balances return as decimal strings of raw units (NG is 18-decimal)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GetWorkParams

type GetWorkParams struct {
	GenTx string `json:"gen"`
}

GetWorkParams carries the miner's OWN signed generate tx. The post-state StateRoot is folded into the pow preimage and depends on the block's contents including this generate, so getWork must fold it in and seal the root BEFORE returning — the miner can no longer append its generate after the fact and still carry a correct root.

type GetWorkReply

type GetWorkReply struct {
	WorkID uint64 `json:"id"`
	Block  string `json:"block"`
	Txs    string `json:"txs"`
}

GetWorkReply hands the miner a FULLY-ASSEMBLED unsealing block (generate folded in, StateRoot sealed) — it needs only a nonce. Txs is kept as an empty list for wire-compat but is no longer needed to reconstruct.

type Server

type Server struct {
	*ServerConfig
	*jsonrpc2http.Server
	// contains filtered or unexported fields
}

Server is a json-rpc v2 server, reachable over HTTP POST at / and over WebSocket at /ws (the latter additionally serves subscriptions).

func NewServer

func NewServer(pow *consensus.PoWork, config ServerConfig) *Server

NewServer will create a new Server with its methods registered, but not running.

func (*Server) Serve

func (s *Server) Serve()

Serve will make the server running.

type ServerConfig

type ServerConfig struct {
	Host                 string
	Version              string
	Port                 int
	DisableP2PMethods    bool
	DisableMiningMethods bool
}

type SubmitWorkParams

type SubmitWorkParams struct {
	WorkID uint64 `json:"id"`
	Nonce  string `json:"nonce"`
}

SubmitWorkParams carries only the found nonce for a stored work id: the block (with its generate and StateRoot) was fully assembled at getWork time.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址