|
|
@ -41,22 +41,20 @@ type Local struct { |
|
|
|
*types.EventBus |
|
|
|
Logger log.Logger |
|
|
|
ctx *rpctypes.Context |
|
|
|
env *core.Environment |
|
|
|
} |
|
|
|
|
|
|
|
// NewLocal configures a client that calls the Node directly.
|
|
|
|
//
|
|
|
|
// Note that given how rpc/core works with package singletons, that
|
|
|
|
// you can only have one node per process. So make sure test cases
|
|
|
|
// don't run in parallel, or try to simulate an entire network in
|
|
|
|
// one process...
|
|
|
|
func New(node *nm.Node) *Local { |
|
|
|
if err := node.ConfigureRPC(); err != nil { |
|
|
|
env, err := node.ConfigureRPC() |
|
|
|
if err != nil { |
|
|
|
node.Logger.Error("Error configuring RPC", "err", err) |
|
|
|
} |
|
|
|
return &Local{ |
|
|
|
EventBus: node.EventBus(), |
|
|
|
Logger: log.NewNopLogger(), |
|
|
|
ctx: &rpctypes.Context{}, |
|
|
|
env: env, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -68,11 +66,11 @@ func (c *Local) SetLogger(l log.Logger) { |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) Status(ctx context.Context) (*ctypes.ResultStatus, error) { |
|
|
|
return core.Status(c.ctx) |
|
|
|
return c.env.Status(c.ctx) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) ABCIInfo(ctx context.Context) (*ctypes.ResultABCIInfo, error) { |
|
|
|
return core.ABCIInfo(c.ctx) |
|
|
|
return c.env.ABCIInfo(c.ctx) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) ABCIQuery(ctx context.Context, path string, data bytes.HexBytes) (*ctypes.ResultABCIQuery, error) { |
|
|
@ -84,55 +82,55 @@ func (c *Local) ABCIQueryWithOptions( |
|
|
|
path string, |
|
|
|
data bytes.HexBytes, |
|
|
|
opts rpcclient.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) { |
|
|
|
return core.ABCIQuery(c.ctx, path, data, opts.Height, opts.Prove) |
|
|
|
return c.env.ABCIQuery(c.ctx, path, data, opts.Height, opts.Prove) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) { |
|
|
|
return core.BroadcastTxCommit(c.ctx, tx) |
|
|
|
return c.env.BroadcastTxCommit(c.ctx, tx) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) { |
|
|
|
return core.BroadcastTxAsync(c.ctx, tx) |
|
|
|
return c.env.BroadcastTxAsync(c.ctx, tx) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) BroadcastTxSync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) { |
|
|
|
return core.BroadcastTxSync(c.ctx, tx) |
|
|
|
return c.env.BroadcastTxSync(c.ctx, tx) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) UnconfirmedTxs(ctx context.Context, limit *int) (*ctypes.ResultUnconfirmedTxs, error) { |
|
|
|
return core.UnconfirmedTxs(c.ctx, limit) |
|
|
|
return c.env.UnconfirmedTxs(c.ctx, limit) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) NumUnconfirmedTxs(ctx context.Context) (*ctypes.ResultUnconfirmedTxs, error) { |
|
|
|
return core.NumUnconfirmedTxs(c.ctx) |
|
|
|
return c.env.NumUnconfirmedTxs(c.ctx) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) CheckTx(ctx context.Context, tx types.Tx) (*ctypes.ResultCheckTx, error) { |
|
|
|
return core.CheckTx(c.ctx, tx) |
|
|
|
return c.env.CheckTx(c.ctx, tx) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) NetInfo(ctx context.Context) (*ctypes.ResultNetInfo, error) { |
|
|
|
return core.NetInfo(c.ctx) |
|
|
|
return c.env.NetInfo(c.ctx) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) DumpConsensusState(ctx context.Context) (*ctypes.ResultDumpConsensusState, error) { |
|
|
|
return core.DumpConsensusState(c.ctx) |
|
|
|
return c.env.DumpConsensusState(c.ctx) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) ConsensusState(ctx context.Context) (*ctypes.ResultConsensusState, error) { |
|
|
|
return core.ConsensusState(c.ctx) |
|
|
|
return c.env.GetConsensusState(c.ctx) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) ConsensusParams(ctx context.Context, height *int64) (*ctypes.ResultConsensusParams, error) { |
|
|
|
return core.ConsensusParams(c.ctx, height) |
|
|
|
return c.env.ConsensusParams(c.ctx, height) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) Health(ctx context.Context) (*ctypes.ResultHealth, error) { |
|
|
|
return core.Health(c.ctx) |
|
|
|
return c.env.Health(c.ctx) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) DialSeeds(ctx context.Context, seeds []string) (*ctypes.ResultDialSeeds, error) { |
|
|
|
return core.UnsafeDialSeeds(c.ctx, seeds) |
|
|
|
return c.env.UnsafeDialSeeds(c.ctx, seeds) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) DialPeers( |
|
|
@ -142,39 +140,39 @@ func (c *Local) DialPeers( |
|
|
|
unconditional, |
|
|
|
private bool, |
|
|
|
) (*ctypes.ResultDialPeers, error) { |
|
|
|
return core.UnsafeDialPeers(c.ctx, peers, persistent, unconditional, private) |
|
|
|
return c.env.UnsafeDialPeers(c.ctx, peers, persistent, unconditional, private) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) BlockchainInfo(ctx context.Context, minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error) { |
|
|
|
return core.BlockchainInfo(c.ctx, minHeight, maxHeight) |
|
|
|
return c.env.BlockchainInfo(c.ctx, minHeight, maxHeight) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) Genesis(ctx context.Context) (*ctypes.ResultGenesis, error) { |
|
|
|
return core.Genesis(c.ctx) |
|
|
|
return c.env.Genesis(c.ctx) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) Block(ctx context.Context, height *int64) (*ctypes.ResultBlock, error) { |
|
|
|
return core.Block(c.ctx, height) |
|
|
|
return c.env.Block(c.ctx, height) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) BlockByHash(ctx context.Context, hash []byte) (*ctypes.ResultBlock, error) { |
|
|
|
return core.BlockByHash(c.ctx, hash) |
|
|
|
return c.env.BlockByHash(c.ctx, hash) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) BlockResults(ctx context.Context, height *int64) (*ctypes.ResultBlockResults, error) { |
|
|
|
return core.BlockResults(c.ctx, height) |
|
|
|
return c.env.BlockResults(c.ctx, height) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) Commit(ctx context.Context, height *int64) (*ctypes.ResultCommit, error) { |
|
|
|
return core.Commit(c.ctx, height) |
|
|
|
return c.env.Commit(c.ctx, height) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) Validators(ctx context.Context, height *int64, page, perPage *int) (*ctypes.ResultValidators, error) { |
|
|
|
return core.Validators(c.ctx, height, page, perPage) |
|
|
|
return c.env.Validators(c.ctx, height, page, perPage) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) Tx(ctx context.Context, hash []byte, prove bool) (*ctypes.ResultTx, error) { |
|
|
|
return core.Tx(c.ctx, hash, prove) |
|
|
|
return c.env.Tx(c.ctx, hash, prove) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) TxSearch( |
|
|
@ -185,7 +183,7 @@ func (c *Local) TxSearch( |
|
|
|
perPage *int, |
|
|
|
orderBy string, |
|
|
|
) (*ctypes.ResultTxSearch, error) { |
|
|
|
return core.TxSearch(c.ctx, query, prove, page, perPage, orderBy) |
|
|
|
return c.env.TxSearch(c.ctx, query, prove, page, perPage, orderBy) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) BlockSearch( |
|
|
@ -194,11 +192,11 @@ func (c *Local) BlockSearch( |
|
|
|
page, perPage *int, |
|
|
|
orderBy string, |
|
|
|
) (*ctypes.ResultBlockSearch, error) { |
|
|
|
return core.BlockSearch(c.ctx, query, page, perPage, orderBy) |
|
|
|
return c.env.BlockSearch(c.ctx, query, page, perPage, orderBy) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) BroadcastEvidence(ctx context.Context, ev types.Evidence) (*ctypes.ResultBroadcastEvidence, error) { |
|
|
|
return core.BroadcastEvidence(c.ctx, ev) |
|
|
|
return c.env.BroadcastEvidence(c.ctx, ev) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Local) Subscribe( |
|
|
|