Documentation
¶
Overview ¶
Copyright © 2019 Annchain Authors <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2019 Annchain Authors <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2019 Annchain Authors <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2019 Annchain Authors <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2019 Annchain Authors <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func ChannelHandler(timer *time.Timer, receiver chan interface{}, data interface{})
- type ActionData
- type ActionTx
- func (t *ActionTx) CheckActionIsValid() bool
- func (t *ActionTx) Compare(tx Txi) bool
- func (t *ActionTx) Dump() string
- func (t *ActionTx) GetBase() *TxBase
- func (t *ActionTx) GetConfirm() time.Duration
- func (t *ActionTx) GetSender() ogTypes.Address
- func (c *ActionTx) MarshalMsg() ([]byte, error)
- func (c *ActionTx) MsgSize() int
- func (t *ActionTx) Sender() ogTypes.Address
- func (c *ActionTx) SetSender(addr ogTypes.Address)
- func (t *ActionTx) Setconfirm()
- func (t *ActionTx) SignatureTargets() []byte
- func (t *ActionTx) String() string
- func (c *ActionTx) UnmarshalMsg(b []byte) ([]byte, error)
- type BinaryWriter
- type BlsSigSet
- type DestroyOffering
- type InitialOffering
- type PublicKey
- func (z *PublicKey) DecodeMsg(dc *msgp.Reader) (err error)
- func (z PublicKey) EncodeMsg(en *msgp.Writer) (err error)
- func (b PublicKey) MarshalJson() ([]byte, error)
- func (z PublicKey) MarshalMsg(b []byte) (o []byte, err error)
- func (z PublicKey) Msgsize() (s int)
- func (z PublicKey) String() string
- func (z *PublicKey) UnmarshalMsg(bts []byte) (o []byte, err error)
- type RequestDomain
- type SecondaryOffering
- type Sequencer
- func (t *Sequencer) Compare(tx Txi) bool
- func (t *Sequencer) Dump() string
- func (t *Sequencer) GetBase() *TxBase
- func (s *Sequencer) GetConfirmSeqHash() og_types.Hash
- func (t *Sequencer) GetHead() *SequencerHeader
- func (s *Sequencer) GetParentSeqHash() og_types.Hash
- func (t *Sequencer) GetSender() og_types.Address
- func (s *Sequencer) MarshalMsg() ([]byte, error)
- func (s *Sequencer) MsgSize() int
- func (t *Sequencer) Number() uint64
- func (t *Sequencer) Parents() []og_types.Hash
- func (s *Sequencer) PrevBlock() og_types.Hash
- func (t *Sequencer) Sender() og_types.Address
- func (t *Sequencer) SetSender(addr og_types.Address)
- func (t *Sequencer) SignatureTargets() []byte
- func (t *Sequencer) String() string
- func (s *Sequencer) ToJsonMsg() SequencerMsg
- func (s *Sequencer) ToSmallCaseJson() ([]byte, error)
- func (s *Sequencer) UnmarshalMsg(b []byte) ([]byte, error)
- type SequencerHeader
- func (z *SequencerHeader) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *SequencerHeader) EncodeMsg(en *msgp.Writer) (err error)
- func (s *SequencerHeader) Equal(h *SequencerHeader) bool
- func (s *SequencerHeader) GetHash() og_types.Hash
- func (s *SequencerHeader) GetHeight() uint64
- func (z *SequencerHeader) MarshalMsg(b []byte) (o []byte, err error)
- func (z *SequencerHeader) Msgsize() (s int)
- func (s *SequencerHeader) SequencerId() uint64
- func (s *SequencerHeader) String() string
- func (s *SequencerHeader) StringFull() string
- func (z *SequencerHeader) UnmarshalMsg(bts []byte) (o []byte, err error)
- type SequencerHeaders
- func (z *SequencerHeaders) DecodeMsg(dc *msgp.Reader) (err error)
- func (z SequencerHeaders) EncodeMsg(en *msgp.Writer) (err error)
- func (z SequencerHeaders) MarshalMsg(b []byte) (o []byte, err error)
- func (z SequencerHeaders) Msgsize() (s int)
- func (h SequencerHeaders) String() string
- func (z *SequencerHeaders) UnmarshalMsg(bts []byte) (o []byte, err error)
- type SequencerJson
- type SequencerMsg
- type Sequencers
- type TransactionMsg
- type Tx
- func (t *Tx) Compare(tx Txi) bool
- func (t *Tx) Dump() string
- func (t *Tx) GetBase() *TxBase
- func (t *Tx) GetConfirm() time.Duration
- func (t *Tx) GetSender() og_types.Address
- func (t *Tx) GetValue() *math.BigInt
- func (t *Tx) MarshalMsg() ([]byte, error)
- func (t *Tx) MsgSize() int
- func (t *Tx) Parents() []og_types.Hash
- func (t *Tx) Sender() og_types.Address
- func (t *Tx) SetSender(addr og_types.Address)
- func (t *Tx) Setconfirm()
- func (t *Tx) SignatureTargets() []byte
- func (t *Tx) String() string
- func (t *Tx) ToJsonMsg() TransactionMsg
- func (t *Tx) UnmarshalMsg(b []byte) ([]byte, error)
- type TxBase
- func (t *TxBase) CalcMinedHash() (hash og_types.Hash)
- func (t *TxBase) CalcTxHash() (hash og_types.Hash)
- func (t *TxBase) CalculateWeight(parents Txis) uint64
- func (t *TxBase) GetHeight() uint64
- func (t *TxBase) GetNonce() uint64
- func (t *TxBase) GetTxHash() og_types.Hash
- func (t *TxBase) GetType() TxBaseType
- func (t *TxBase) GetVersion() byte
- func (t *TxBase) GetWeight() uint64
- func (t *TxBase) InValid() bool
- func (t *TxBase) IsVerified() verifiedType
- func (t *TxBase) MarshalMsg() ([]byte, error)
- func (t *TxBase) MsgSize() int
- func (t *TxBase) Parents() []og_types.Hash
- func (t *TxBase) SetHash(hash og_types.Hash)
- func (t *TxBase) SetInValid(b bool)
- func (t *TxBase) SetVerified(v verifiedType)
- func (t *TxBase) String() string
- func (t *TxBase) ToSmallCase() *TxBaseJson
- func (t *TxBase) ToSmallCaseJson() ([]byte, error)
- func (t *TxBase) UnmarshalMsg(b []byte) ([]byte, error)
- type TxBaseJson
- type TxBaseType
- type Txi
- type Txis
- type Txs
Constants ¶
const ( ActionTxActionIPO uint8 = iota ActionTxActionDestroy ActionTxActionSPO ActionRequestDomainName )
const ( VerifiedNone verifiedType = iota VerifiedFormat VerifiedGraph VerifiedFormatAndGraph )
Variables ¶
var ( ErrDuplicateTx = errors.New("duplicate tx found in txlookup") ErrDuplicateNonce = errors.New("duplicate tx nonce") ErrTxNotExist = errors.New("transaction not exist") ErrNonceNotExist = errors.New("nonce not exist") )
var CanRecoverPubFromSig bool
Functions ¶
func ChannelHandler ¶
Types ¶
type ActionData ¶
type ActionData interface {
marshaller.IMarshaller
String() string
}
type ActionTx ¶
type ActionTx struct {
TxBase
Action uint8
From ogTypes.Address
ActionData ActionData
// contains filtered or unexported fields
}
func RandomActionTx ¶
func RandomActionTx() *ActionTx
func SampleActionTx ¶
func SampleActionTx() *ActionTx
func (*ActionTx) CheckActionIsValid ¶
func (*ActionTx) GetConfirm ¶
func (*ActionTx) MarshalMsg ¶
func (*ActionTx) Setconfirm ¶
func (t *ActionTx) Setconfirm()
func (*ActionTx) SignatureTargets ¶
type BinaryWriter ¶
type BinaryWriter struct {
// contains filtered or unexported fields
}
func NewBinaryWriter ¶
func NewBinaryWriter() *BinaryWriter
func (*BinaryWriter) Write ¶
func (s *BinaryWriter) Write(datas ...interface{})
type DestroyOffering ¶
type DestroyOffering struct {
TokenId int32 `json:"token_id"`
}
func NewDestroyOffering ¶
func NewDestroyOffering(tokenId int32) *DestroyOffering
func (*DestroyOffering) MarshalMsg ¶
func (d *DestroyOffering) MarshalMsg() ([]byte, error)
func (*DestroyOffering) MsgSize ¶
func (d *DestroyOffering) MsgSize() int
func (*DestroyOffering) String ¶
func (d *DestroyOffering) String() string
func (*DestroyOffering) UnmarshalMsg ¶
func (d *DestroyOffering) UnmarshalMsg(b []byte) ([]byte, error)
type InitialOffering ¶
type InitialOffering struct {
Value *math.BigInt `json:"value"`
EnableSPO bool `json:"enable_spo"` //if enableSPO is false , no Secondary Public Issues.
TokenName string `json:"token_name"`
}
func NewInitialOffering ¶
func NewInitialOffering(value *math.BigInt, enableSPO bool, tokenName string) *InitialOffering
func (*InitialOffering) MarshalMsg ¶
func (p *InitialOffering) MarshalMsg() ([]byte, error)
func (*InitialOffering) MsgSize ¶
func (p *InitialOffering) MsgSize() int
func (InitialOffering) String ¶
func (p InitialOffering) String() string
func (*InitialOffering) UnmarshalMsg ¶
func (p *InitialOffering) UnmarshalMsg(b []byte) ([]byte, error)
type PublicKey ¶
type PublicKey []byte
func (PublicKey) MarshalJson ¶
func (PublicKey) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type RequestDomain ¶
type RequestDomain struct {
DomainName string
}
func (RequestDomain) String ¶
func (r RequestDomain) String() string
type SecondaryOffering ¶
type SecondaryOffering struct {
TokenId int32 `json:"token_id"` //for Secondary Public Issues
Value *math.BigInt `json:"value"`
}
func NewSecondaryOffering ¶
func NewSecondaryOffering(tokenId int32, value *math.BigInt) *SecondaryOffering
func (*SecondaryOffering) MarshalMsg ¶
func (so *SecondaryOffering) MarshalMsg() ([]byte, error)
func (*SecondaryOffering) MsgSize ¶
func (so *SecondaryOffering) MsgSize() int
func (SecondaryOffering) String ¶
func (so SecondaryOffering) String() string
func (*SecondaryOffering) UnmarshalMsg ¶
func (so *SecondaryOffering) UnmarshalMsg(b []byte) ([]byte, error)
type Sequencer ¶
type Sequencer struct {
// TODO: need more states in sequencer to differentiate multiple chains
TxBase
Issuer og_types.Address
BlsJointSig hexutil.Bytes
BlsJointPubKey hexutil.Bytes
StateRoot og_types.Hash
Proposing bool `msg:"-"` // is the sequencer is proposal ,did't commit yet ,use this flag to avoid bls sig verification failed
}
func RandomSequencer ¶
func RandomSequencer() *Sequencer
func SampleSequencer ¶
func SampleSequencer() *Sequencer
func (*Sequencer) GetConfirmSeqHash ¶
func (*Sequencer) GetHead ¶
func (t *Sequencer) GetHead() *SequencerHeader
func (*Sequencer) GetParentSeqHash ¶
func (*Sequencer) SignatureTargets ¶
func (*Sequencer) ToJsonMsg ¶
func (s *Sequencer) ToJsonMsg() SequencerMsg
func (*Sequencer) ToSmallCaseJson ¶
type SequencerHeader ¶
func NewSequencerHead ¶
func NewSequencerHead(hash og_types.Hash, height uint64) *SequencerHeader
func (*SequencerHeader) DecodeMsg ¶
func (z *SequencerHeader) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*SequencerHeader) EncodeMsg ¶
func (z *SequencerHeader) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*SequencerHeader) Equal ¶
func (s *SequencerHeader) Equal(h *SequencerHeader) bool
func (*SequencerHeader) GetHash ¶
func (s *SequencerHeader) GetHash() og_types.Hash
func (*SequencerHeader) GetHeight ¶
func (s *SequencerHeader) GetHeight() uint64
func (*SequencerHeader) MarshalMsg ¶
func (z *SequencerHeader) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*SequencerHeader) Msgsize ¶
func (z *SequencerHeader) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*SequencerHeader) SequencerId ¶
func (s *SequencerHeader) SequencerId() uint64
func (*SequencerHeader) String ¶
func (s *SequencerHeader) String() string
func (*SequencerHeader) StringFull ¶
func (s *SequencerHeader) StringFull() string
func (*SequencerHeader) UnmarshalMsg ¶
func (z *SequencerHeader) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type SequencerHeaders ¶
type SequencerHeaders []*SequencerHeader
func (*SequencerHeaders) DecodeMsg ¶
func (z *SequencerHeaders) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (SequencerHeaders) EncodeMsg ¶
func (z SequencerHeaders) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (SequencerHeaders) MarshalMsg ¶
func (z SequencerHeaders) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (SequencerHeaders) Msgsize ¶
func (z SequencerHeaders) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (SequencerHeaders) String ¶
func (h SequencerHeaders) String() string
func (*SequencerHeaders) UnmarshalMsg ¶
func (z *SequencerHeaders) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type SequencerJson ¶
type SequencerMsg ¶
type SequencerMsg struct {
Type int `json:"type"`
Hash string `json:"hash"`
Parents []string `json:"parents"`
Issuer string `json:"issuer"`
Nonce uint64 `json:"nonce"`
Height uint64 `json:"height"`
Weight uint64 `json:"weight"`
BlsJointSig string `json:"bls_joint_sig"`
BlsJointPubKey string `json:"bls_joint_pub_key"`
}
type Sequencers ¶
type Sequencers []*Sequencer
func (Sequencers) String ¶
func (s Sequencers) String() string
func (Sequencers) ToHeaders ¶
func (s Sequencers) ToHeaders() SequencerHeaders
type TransactionMsg ¶
type Tx ¶
type Tx struct {
TxBase
From og_types.Address
To og_types.Address
Value *math.BigInt
TokenId int32
Data []byte
// contains filtered or unexported fields
}
func (*Tx) GetConfirm ¶
func (*Tx) MarshalMsg ¶
func (*Tx) Setconfirm ¶
func (t *Tx) Setconfirm()
func (*Tx) SignatureTargets ¶
func (*Tx) ToJsonMsg ¶
func (t *Tx) ToJsonMsg() TransactionMsg
type TxBase ¶
type TxBase struct {
Type TxBaseType
Hash og_types.Hash
ParentsHash []og_types.Hash
AccountNonce uint64
Height uint64
PublicKey PublicKey //
Signature hexutil.Bytes
MineNonce uint64
Weight uint64
Version byte
// contains filtered or unexported fields
}
func (*TxBase) CalcMinedHash ¶
func (*TxBase) CalcTxHash ¶
func (*TxBase) CalculateWeight ¶
CalculateWeight a core algorithm for tx sorting, a tx's weight must bigger than any of it's parent's weight and bigger than any of it's elder transaction's
func (*TxBase) GetType ¶
func (t *TxBase) GetType() TxBaseType
func (*TxBase) GetVersion ¶
func (*TxBase) IsVerified ¶
func (t *TxBase) IsVerified() verifiedType
func (*TxBase) MarshalMsg ¶
func (*TxBase) SetInValid ¶
func (*TxBase) SetVerified ¶
func (t *TxBase) SetVerified(v verifiedType)
func (*TxBase) ToSmallCase ¶
func (t *TxBase) ToSmallCase() *TxBaseJson
func (*TxBase) ToSmallCaseJson ¶
type TxBaseJson ¶
type TxBaseJson struct {
Type TxBaseType `json:"type"`
Hash og_types.Hash `json:"hash"`
ParentsHash []og_types.Hash `json:"parents_hash"`
AccountNonce uint64 `json:"account_nonce"`
Height uint64 `json:"height"`
PublicKey PublicKey `json:"public_key"`
Signature hexutil.Bytes `json:"signature"`
MineNonce uint64 `json:"mine_nonce"`
Weight uint64 `json:"weight"`
Version byte `json:"version"`
// contains filtered or unexported fields
}
type TxBaseType ¶
type TxBaseType uint8
const ( TxBaseTypeNormal TxBaseType = iota TxBaseTypeSequencer TxBaseTypeCampaign TxBaseTypeTermChange TxBaseTypeArchive TxBaseAction )
add tx types here
func (TxBaseType) String ¶
func (t TxBaseType) String() string
type Txi ¶
type Txi interface {
// Implemented by TxBase
GetType() TxBaseType
GetHeight() uint64
GetWeight() uint64
GetTxHash() og_types.Hash
GetNonce() uint64
Parents() []og_types.Hash // Parents returns the common.Hash of txs that it directly proves.
SetHash(h og_types.Hash)
String() string
CalcTxHash() og_types.Hash // TxHash returns a full tx common.Hash (parents sealed by PoW stage 2)
CalcMinedHash() og_types.Hash // NonceHash returns the part that needs to be considered in PoW stage 1.
CalculateWeight(parents Txis) uint64
ToSmallCaseJson() ([]byte, error)
IsVerified() verifiedType
SetVerified(v verifiedType)
SetInValid(b bool)
InValid() bool
// implemented by each tx type
GetBase() *TxBase
Sender() og_types.Address
GetSender() og_types.Address
SetSender(addr og_types.Address)
Dump() string // For logger dump
Compare(tx Txi) bool // Compare compares two txs, return true if they are the same.
SignatureTargets() []byte // SignatureTargets only returns the parts that needs to be signed by sender.
GetVersion() byte
marshaller.IMarshaller
}