Made all JSON fields lower_case

This commit is contained in:
Jae Kwon
2015-05-01 17:26:49 -07:00
parent 9babda1d7a
commit b92c0401e6
26 changed files with 323 additions and 265 deletions

View File

@ -36,12 +36,12 @@ func HashSignBytes(o Signable) []byte {
// on the blockchain. // on the blockchain.
// Serialized by binary.[read|write]Reflect // Serialized by binary.[read|write]Reflect
type Account struct { type Account struct {
Address []byte Address []byte `json:"address"`
PubKey PubKey PubKey PubKey `json:"pub_key"`
Sequence uint Sequence uint `json:"sequence"`
Balance uint64 Balance uint64 `json:"balance"`
Code []byte // VM code Code []byte `json:"code"` // VM code
StorageRoot []byte // VM storage merkle root. StorageRoot []byte `json:"storage_root"` // VM storage merkle root.
} }
func (acc *Account) Copy() *Account { func (acc *Account) Copy() *Account {

View File

@ -6,9 +6,9 @@ import (
) )
type PrivAccount struct { type PrivAccount struct {
Address []byte Address []byte `json:"address"`
PubKey PubKey PubKey PubKey `json:"pub_key"`
PrivKey PrivKey PrivKey PrivKey `json:"priv_key"`
} }
// Generates a new account with private key. // Generates a new account with private key.

View File

@ -65,64 +65,64 @@ ListenAddr = "0.0.0.0:46657"
` `
var DefaultGenesis = `{ var DefaultGenesis = `{
"Accounts": [ "accounts": [
{ {
"Address": "69988763FCF806AC35D1A2F9C4885B7DD7B0599C", "address": "69988763FCF806AC35D1A2F9C4885B7DD7B0599C",
"Amount": 1049800000000000 "amount": 1049800000000000
}, },
{ {
"Address": "D7DFF9806078899C8DA3FE3633CC0BF3C6C2B1BB", "address": "D7DFF9806078899C8DA3FE3633CC0BF3C6C2B1BB",
"Amount": 1049800000000000 "amount": 1049800000000000
} }
], ],
"Validators": [ "validators": [
{ {
"PubKey": [1, "323A31EB01877858592AB7D593E9447110AFCD3ACF280D60C4F8E7C04FACC955"], "pub_key": [1, "323A31EB01877858592AB7D593E9447110AFCD3ACF280D60C4F8E7C04FACC955"],
"Amount": 100000000000, "amount": 100000000000,
"UnbondTo": [ "unbond_to": [
{ {
"Address": "69988763FCF806AC35D1A2F9C4885B7DD7B0599C", "address": "69988763FCF806AC35D1A2F9C4885B7DD7B0599C",
"Amount": 100000000000 "amount": 100000000000
} }
] ]
}, },
{ {
"PubKey": [1, "2239C21C81EA7173A6C489145490C015E05D4B97448933B708A7EC5B7B4921E3"], "pub_key": [1, "2239C21C81EA7173A6C489145490C015E05D4B97448933B708A7EC5B7B4921E3"],
"Amount": 100000000000, "amount": 100000000000,
"UnbondTo": [ "unbond_to": [
{ {
"Address": "D7DFF9806078899C8DA3FE3633CC0BF3C6C2B1BB", "address": "D7DFF9806078899C8DA3FE3633CC0BF3C6C2B1BB",
"Amount": 100000000000 "amount": 100000000000
} }
] ]
}, },
{ {
"PubKey": [1, "DD2206E8F889EED3ABAAECEB2D18962D062A887346241820493FFE3B1DEF255D"], "pub_key": [1, "DD2206E8F889EED3ABAAECEB2D18962D062A887346241820493FFE3B1DEF255D"],
"Amount": 100000000000, "amount": 100000000000,
"UnbondTo": [ "unbond_to": [
{ {
"Address": "69988763FCF806AC35D1A2F9C4885B7DD7B0599C", "address": "69988763FCF806AC35D1A2F9C4885B7DD7B0599C",
"Amount": 100000000000 "amount": 100000000000
} }
] ]
}, },
{ {
"PubKey": [1, "1B3256A3754FC6AB01110C166199A2F619E2D76DB3EE751E376FE404AC9FDCFF"], "pub_key": [1, "1B3256A3754FC6AB01110C166199A2F619E2D76DB3EE751E376FE404AC9FDCFF"],
"Amount": 100000000000, "amount": 100000000000,
"UnbondTo": [ "unbond_to": [
{ {
"Address": "69988763FCF806AC35D1A2F9C4885B7DD7B0599C", "address": "69988763FCF806AC35D1A2F9C4885B7DD7B0599C",
"Amount": 50000000000 "amount": 50000000000
} }
] ]
}, },
{ {
"PubKey": [1, "62CF1048BAEBB4FFFF360D5E896E3F4EC72D03D55183596931ED14995D512926"], "pub_key": [1, "62CF1048BAEBB4FFFF360D5E896E3F4EC72D03D55183596931ED14995D512926"],
"Amount": 100000000000, "amount": 100000000000,
"UnbondTo": [ "unbond_to": [
{ {
"Address": "69988763FCF806AC35D1A2F9C4885B7DD7B0599C", "address": "69988763FCF806AC35D1A2F9C4885B7DD7B0599C",
"Amount": 50000000000 "amount": 50000000000
} }
] ]
} }

View File

@ -15,18 +15,18 @@ import (
// Commits require an additional round which is strictly less than // Commits require an additional round which is strictly less than
// the POL round. Prevote rounds are equal to the POL round. // the POL round. Prevote rounds are equal to the POL round.
type POLVoteSignature struct { type POLVoteSignature struct {
Round uint Round uint `json:"round"`
Signature account.SignatureEd25519 Signature account.SignatureEd25519 `json:"signature"`
} }
// Proof of lock. // Proof of lock.
// +2/3 of validators' prevotes for a given blockhash (or nil) // +2/3 of validators' prevotes for a given blockhash (or nil)
type POL struct { type POL struct {
Height uint Height uint `json:"height"`
Round uint Round uint `json:"round"`
BlockHash []byte // Could be nil, which makes this a proof of unlock. BlockHash []byte `json:"block_hash"` // Could be nil, which makes this a proof of unlock.
BlockParts types.PartSetHeader // When BlockHash is nil, this is zero. BlockParts types.PartSetHeader `json:"block_parts"` // When BlockHash is nil, this is zero.
Votes []POLVoteSignature // Prevote and commit signatures in ValidatorSet order. Votes []POLVoteSignature `json:"votes"` // Prevote and commit signatures in ValidatorSet order.
} }
// Returns whether +2/3 have prevoted/committed for BlockHash. // Returns whether +2/3 have prevoted/committed for BlockHash.

View File

@ -18,11 +18,11 @@ var (
) )
type Proposal struct { type Proposal struct {
Height uint Height uint `json:"height"`
Round uint Round uint `json:"round"`
BlockParts types.PartSetHeader BlockParts types.PartSetHeader `json:"block_parts"`
POLParts types.PartSetHeader POLParts types.PartSetHeader `json:"pol_parts"`
Signature account.SignatureEd25519 Signature account.SignatureEd25519 `json:"signature"`
} }
func NewProposal(height uint, round uint, blockParts, polParts types.PartSetHeader) *Proposal { func NewProposal(height uint, round uint, blockParts, polParts types.PartSetHeader) *Proposal {
@ -41,10 +41,10 @@ func (p *Proposal) String() string {
func (p *Proposal) WriteSignBytes(w io.Writer, n *int64, err *error) { func (p *Proposal) WriteSignBytes(w io.Writer, n *int64, err *error) {
// We hex encode the network name so we don't deal with escaping issues. // We hex encode the network name so we don't deal with escaping issues.
binary.WriteTo([]byte(Fmt(`{"Network":"%X"`, config.App().GetString("Network"))), w, n, err) binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("Network"))), w, n, err)
binary.WriteTo([]byte(`,"Proprosal":{"BlockParts":`), w, n, err) binary.WriteTo([]byte(`,"proposal":{"block_parts":`), w, n, err)
p.BlockParts.WriteSignBytes(w, n, err) p.BlockParts.WriteSignBytes(w, n, err)
binary.WriteTo([]byte(Fmt(`,"Height":%v,"POLParts":`, p.Height)), w, n, err) binary.WriteTo([]byte(Fmt(`,"height":%v,"pol_parts":`, p.Height)), w, n, err)
p.POLParts.WriteSignBytes(w, n, err) p.POLParts.WriteSignBytes(w, n, err)
binary.WriteTo([]byte(Fmt(`,"Round":%v}}`, p.Round)), w, n, err) binary.WriteTo([]byte(Fmt(`,"round":%v}}`, p.Round)), w, n, err)
} }

View File

@ -19,7 +19,7 @@ func TestProposalSignable(t *testing.T) {
} }
signBytes := account.SignBytes(proposal) signBytes := account.SignBytes(proposal)
signStr := string(signBytes) signStr := string(signBytes)
expected := Fmt(`{"Network":"%X","Proprosal":{"BlockParts":{"Hash":"626C6F636B7061727473","Total":111},"Height":12345,"POLParts":{"Hash":"706F6C7061727473","Total":222},"Round":23456}}`, expected := Fmt(`{"network":"%X","proposal":{"block_parts":{"hash":"626C6F636B7061727473","total":111},"height":12345,"pol_parts":{"hash":"706F6C7061727473","total":222},"round":23456}}`,
config.App().GetString("Network")) config.App().GetString("Network"))
if signStr != expected { if signStr != expected {
t.Errorf("Got unexpected sign string for SendTx. Expected:\n%v\nGot:\n%v", expected, signStr) t.Errorf("Got unexpected sign string for SendTx. Expected:\n%v\nGot:\n%v", expected, signStr)

View File

@ -7,95 +7,95 @@ import (
) )
type ResponseGenPrivAccount struct { type ResponseGenPrivAccount struct {
PrivAccount *account.PrivAccount PrivAccount *account.PrivAccount `json:"priv_account"`
} }
type ResponseGetAccount struct { type ResponseGetAccount struct {
Account *account.Account Account *account.Account `json:"account"`
} }
type ResponseGetStorage struct { type ResponseGetStorage struct {
Key []byte Key []byte `json:"key"`
Value []byte Value []byte `json:"value"`
} }
type ResponseCall struct { type ResponseCall struct {
Return []byte Return []byte `json:"return"`
GasUsed uint64 GasUsed uint64 `json:"gas_used"`
// TODO ... // TODO ...
} }
type ResponseListAccounts struct { type ResponseListAccounts struct {
BlockHeight uint BlockHeight uint `json:"block_height"`
Accounts []*account.Account Accounts []*account.Account `json:"accounts"`
} }
type StorageItem struct { type StorageItem struct {
Key []byte Key []byte `json:"key"`
Value []byte Value []byte `json:"value"`
} }
type ResponseDumpStorage struct { type ResponseDumpStorage struct {
StorageRoot []byte StorageRoot []byte `json:"storage_root"`
StorageItems []StorageItem StorageItems []StorageItem `json:"storage_items"`
} }
type ResponseBlockchainInfo struct { type ResponseBlockchainInfo struct {
LastHeight uint LastHeight uint `json:"last_height"`
BlockMetas []*types.BlockMeta BlockMetas []*types.BlockMeta `json:"block_metas"`
} }
type ResponseGetBlock struct { type ResponseGetBlock struct {
BlockMeta *types.BlockMeta BlockMeta *types.BlockMeta `json:"block_meta"`
Block *types.Block Block *types.Block `json:"block"`
} }
type ResponseBroadcastTx struct { type ResponseBroadcastTx struct {
Receipt Receipt Receipt Receipt `json:"receipt"`
} }
type ResponseListUnconfirmedTxs struct { type ResponseListUnconfirmedTxs struct {
Txs []types.Tx Txs []types.Tx `json:"txs"`
} }
type Receipt struct { type Receipt struct {
TxHash []byte TxHash []byte `json:"tx_hash"`
CreatesContract uint8 CreatesContract uint8 `json:"creates_contract"`
ContractAddr []byte ContractAddr []byte `json:"contract_addr"`
} }
type ResponseStatus struct { type ResponseStatus struct {
GenesisHash []byte GenesisHash []byte `json:"genesis_hash"`
Network string Network string `json:"network"`
LatestBlockHash []byte LatestBlockHash []byte `json:"lastest_block_hash"`
LatestBlockHeight uint LatestBlockHeight uint `json:"lastest_block_height"`
LatestBlockTime int64 // nano LatestBlockTime int64 `json:"latest_bloick_time"` // nano
} }
type ResponseNetInfo struct { type ResponseNetInfo struct {
Moniker string Moniker string `json:"moniker"`
Network string Network string `json:"network"`
Listening bool Listening bool `json:"listening"`
Listeners []string Listeners []string `json:"listeners"`
Peers []Peer Peers []Peer `json:"peers"`
} }
type Peer struct { type Peer struct {
types.NodeInfo types.NodeInfo `json:"net_info"`
IsOutbound bool IsOutbound bool `json:"is_outbound"`
} }
type ResponseSignTx struct { type ResponseSignTx struct {
Tx types.Tx Tx types.Tx `json:"tx"`
} }
type ResponseListValidators struct { type ResponseListValidators struct {
BlockHeight uint BlockHeight uint `json:"block_height"`
BondedValidators []*sm.Validator BondedValidators []*sm.Validator `json:"bonded_validators"`
UnbondingValidators []*sm.Validator UnbondingValidators []*sm.Validator `json:"unbonding_validators"`
} }
type ResponseDumpConsensusState struct { type ResponseDumpConsensusState struct {
RoundState string RoundState string `json:"round_state"`
PeerRoundStates []string PeerRoundStates []string `json:"peer_round_states"`
} }

View File

@ -25,6 +25,7 @@ type Client interface {
GetBlock(height uint) (*ctypes.ResponseGetBlock, error) GetBlock(height uint) (*ctypes.ResponseGetBlock, error)
GetStorage(address []byte, key []byte) (*ctypes.ResponseGetStorage, error) GetStorage(address []byte, key []byte) (*ctypes.ResponseGetStorage, error)
ListAccounts() (*ctypes.ResponseListAccounts, error) ListAccounts() (*ctypes.ResponseListAccounts, error)
ListUnconfirmedTxs() (*ctypes.ResponseListUnconfirmedTxs, error)
ListValidators() (*ctypes.ResponseListValidators, error) ListValidators() (*ctypes.ResponseListValidators, error)
NetInfo() (*ctypes.ResponseNetInfo, error) NetInfo() (*ctypes.ResponseNetInfo, error)
SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (*ctypes.ResponseSignTx, error) SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (*ctypes.ResponseSignTx, error)
@ -361,6 +362,36 @@ func (c *ClientHTTP) ListAccounts() (*ctypes.ResponseListAccounts, error) {
return response.Result, nil return response.Result, nil
} }
func (c *ClientHTTP) ListUnconfirmedTxs() (*ctypes.ResponseListUnconfirmedTxs, error) {
values, err := argsToURLValues(nil)
if err != nil {
return nil, err
}
resp, err := http.PostForm(c.addr+reverseFuncMap["ListUnconfirmedTxs"], values)
if err != nil {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
var response struct {
Result *ctypes.ResponseListUnconfirmedTxs `json:"result"`
Error string `json:"error"`
Id string `json:"id"`
JSONRPC string `json:"jsonrpc"`
}
binary.ReadJSON(&response, body, &err)
if err != nil {
return nil, err
}
if response.Error != "" {
return nil, fmt.Errorf(response.Error)
}
return response.Result, nil
}
func (c *ClientHTTP) ListValidators() (*ctypes.ResponseListValidators, error) { func (c *ClientHTTP) ListValidators() (*ctypes.ResponseListValidators, error) {
values, err := argsToURLValues(nil) values, err := argsToURLValues(nil)
if err != nil { if err != nil {
@ -778,6 +809,33 @@ func (c *ClientJSON) ListAccounts() (*ctypes.ResponseListAccounts, error) {
return response.Result, nil return response.Result, nil
} }
func (c *ClientJSON) ListUnconfirmedTxs() (*ctypes.ResponseListUnconfirmedTxs, error) {
request := rpc.RPCRequest{
JSONRPC: "2.0",
Method: reverseFuncMap["ListUnconfirmedTxs"],
Params: []interface{}{},
Id: 0,
}
body, err := c.RequestResponse(request)
if err != nil {
return nil, err
}
var response struct {
Result *ctypes.ResponseListUnconfirmedTxs `json:"result"`
Error string `json:"error"`
Id string `json:"id"`
JSONRPC string `json:"jsonrpc"`
}
binary.ReadJSON(&response, body, &err)
if err != nil {
return nil, err
}
if response.Error != "" {
return nil, fmt.Errorf(response.Error)
}
return response.Result, nil
}
func (c *ClientJSON) ListValidators() (*ctypes.ResponseListValidators, error) { func (c *ClientJSON) ListValidators() (*ctypes.ResponseListValidators, error) {
request := rpc.RPCRequest{ request := rpc.RPCRequest{
JSONRPC: "2.0", JSONRPC: "2.0",

View File

@ -207,15 +207,15 @@ const (
// for requests coming in // for requests coming in
type WSRequest struct { type WSRequest struct {
Type string // subscribe or unsubscribe Type string `json:"type"` // subscribe or unsubscribe
Event string Event string `json:"event"`
} }
// for responses going out // for responses going out
type WSResponse struct { type WSResponse struct {
Event string Event string `json:"event"`
Data interface{} Data interface{} `json:"data"`
Error string Error string `json:"error"`
} }
// a single websocket connection // a single websocket connection

View File

@ -1,22 +1,22 @@
{ {
"Accounts": [ "accounts": [
{ {
"Address": "d7dff9806078899c8da3fe3633cc0bf3c6c2b1bb", "address": "d7dff9806078899c8da3fe3633cc0bf3c6c2b1bb",
"Amount": 200000000 "amount": 200000000
}, },
{ {
"Address": "AC89A6DDF4C309A89A2C4078CE409A5A7B282270", "address": "AC89A6DDF4C309A89A2C4078CE409A5A7B282270",
"Amount": 200000000 "amount": 200000000
} }
], ],
"Validators": [ "validators": [
{ {
"PubKey": [1, "2239c21c81ea7173a6c489145490c015e05d4b97448933b708a7ec5b7b4921e3"], "pub_key": [1, "2239c21c81ea7173a6c489145490c015e05d4b97448933b708a7ec5b7b4921e3"],
"Amount": 1000000, "amount": 1000000,
"UnbondTo": [ "unbond_to": [
{ {
"Address": "d7dff9806078899c8da3fe3633cc0bf3c6c2b1bb", "address": "d7dff9806078899c8da3fe3633cc0bf3c6c2b1bb",
"Amount": 100000 "amount": 100000
} }
] ]
} }

View File

@ -65,7 +65,7 @@ func waitForEvent(t *testing.T, con *websocket.Conn, eventid string, dieOnTimeou
// if the event id isnt what we're waiting on // if the event id isnt what we're waiting on
// ignore it // ignore it
var response struct { var response struct {
Event string Event string `json:"event"`
} }
if err := json.Unmarshal(p, &response); err != nil { if err := json.Unmarshal(p, &response); err != nil {
ech <- err ech <- err
@ -112,9 +112,9 @@ func waitForEvent(t *testing.T, con *websocket.Conn, eventid string, dieOnTimeou
func unmarshalResponseNewBlock(b []byte) (*types.Block, error) { func unmarshalResponseNewBlock(b []byte) (*types.Block, error) {
// unmarshall and assert somethings // unmarshall and assert somethings
var response struct { var response struct {
Event string Event string `json:"event"`
Data *types.Block Data *types.Block `json:"data"`
Error string Error string `json:"error"`
} }
var err error var err error
binary.ReadJSON(&response, b, &err) binary.ReadJSON(&response, b, &err)
@ -226,7 +226,6 @@ func TestWSCallWait(t *testing.T) {
waitForEvent(t, con, eid1, true, func() { waitForEvent(t, con, eid1, true, func() {
_, receipt := broadcastTx(t, "JSONRPC", userByteAddr, nil, code, userBytePriv, amt, 1000, 1000) _, receipt := broadcastTx(t, "JSONRPC", userByteAddr, nil, code, userBytePriv, amt, 1000, 1000)
contractAddr = receipt.ContractAddr contractAddr = receipt.ContractAddr
}, unmarshalValidateCall(amt, returnCode)) }, unmarshalValidateCall(amt, returnCode))
// susbscribe to the new contract // susbscribe to the new contract

View File

@ -34,9 +34,9 @@ func unmarshalValidateSend(amt uint64, toAddr []byte) func(string, []byte) error
return func(eid string, b []byte) error { return func(eid string, b []byte) error {
// unmarshal and assert correctness // unmarshal and assert correctness
var response struct { var response struct {
Event string Event string `json:"event"`
Data types.SendTx Data types.SendTx `json:"data"`
Error string Error string `json:"error"`
} }
var err error var err error
binary.ReadJSON(&response, b, &err) binary.ReadJSON(&response, b, &err)
@ -67,13 +67,13 @@ func unmarshalValidateCall(amt uint64, returnCode []byte) func(string, []byte) e
return func(eid string, b []byte) error { return func(eid string, b []byte) error {
// unmarshall and assert somethings // unmarshall and assert somethings
var response struct { var response struct {
Event string Event string `json:"event"`
Data struct { Data struct {
Tx types.CallTx Tx types.CallTx `json:"tx"`
Return []byte Return []byte `json:"return"`
Exception string Exception string `json:"exception"`
} } `json:"data"`
Error string Error string `json:"error"`
} }
var err error var err error
binary.ReadJSON(&response, b, &err) binary.ReadJSON(&response, b, &err)
@ -105,9 +105,9 @@ func unmarshalValidateCallCall(origin, returnCode []byte, txid *[]byte) func(str
return func(eid string, b []byte) error { return func(eid string, b []byte) error {
// unmarshall and assert somethings // unmarshall and assert somethings
var response struct { var response struct {
Event string Event string `json:"event"`
Data types.EventMsgCall Data types.EventMsgCall `json:"data"`
Error string Error string `json:"error"`
} }
var err error var err error
binary.ReadJSON(&response, b, &err) binary.ReadJSON(&response, b, &err)

View File

@ -13,20 +13,20 @@ import (
) )
type GenesisAccount struct { type GenesisAccount struct {
Address []byte Address []byte `json:"address"`
Amount uint64 Amount uint64 `json:"amount"`
} }
type GenesisValidator struct { type GenesisValidator struct {
PubKey account.PubKeyEd25519 PubKey account.PubKeyEd25519 `json:"pub_key"`
Amount uint64 Amount uint64 `json:"amount"`
UnbondTo []GenesisAccount UnbondTo []GenesisAccount `json:"unbond_to"`
} }
type GenesisDoc struct { type GenesisDoc struct {
GenesisTime time.Time GenesisTime time.Time `json:"genesis_time"`
Accounts []GenesisAccount Accounts []GenesisAccount `json:"accounts"`
Validators []GenesisValidator Validators []GenesisValidator `json:"validators"`
} }
func GenesisDocFromJSON(jsonBlob []byte) (genState *GenesisDoc) { func GenesisDocFromJSON(jsonBlob []byte) (genState *GenesisDoc) {

View File

@ -41,12 +41,12 @@ func voteToStep(vote *types.Vote) uint8 {
} }
type PrivValidator struct { type PrivValidator struct {
Address []byte Address []byte `json:"address"`
PubKey account.PubKeyEd25519 PubKey account.PubKeyEd25519 `json:"pub_key"`
PrivKey account.PrivKeyEd25519 PrivKey account.PrivKeyEd25519 `json:"priv_key"`
LastHeight uint LastHeight uint `json:"last_height"`
LastRound uint LastRound uint `json:"last_round"`
LastStep uint8 LastStep uint8 `json:"last_step"`
// For persistence. // For persistence.
// Overloaded for testing. // Overloaded for testing.

View File

@ -12,18 +12,14 @@ import (
// Persistent (mostly) static data for each Validator // Persistent (mostly) static data for each Validator
type ValidatorInfo struct { type ValidatorInfo struct {
Address []byte Address []byte `json:"address"`
PubKey account.PubKeyEd25519 PubKey account.PubKeyEd25519 `json:"pub_key"`
UnbondTo []*types.TxOutput UnbondTo []*types.TxOutput `json:"unbond_to"`
FirstBondHeight uint FirstBondHeight uint `json:"first_bond_height"`
FirstBondAmount uint64 FirstBondAmount uint64 `json:"first_bond_amount"`
DestroyedHeight uint `json:"destroyed_height"` // If destroyed
// If destroyed: DestroyedAmount uint64 `json:"destroyed_amount"` // If destroyed
DestroyedHeight uint ReleasedHeight uint `json:"released_height"` // If released
DestroyedAmount uint64
// If released:
ReleasedHeight uint
} }
func (valInfo *ValidatorInfo) Copy() *ValidatorInfo { func (valInfo *ValidatorInfo) Copy() *ValidatorInfo {
@ -50,13 +46,13 @@ var ValidatorInfoCodec = binary.Codec{
// Also persisted with the state, but fields change // Also persisted with the state, but fields change
// every height|round so they don't go in merkle.Tree // every height|round so they don't go in merkle.Tree
type Validator struct { type Validator struct {
Address []byte Address []byte `json:"address"`
PubKey account.PubKeyEd25519 PubKey account.PubKeyEd25519 `json:"pub_key"`
BondHeight uint BondHeight uint `json:"bond_height"`
UnbondHeight uint UnbondHeight uint `json:"unbond_height"`
LastCommitHeight uint LastCommitHeight uint `json:"last_commit_height"`
VotingPower uint64 VotingPower uint64 `json:"voting_power"`
Accum int64 Accum int64 `json:"accum"`
} }
// Creates a new copy of the validator so we can mutate accum. // Creates a new copy of the validator so we can mutate accum.

View File

@ -16,9 +16,9 @@ import (
) )
type Block struct { type Block struct {
*Header *Header `json:"header"`
*Validation *Validation `json:"validation"`
*Data *Data `json:"data"`
} }
// Basic validation that doesn't involve state data. // Basic validation that doesn't involve state data.
@ -123,14 +123,14 @@ func (b *Block) StringShort() string {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
type Header struct { type Header struct {
Network string Network string `json:"network"`
Height uint Height uint `json:"height"`
Time time.Time Time time.Time `json:"time"`
Fees uint64 Fees uint64 `json:"fees"`
NumTxs uint NumTxs uint `json:"num_txs"`
LastBlockHash []byte LastBlockHash []byte `json:"last_block_hash"`
LastBlockParts PartSetHeader LastBlockParts PartSetHeader `json:"last_block_parts"`
StateHash []byte StateHash []byte `json:"state_hash"`
} }
// NOTE: hash is nil if required fields are missing. // NOTE: hash is nil if required fields are missing.
@ -178,9 +178,9 @@ func (h *Header) StringIndented(indent string) string {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
type Commit struct { type Commit struct {
Address []byte Address []byte `json:"address"`
Round uint Round uint `json:"round"`
Signature account.SignatureEd25519 Signature account.SignatureEd25519 `json:"signature"`
} }
func (commit Commit) IsZero() bool { func (commit Commit) IsZero() bool {
@ -197,7 +197,7 @@ func (commit Commit) String() string {
// Any peer with a block can gossip commits by index with a peer without recalculating the // Any peer with a block can gossip commits by index with a peer without recalculating the
// active ValidatorSet. // active ValidatorSet.
type Validation struct { type Validation struct {
Commits []Commit // Commits (or nil) of all active validators in address order. Commits []Commit `json:"commits"` // Commits (or nil) of all active validators in address order.
// Volatile // Volatile
hash []byte hash []byte
@ -267,7 +267,7 @@ func (v *Validation) BitArray() BitArray {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
type Data struct { type Data struct {
Txs []Tx Txs []Tx `json:"txs"`
// Volatile // Volatile
hash []byte hash []byte

View File

@ -1,9 +1,9 @@
package types package types
type BlockMeta struct { type BlockMeta struct {
Hash []byte // The block hash Hash []byte `json:"hash"` // The block hash
Header *Header // The block's Header Header *Header `json:"header"` // The block's Header
Parts PartSetHeader // The PartSetHeader, for transfer Parts PartSetHeader `json:"parts"` // The PartSetHeader, for transfer
} }
func NewBlockMeta(block *Block, blockParts *PartSet) *BlockMeta { func NewBlockMeta(block *Block, blockParts *PartSet) *BlockMeta {

View File

@ -7,15 +7,15 @@ import (
// Functions to generate eventId strings // Functions to generate eventId strings
func EventStringAccInput(addr []byte) string { func EventStringAccInput(addr []byte) string {
return fmt.Sprintf("Acc/%x/Input", addr) return fmt.Sprintf("Acc/%X/Input", addr)
} }
func EventStringAccOutput(addr []byte) string { func EventStringAccOutput(addr []byte) string {
return fmt.Sprintf("Acc/%x/Output", addr) return fmt.Sprintf("Acc/%X/Output", addr)
} }
func EventStringAccReceive(addr []byte) string { func EventStringAccReceive(addr []byte) string {
return fmt.Sprintf("Acc/%x/Receive", addr) return fmt.Sprintf("Acc/%X/Receive", addr)
} }
func EventStringBond() string { func EventStringBond() string {
@ -46,25 +46,25 @@ func EventStringFork() string {
// but some (an input to a call tx or a receive) are more exotic: // but some (an input to a call tx or a receive) are more exotic:
type EventMsgCallTx struct { type EventMsgCallTx struct {
Tx Tx Tx Tx `json:"tx"`
Return []byte Return []byte `json:"return"`
Exception string Exception string `json:"exception"`
} }
type CallData struct { type CallData struct {
Caller []byte Caller []byte `json:"caller"`
Callee []byte Callee []byte `json:"callee"`
Data []byte Data []byte `json:"data"`
Value uint64 Value uint64 `json:"value"`
Gas uint64 Gas uint64 `json:"gas"`
} }
type EventMsgCall struct { type EventMsgCall struct {
CallData *CallData CallData *CallData `json:"call_data"`
Origin []byte Origin []byte `json:"origin"`
TxId []byte TxId []byte `json:"tx_id"`
Return []byte Return []byte `json:"return"`
Exception string Exception string `json:"exception"`
} }
/* /*

View File

@ -6,13 +6,13 @@ import (
) )
type NodeInfo struct { type NodeInfo struct {
Moniker string Moniker string `json:"moniker"`
Network string Network string `json:"network"`
Version string Version string `json:"version"`
Host string Host string `json:"host"`
P2PPort uint16 P2PPort uint16 `json:"p2p_port"`
RPCPort uint16 RPCPort uint16 `json:"rpc_port"`
} }
func (ni *NodeInfo) CompatibleWith(no *NodeInfo) error { func (ni *NodeInfo) CompatibleWith(no *NodeInfo) error {

View File

@ -24,9 +24,9 @@ var (
) )
type Part struct { type Part struct {
Index uint Index uint `json:"index"`
Trail [][]byte Trail [][]byte `json:"trail"`
Bytes []byte Bytes []byte `json:"bytes"`
// Cache // Cache
hash []byte hash []byte
@ -69,8 +69,8 @@ func (part *Part) StringIndented(indent string) string {
//------------------------------------- //-------------------------------------
type PartSetHeader struct { type PartSetHeader struct {
Total uint Total uint `json:"total"`
Hash []byte Hash []byte `json:"hash"`
} }
func (psh PartSetHeader) String() string { func (psh PartSetHeader) String() string {
@ -86,7 +86,7 @@ func (psh PartSetHeader) Equals(other PartSetHeader) bool {
} }
func (psh PartSetHeader) WriteSignBytes(w io.Writer, n *int64, err *error) { func (psh PartSetHeader) WriteSignBytes(w io.Writer, n *int64, err *error) {
binary.WriteTo([]byte(Fmt(`{"Hash":"%X","Total":%v}`, psh.Hash, psh.Total)), w, n, err) binary.WriteTo([]byte(Fmt(`{"hash":"%X","total":%v}`, psh.Hash, psh.Total)), w, n, err)
} }
//------------------------------------- //-------------------------------------

View File

@ -73,11 +73,11 @@ var _ = binary.RegisterInterface(
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
type TxInput struct { type TxInput struct {
Address []byte // Hash of the PubKey Address []byte `json:"address"` // Hash of the PubKey
Amount uint64 // Must not exceed account balance Amount uint64 `json:"amount"` // Must not exceed account balance
Sequence uint // Must be 1 greater than the last committed TxInput Sequence uint `json:"sequence"` // Must be 1 greater than the last committed TxInput
Signature account.Signature // Depends on the PubKey type and the whole Tx Signature account.Signature `json:"signature"` // Depends on the PubKey type and the whole Tx
PubKey account.PubKey // Must not be nil, may be nil PubKey account.PubKey `json:"pub_key"` // Must not be nil, may be nil
} }
func (txIn *TxInput) ValidateBasic() error { func (txIn *TxInput) ValidateBasic() error {
@ -91,7 +91,7 @@ func (txIn *TxInput) ValidateBasic() error {
} }
func (txIn *TxInput) WriteSignBytes(w io.Writer, n *int64, err *error) { func (txIn *TxInput) WriteSignBytes(w io.Writer, n *int64, err *error) {
binary.WriteTo([]byte(Fmt(`{"Address":"%X","Amount":%v,"Sequence":%v}`, txIn.Address, txIn.Amount, txIn.Sequence)), w, n, err) binary.WriteTo([]byte(Fmt(`{"address":"%X","amount":%v,"sequence":%v}`, txIn.Address, txIn.Amount, txIn.Sequence)), w, n, err)
} }
func (txIn *TxInput) String() string { func (txIn *TxInput) String() string {
@ -101,8 +101,8 @@ func (txIn *TxInput) String() string {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
type TxOutput struct { type TxOutput struct {
Address []byte // Hash of the PubKey Address []byte `json:"address"` // Hash of the PubKey
Amount uint64 // The sum of all outputs must not exceed the inputs. Amount uint64 `json:"amount"` // The sum of all outputs must not exceed the inputs.
} }
func (txOut *TxOutput) ValidateBasic() error { func (txOut *TxOutput) ValidateBasic() error {
@ -116,7 +116,7 @@ func (txOut *TxOutput) ValidateBasic() error {
} }
func (txOut *TxOutput) WriteSignBytes(w io.Writer, n *int64, err *error) { func (txOut *TxOutput) WriteSignBytes(w io.Writer, n *int64, err *error) {
binary.WriteTo([]byte(Fmt(`{"Address":"%X","Amount":%v}`, txOut.Address, txOut.Amount)), w, n, err) binary.WriteTo([]byte(Fmt(`{"address":"%X","amount":%v}`, txOut.Address, txOut.Amount)), w, n, err)
} }
func (txOut *TxOutput) String() string { func (txOut *TxOutput) String() string {
@ -126,21 +126,21 @@ func (txOut *TxOutput) String() string {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
type SendTx struct { type SendTx struct {
Inputs []*TxInput Inputs []*TxInput `json:"inputs"`
Outputs []*TxOutput Outputs []*TxOutput `json:"outputs"`
} }
func (tx *SendTx) WriteSignBytes(w io.Writer, n *int64, err *error) { func (tx *SendTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
// We hex encode the network name so we don't deal with escaping issues. // We hex encode the network name so we don't deal with escaping issues.
binary.WriteTo([]byte(Fmt(`{"Network":"%X"`, config.App().GetString("Network"))), w, n, err) binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("Network"))), w, n, err)
binary.WriteTo([]byte(Fmt(`,"Tx":[%v,{"Inputs":[`, TxTypeSend)), w, n, err) binary.WriteTo([]byte(Fmt(`,"tx":[%v,{"inputs":[`, TxTypeSend)), w, n, err)
for i, in := range tx.Inputs { for i, in := range tx.Inputs {
in.WriteSignBytes(w, n, err) in.WriteSignBytes(w, n, err)
if i != len(tx.Inputs)-1 { if i != len(tx.Inputs)-1 {
binary.WriteTo([]byte(","), w, n, err) binary.WriteTo([]byte(","), w, n, err)
} }
} }
binary.WriteTo([]byte(`],"Outputs":[`), w, n, err) binary.WriteTo([]byte(`],"outputs":[`), w, n, err)
for i, out := range tx.Outputs { for i, out := range tx.Outputs {
out.WriteSignBytes(w, n, err) out.WriteSignBytes(w, n, err)
if i != len(tx.Outputs)-1 { if i != len(tx.Outputs)-1 {
@ -157,18 +157,18 @@ func (tx *SendTx) String() string {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
type CallTx struct { type CallTx struct {
Input *TxInput Input *TxInput `json:"input"`
Address []byte Address []byte `json:"address"`
GasLimit uint64 GasLimit uint64 `json:"gas_limit"`
Fee uint64 Fee uint64 `json:"fee"`
Data []byte Data []byte `json:"data"`
} }
func (tx *CallTx) WriteSignBytes(w io.Writer, n *int64, err *error) { func (tx *CallTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
// We hex encode the network name so we don't deal with escaping issues. // We hex encode the network name so we don't deal with escaping issues.
binary.WriteTo([]byte(Fmt(`{"Network":"%X"`, config.App().GetString("Network"))), w, n, err) binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("Network"))), w, n, err)
binary.WriteTo([]byte(Fmt(`,"Tx":[%v,{"Address":"%X","Data":"%X"`, TxTypeCall, tx.Address, tx.Data)), w, n, err) binary.WriteTo([]byte(Fmt(`,"tx":[%v,{"address":"%X","data":"%X"`, TxTypeCall, tx.Address, tx.Data)), w, n, err)
binary.WriteTo([]byte(Fmt(`,"Fee":%v,"GasLimit":%v,"Input":`, tx.Fee, tx.GasLimit)), w, n, err) binary.WriteTo([]byte(Fmt(`,"fee":%v,"gas_limit":%v,"input":`, tx.Fee, tx.GasLimit)), w, n, err)
tx.Input.WriteSignBytes(w, n, err) tx.Input.WriteSignBytes(w, n, err)
binary.WriteTo([]byte(`}]}`), w, n, err) binary.WriteTo([]byte(`}]}`), w, n, err)
} }
@ -180,24 +180,24 @@ func (tx *CallTx) String() string {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
type BondTx struct { type BondTx struct {
PubKey account.PubKeyEd25519 PubKey account.PubKeyEd25519 `json:"pub_key"`
Inputs []*TxInput Inputs []*TxInput `json:"inputs"`
UnbondTo []*TxOutput UnbondTo []*TxOutput `json:"unbond_to"`
} }
func (tx *BondTx) WriteSignBytes(w io.Writer, n *int64, err *error) { func (tx *BondTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
// We hex encode the network name so we don't deal with escaping issues. // We hex encode the network name so we don't deal with escaping issues.
binary.WriteTo([]byte(Fmt(`{"Network":"%X"`, config.App().GetString("Network"))), w, n, err) binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("Network"))), w, n, err)
binary.WriteTo([]byte(Fmt(`,"Tx":[%v,{"Inputs":[`, TxTypeBond)), w, n, err) binary.WriteTo([]byte(Fmt(`,"tx":[%v,{"inputs":[`, TxTypeBond)), w, n, err)
for i, in := range tx.Inputs { for i, in := range tx.Inputs {
in.WriteSignBytes(w, n, err) in.WriteSignBytes(w, n, err)
if i != len(tx.Inputs)-1 { if i != len(tx.Inputs)-1 {
binary.WriteTo([]byte(","), w, n, err) binary.WriteTo([]byte(","), w, n, err)
} }
} }
binary.WriteTo([]byte(Fmt(`],"PubKey":`)), w, n, err) binary.WriteTo([]byte(Fmt(`],"pub_key":`)), w, n, err)
binary.WriteTo(binary.JSONBytes(tx.PubKey), w, n, err) binary.WriteTo(binary.JSONBytes(tx.PubKey), w, n, err)
binary.WriteTo([]byte(`,"UnbondTo":[`), w, n, err) binary.WriteTo([]byte(`,"unbond_to":[`), w, n, err)
for i, out := range tx.UnbondTo { for i, out := range tx.UnbondTo {
out.WriteSignBytes(w, n, err) out.WriteSignBytes(w, n, err)
if i != len(tx.UnbondTo)-1 { if i != len(tx.UnbondTo)-1 {
@ -214,15 +214,15 @@ func (tx *BondTx) String() string {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
type UnbondTx struct { type UnbondTx struct {
Address []byte Address []byte `json:"address"`
Height uint Height uint `json:"height"`
Signature account.SignatureEd25519 Signature account.SignatureEd25519 `json:"signature"`
} }
func (tx *UnbondTx) WriteSignBytes(w io.Writer, n *int64, err *error) { func (tx *UnbondTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
// We hex encode the network name so we don't deal with escaping issues. // We hex encode the network name so we don't deal with escaping issues.
binary.WriteTo([]byte(Fmt(`{"Network":"%X"`, config.App().GetString("Network"))), w, n, err) binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("Network"))), w, n, err)
binary.WriteTo([]byte(Fmt(`,"Tx":[%v,{"Address":"%X","Height":%v}]}`, TxTypeUnbond, tx.Address, tx.Height)), w, n, err) binary.WriteTo([]byte(Fmt(`,"tx":[%v,{"address":"%X","height":%v}]}`, TxTypeUnbond, tx.Address, tx.Height)), w, n, err)
} }
func (tx *UnbondTx) String() string { func (tx *UnbondTx) String() string {
@ -232,15 +232,15 @@ func (tx *UnbondTx) String() string {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
type RebondTx struct { type RebondTx struct {
Address []byte Address []byte `json:"address"`
Height uint Height uint `json:"height"`
Signature account.SignatureEd25519 Signature account.SignatureEd25519 `json:"signature"`
} }
func (tx *RebondTx) WriteSignBytes(w io.Writer, n *int64, err *error) { func (tx *RebondTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
// We hex encode the network name so we don't deal with escaping issues. // We hex encode the network name so we don't deal with escaping issues.
binary.WriteTo([]byte(Fmt(`{"Network":"%X"`, config.App().GetString("Network"))), w, n, err) binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("Network"))), w, n, err)
binary.WriteTo([]byte(Fmt(`,"Tx":[%v,{"Address":"%X","Height":%v}]}`, TxTypeRebond, tx.Address, tx.Height)), w, n, err) binary.WriteTo([]byte(Fmt(`,"tx":[%v,{"address":"%X","height":%v}]}`, TxTypeRebond, tx.Address, tx.Height)), w, n, err)
} }
func (tx *RebondTx) String() string { func (tx *RebondTx) String() string {
@ -250,9 +250,9 @@ func (tx *RebondTx) String() string {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
type DupeoutTx struct { type DupeoutTx struct {
Address []byte Address []byte `json:"address"`
VoteA Vote VoteA Vote `json:"vote_a"`
VoteB Vote VoteB Vote `json:"vote_b"`
} }
func (tx *DupeoutTx) WriteSignBytes(w io.Writer, n *int64, err *error) { func (tx *DupeoutTx) WriteSignBytes(w io.Writer, n *int64, err *error) {

View File

@ -35,7 +35,7 @@ func TestSendTxSignable(t *testing.T) {
} }
signBytes := account.SignBytes(sendTx) signBytes := account.SignBytes(sendTx)
signStr := string(signBytes) signStr := string(signBytes)
expected := Fmt(`{"Network":"%X","Tx":[1,{"Inputs":[{"Address":"696E70757431","Amount":12345,"Sequence":67890},{"Address":"696E70757432","Amount":111,"Sequence":222}],"Outputs":[{"Address":"6F757470757431","Amount":333},{"Address":"6F757470757432","Amount":444}]}]}`, expected := Fmt(`{"network":"%X","tx":[1,{"inputs":[{"address":"696E70757431","amount":12345,"sequence":67890},{"address":"696E70757432","amount":111,"sequence":222}],"outputs":[{"address":"6F757470757431","amount":333},{"address":"6F757470757432","amount":444}]}]}`,
config.App().GetString("Network")) config.App().GetString("Network"))
if signStr != expected { if signStr != expected {
t.Errorf("Got unexpected sign string for SendTx. Expected:\n%v\nGot:\n%v", expected, signStr) t.Errorf("Got unexpected sign string for SendTx. Expected:\n%v\nGot:\n%v", expected, signStr)
@ -56,7 +56,7 @@ func TestCallTxSignable(t *testing.T) {
} }
signBytes := account.SignBytes(callTx) signBytes := account.SignBytes(callTx)
signStr := string(signBytes) signStr := string(signBytes)
expected := Fmt(`{"Network":"%X","Tx":[2,{"Address":"636F6E747261637431","Data":"6461746131","Fee":222,"GasLimit":111,"Input":{"Address":"696E70757431","Amount":12345,"Sequence":67890}}]}`, expected := Fmt(`{"network":"%X","tx":[2,{"address":"636F6E747261637431","data":"6461746131","fee":222,"gas_limit":111,"input":{"address":"696E70757431","amount":12345,"sequence":67890}}]}`,
config.App().GetString("Network")) config.App().GetString("Network"))
if signStr != expected { if signStr != expected {
t.Errorf("Got unexpected sign string for CallTx. Expected:\n%v\nGot:\n%v", expected, signStr) t.Errorf("Got unexpected sign string for CallTx. Expected:\n%v\nGot:\n%v", expected, signStr)
@ -92,7 +92,7 @@ func TestBondTxSignable(t *testing.T) {
} }
signBytes := account.SignBytes(bondTx) signBytes := account.SignBytes(bondTx)
signStr := string(signBytes) signStr := string(signBytes)
expected := Fmt(`{"Network":"%X","Tx":[17,{"Inputs":[{"Address":"696E70757431","Amount":12345,"Sequence":67890},{"Address":"696E70757432","Amount":111,"Sequence":222}],"PubKey":[1,"3B6A27BCCEB6A42D62A3A8D02A6F0D73653215771DE243A63AC048A18B59DA29"],"UnbondTo":[{"Address":"6F757470757431","Amount":333},{"Address":"6F757470757432","Amount":444}]}]}`, expected := Fmt(`{"network":"%X","tx":[17,{"inputs":[{"address":"696E70757431","amount":12345,"sequence":67890},{"address":"696E70757432","amount":111,"sequence":222}],"pub_key":[1,"3B6A27BCCEB6A42D62A3A8D02A6F0D73653215771DE243A63AC048A18B59DA29"],"unbond_to":[{"address":"6F757470757431","amount":333},{"address":"6F757470757432","amount":444}]}]}`,
config.App().GetString("Network")) config.App().GetString("Network"))
if signStr != expected { if signStr != expected {
t.Errorf("Got unexpected sign string for BondTx") t.Errorf("Got unexpected sign string for BondTx")
@ -106,7 +106,7 @@ func TestUnbondTxSignable(t *testing.T) {
} }
signBytes := account.SignBytes(unbondTx) signBytes := account.SignBytes(unbondTx)
signStr := string(signBytes) signStr := string(signBytes)
expected := Fmt(`{"Network":"%X","Tx":[18,{"Address":"6164647265737331","Height":111}]}`, expected := Fmt(`{"network":"%X","tx":[18,{"address":"6164647265737331","height":111}]}`,
config.App().GetString("Network")) config.App().GetString("Network"))
if signStr != expected { if signStr != expected {
t.Errorf("Got unexpected sign string for UnbondTx") t.Errorf("Got unexpected sign string for UnbondTx")
@ -120,7 +120,7 @@ func TestRebondTxSignable(t *testing.T) {
} }
signBytes := account.SignBytes(rebondTx) signBytes := account.SignBytes(rebondTx)
signStr := string(signBytes) signStr := string(signBytes)
expected := Fmt(`{"Network":"%X","Tx":[19,{"Address":"6164647265737331","Height":111}]}`, expected := Fmt(`{"network":"%X","tx":[19,{"address":"6164647265737331","height":111}]}`,
config.App().GetString("Network")) config.App().GetString("Network"))
if signStr != expected { if signStr != expected {
t.Errorf("Got unexpected sign string for RebondTx") t.Errorf("Got unexpected sign string for RebondTx")

View File

@ -31,12 +31,12 @@ func (err *ErrVoteConflictingSignature) Error() string {
// Commit votes get aggregated into the next block's Validaiton. // Commit votes get aggregated into the next block's Validaiton.
// See the whitepaper for details. // See the whitepaper for details.
type Vote struct { type Vote struct {
Height uint Height uint `json:"height"`
Round uint Round uint `json:"round"`
Type byte Type byte `json:"type"`
BlockHash []byte // empty if vote is nil. BlockHash []byte `json:"block_hash"` // empty if vote is nil.
BlockParts PartSetHeader // zero if vote is nil. BlockParts PartSetHeader `json:"block_parts"` // zero if vote is nil.
Signature account.SignatureEd25519 Signature account.SignatureEd25519 `json:"signature"`
} }
// Types of votes // Types of votes
@ -48,9 +48,9 @@ const (
func (vote *Vote) WriteSignBytes(w io.Writer, n *int64, err *error) { func (vote *Vote) WriteSignBytes(w io.Writer, n *int64, err *error) {
// We hex encode the network name so we don't deal with escaping issues. // We hex encode the network name so we don't deal with escaping issues.
binary.WriteTo([]byte(Fmt(`{"Network":"%X"`, config.App().GetString("Network"))), w, n, err) binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("Network"))), w, n, err)
binary.WriteTo([]byte(Fmt(`,"Vote":{"BlockHash":"%X","BlockParts":%v`, vote.BlockHash, vote.BlockParts)), w, n, err) binary.WriteTo([]byte(Fmt(`,"vote":{"block_hash":"%X","block_parts":%v`, vote.BlockHash, vote.BlockParts)), w, n, err)
binary.WriteTo([]byte(Fmt(`,"Height":%v,"Round":%v,"Type":%v}}`, vote.Height, vote.Round, vote.Type)), w, n, err) binary.WriteTo([]byte(Fmt(`,"height":%v,"round":%v,"type":%v}}`, vote.Height, vote.Round, vote.Type)), w, n, err)
} }
func (vote *Vote) Copy() *Vote { func (vote *Vote) Copy() *Vote {

View File

@ -17,6 +17,11 @@ type Account struct {
Other interface{} // For holding all other data. Other interface{} // For holding all other data.
} }
func (acc *Account) String() string {
return Fmt("VMAccount{%X B:%v C:%X N:%v S:%X}",
acc.Address, acc.Balance, acc.Code, acc.Nonce, acc.StorageRoot)
}
type Log struct { type Log struct {
Address Word256 Address Word256
Topics []Word256 Topics []Word256