Пример #1
0
const (
	PermArgsTypeHasBase   = byte(0x01)
	PermArgsTypeSetBase   = byte(0x02)
	PermArgsTypeUnsetBase = byte(0x03)
	PermArgsTypeSetGlobal = byte(0x04)
	PermArgsTypeHasRole   = byte(0x05)
	PermArgsTypeAddRole   = byte(0x06)
	PermArgsTypeRmRole    = byte(0x07)
)

// for wire.readReflect
var _ = wire.RegisterInterface(
	struct{ PermArgs }{},
	wire.ConcreteType{&HasBaseArgs{}, PermArgsTypeHasBase},
	wire.ConcreteType{&SetBaseArgs{}, PermArgsTypeSetBase},
	wire.ConcreteType{&UnsetBaseArgs{}, PermArgsTypeUnsetBase},
	wire.ConcreteType{&SetGlobalArgs{}, PermArgsTypeSetGlobal},
	wire.ConcreteType{&HasRoleArgs{}, PermArgsTypeHasRole},
	wire.ConcreteType{&AddRoleArgs{}, PermArgsTypeAddRole},
	wire.ConcreteType{&RmRoleArgs{}, PermArgsTypeRmRole},
)

type HasBaseArgs struct {
	Address    []byte   `json:"address"`
	Permission PermFlag `json:"permission"`
}

func (*HasBaseArgs) PermFlag() PermFlag {
	return HasBase
}

type SetBaseArgs struct {
Пример #2
0
	. "github.com/eris-ltd/toadserver/Godeps/_workspace/src/github.com/tendermint/tendermint/common"
	"github.com/eris-ltd/toadserver/Godeps/_workspace/src/github.com/tendermint/tendermint/wire"
)

// Signature is a part of Txs and consensus Votes.
type Signature interface {
	IsZero() bool
	String() string
}

// Types of Signature implementations
const (
	SignatureTypeEd25519 = byte(0x01)
)

// for wire.readReflect
var _ = wire.RegisterInterface(
	struct{ Signature }{},
	wire.ConcreteType{SignatureEd25519{}, SignatureTypeEd25519},
)

//-------------------------------------

// Implements Signature
type SignatureEd25519 [64]byte

func (sig SignatureEd25519) IsZero() bool { return len(sig) == 0 }

func (sig SignatureEd25519) String() string { return fmt.Sprintf("/%X.../", Fingerprint(sig[:])) }
Пример #3
0
	ResultTypeGenesis            = byte(0x11)
	ResultTypeSignTx             = byte(0x12)
	ResultTypeEvent              = byte(0x13) // so websockets can respond to rpc functions
)

type Result interface{}

// for wire.readReflect
var _ = wire.RegisterInterface(
	struct{ Result }{},
	wire.ConcreteType{&ResultGetStorage{}, ResultTypeGetStorage},
	wire.ConcreteType{&ResultCall{}, ResultTypeCall},
	wire.ConcreteType{&ResultListAccounts{}, ResultTypeListAccounts},
	wire.ConcreteType{&ResultDumpStorage{}, ResultTypeDumpStorage},
	wire.ConcreteType{&ResultBlockchainInfo{}, ResultTypeBlockchainInfo},
	wire.ConcreteType{&ResultGetBlock{}, ResultTypeGetBlock},
	wire.ConcreteType{&ResultStatus{}, ResultTypeStatus},
	wire.ConcreteType{&ResultNetInfo{}, ResultTypeNetInfo},
	wire.ConcreteType{&ResultListValidators{}, ResultTypeListValidators},
	wire.ConcreteType{&ResultDumpConsensusState{}, ResultTypeDumpConsensusState},
	wire.ConcreteType{&ResultListNames{}, ResultTypeListNames},
	wire.ConcreteType{&ResultGenPrivAccount{}, ResultTypeGenPrivAccount},
	wire.ConcreteType{&ResultGetAccount{}, ResultTypeGetAccount},
	wire.ConcreteType{&ResultBroadcastTx{}, ResultTypeBroadcastTx},
	wire.ConcreteType{&ResultListUnconfirmedTxs{}, ResultTypeListUnconfirmedTxs},
	wire.ConcreteType{&ResultGetName{}, ResultTypeGetName},
	wire.ConcreteType{&ResultGenesis{}, ResultTypeGenesis},
	wire.ConcreteType{&ResultSignTx{}, ResultTypeSignTx},
	wire.ConcreteType{&ResultEvent{}, ResultTypeEvent},
)
Пример #4
0
const (
	EventDataTypeNewBlock = byte(0x01)
	EventDataTypeFork     = byte(0x02)
	EventDataTypeTx       = byte(0x03)
	EventDataTypeCall     = byte(0x04)
	EventDataTypeLog      = byte(0x05)
)

type EventData interface {
	AssertIsEventData()
}

var _ = wire.RegisterInterface(
	struct{ EventData }{},
	wire.ConcreteType{EventDataNewBlock{}, EventDataTypeNewBlock},
	// wire.ConcreteType{EventDataFork{}, EventDataTypeFork },
	wire.ConcreteType{EventDataTx{}, EventDataTypeTx},
	wire.ConcreteType{EventDataCall{}, EventDataTypeCall},
	wire.ConcreteType{EventDataLog{}, EventDataTypeLog},
)

// Most event messages are basic types (a block, a transaction)
// but some (an input to a call tx or a receive) are more exotic:

type EventDataNewBlock struct {
	Block *Block `json:"block"`
}

// All txs fire EventDataTx, but only CallTx might have Return or Exception
type EventDataTx struct {
	Tx        Tx     `json:"tx"`
	Return    []byte `json:"return"`
Пример #5
0
	TxTypeBond    = byte(0x11)
	TxTypeUnbond  = byte(0x12)
	TxTypeRebond  = byte(0x13)
	TxTypeDupeout = byte(0x14)

	// Admin transactions
	TxTypePermissions = byte(0x20)
)

// for wire.readReflect
var _ = wire.RegisterInterface(
	struct{ Tx }{},
	wire.ConcreteType{&SendTx{}, TxTypeSend},
	wire.ConcreteType{&CallTx{}, TxTypeCall},
	wire.ConcreteType{&NameTx{}, TxTypeName},
	wire.ConcreteType{&BondTx{}, TxTypeBond},
	wire.ConcreteType{&UnbondTx{}, TxTypeUnbond},
	wire.ConcreteType{&RebondTx{}, TxTypeRebond},
	wire.ConcreteType{&DupeoutTx{}, TxTypeDupeout},
	wire.ConcreteType{&PermissionsTx{}, TxTypePermissions},
)

//-----------------------------------------------------------------------------

type TxInput struct {
	Address   []byte        `json:"address"`   // Hash of the PubKey
	Amount    int64         `json:"amount"`    // Must not exceed account balance
	Sequence  int           `json:"sequence"`  // Must be 1 greater than the last committed TxInput
	Signature acm.Signature `json:"signature"` // Depends on the PubKey type and the whole Tx
	PubKey    acm.PubKey    `json:"pub_key"`   // Must not be nil, may be nil
}
Пример #6
0
)

// PubKey is part of Account and Validator.
type PubKey interface {
	Address() []byte
	VerifyBytes(msg []byte, sig Signature) bool
}

// Types of PubKey implementations
const (
	PubKeyTypeEd25519 = byte(0x01)
)

// for wire.readReflect
var _ = wire.RegisterInterface(
	struct{ PubKey }{},
	wire.ConcreteType{PubKeyEd25519{}, PubKeyTypeEd25519},
)

//-------------------------------------

// Implements PubKey
type PubKeyEd25519 [32]byte

// TODO: Slicing the array gives us length prefixing but loses the type byte.
// Revisit if we add more pubkey types.
// For now, we artificially append the type byte in front to give us backwards
// compatibility for when the pubkey wasn't fixed length array
func (pubKey PubKeyEd25519) Address() []byte {
	w, n, err := new(bytes.Buffer), new(int64), new(error)
	wire.WriteBinary(pubKey[:], w, n, err)
	if *err != nil {