mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-07 13:55:17 +00:00
tendermint/block -> tendermint/types and tendermint/blockchain
This commit is contained in:
@@ -3,8 +3,8 @@ package rpc
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
blk "github.com/tendermint/tendermint/block"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
func BlockchainInfoHandler(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -20,7 +20,7 @@ func BlockchainInfoHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
log.Debug("BlockchainInfoHandler", "maxHeight", maxHeight, "minHeight", minHeight)
|
||||
|
||||
blockMetas := []*blk.BlockMeta{}
|
||||
blockMetas := []*types.BlockMeta{}
|
||||
for height := maxHeight; height >= minHeight; height-- {
|
||||
blockMeta := blockStore.LoadBlockMeta(height)
|
||||
blockMetas = append(blockMetas, blockMeta)
|
||||
@@ -28,7 +28,7 @@ func BlockchainInfoHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
WriteAPIResponse(w, API_OK, struct {
|
||||
LastHeight uint
|
||||
BlockMetas []*blk.BlockMeta
|
||||
BlockMetas []*types.BlockMeta
|
||||
}{blockStore.Height(), blockMetas})
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ func GetBlockHandler(w http.ResponseWriter, r *http.Request) {
|
||||
block := blockStore.LoadBlock(height)
|
||||
|
||||
WriteAPIResponse(w, API_OK, struct {
|
||||
BlockMeta *blk.BlockMeta
|
||||
Block *blk.Block
|
||||
BlockMeta *types.BlockMeta
|
||||
Block *types.Block
|
||||
}{blockMeta, block})
|
||||
}
|
||||
|
||||
@@ -4,16 +4,16 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/tendermint/tendermint/binary"
|
||||
blk "github.com/tendermint/tendermint/block"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
"github.com/tendermint/tendermint/merkle"
|
||||
"github.com/tendermint/tendermint/state"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
func BroadcastTxHandler(w http.ResponseWriter, r *http.Request) {
|
||||
txJSON := GetParam(r, "tx")
|
||||
var err error
|
||||
var tx blk.Tx
|
||||
var tx types.Tx
|
||||
binary.ReadJSON(&tx, []byte(txJSON), &err)
|
||||
if err != nil {
|
||||
WriteAPIResponse(w, API_INVALID_PARAM, Fmt("Invalid tx: %v", err))
|
||||
@@ -30,7 +30,7 @@ func BroadcastTxHandler(w http.ResponseWriter, r *http.Request) {
|
||||
var createsContract bool
|
||||
var contractAddr []byte
|
||||
|
||||
if callTx, ok := tx.(*blk.CallTx); ok {
|
||||
if callTx, ok := tx.(*types.CallTx); ok {
|
||||
if callTx.Address == nil {
|
||||
createsContract = true
|
||||
contractAddr = state.NewContractAddress(callTx.Input.Address, uint64(callTx.Input.Sequence))
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
blk "github.com/tendermint/tendermint/block"
|
||||
"github.com/tendermint/tendermint/consensus"
|
||||
mempl "github.com/tendermint/tendermint/mempool"
|
||||
"github.com/tendermint/tendermint/p2p"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
var blockStore *blk.BlockStore
|
||||
var blockStore *types.BlockStore
|
||||
var consensusState *consensus.ConsensusState
|
||||
var mempoolReactor *mempl.MempoolReactor
|
||||
var p2pSwitch *p2p.Switch
|
||||
|
||||
func SetRPCBlockStore(bs *blk.BlockStore) {
|
||||
func SetRPCBlockStore(bs *types.BlockStore) {
|
||||
blockStore = bs
|
||||
}
|
||||
|
||||
|
||||
22
rpc/txs.go
22
rpc/txs.go
@@ -5,8 +5,8 @@ import (
|
||||
|
||||
"github.com/tendermint/tendermint/account"
|
||||
"github.com/tendermint/tendermint/binary"
|
||||
blk "github.com/tendermint/tendermint/block"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
func SignTxHandler(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -14,7 +14,7 @@ func SignTxHandler(w http.ResponseWriter, r *http.Request) {
|
||||
privAccountsStr := GetParam(r, "privAccounts")
|
||||
|
||||
var err error
|
||||
var tx blk.Tx
|
||||
var tx types.Tx
|
||||
binary.ReadJSON(&tx, []byte(txStr), &err)
|
||||
if err != nil {
|
||||
WriteAPIResponse(w, API_INVALID_PARAM, Fmt("Invalid tx: %v", err))
|
||||
@@ -33,25 +33,25 @@ func SignTxHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
switch tx.(type) {
|
||||
case *blk.SendTx:
|
||||
sendTx := tx.(*blk.SendTx)
|
||||
case *types.SendTx:
|
||||
sendTx := tx.(*types.SendTx)
|
||||
for i, input := range sendTx.Inputs {
|
||||
input.PubKey = privAccounts[i].PubKey
|
||||
input.Signature = privAccounts[i].Sign(sendTx)
|
||||
}
|
||||
case *blk.BondTx:
|
||||
bondTx := tx.(*blk.BondTx)
|
||||
case *types.BondTx:
|
||||
bondTx := tx.(*types.BondTx)
|
||||
for i, input := range bondTx.Inputs {
|
||||
input.PubKey = privAccounts[i].PubKey
|
||||
input.Signature = privAccounts[i].Sign(bondTx)
|
||||
}
|
||||
case *blk.UnbondTx:
|
||||
unbondTx := tx.(*blk.UnbondTx)
|
||||
case *types.UnbondTx:
|
||||
unbondTx := tx.(*types.UnbondTx)
|
||||
unbondTx.Signature = privAccounts[0].Sign(unbondTx).(account.SignatureEd25519)
|
||||
case *blk.RebondTx:
|
||||
rebondTx := tx.(*blk.RebondTx)
|
||||
case *types.RebondTx:
|
||||
rebondTx := tx.(*types.RebondTx)
|
||||
rebondTx.Signature = privAccounts[0].Sign(rebondTx).(account.SignatureEd25519)
|
||||
}
|
||||
|
||||
WriteAPIResponse(w, API_OK, struct{ blk.Tx }{tx})
|
||||
WriteAPIResponse(w, API_OK, struct{ types.Tx }{tx})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user