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.
Index ¶
- Constants
- Variables
- func ChannelHandler(timer *time.Timer, receiver chan interface{}, data interface{})
- type BinaryWriter
- type ConfirmTime
- 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 RawTxi
- type RawTxis
- type TxBase
- func (t *TxBase) CalcMinedHash() (hash common.Hash)
- func (t *TxBase) CalcTxHash() (hash common.Hash)
- func (t *TxBase) CalculateWeight(parents Txis) uint64
- func (z *TxBase) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *TxBase) EncodeMsg(en *msgp.Writer) (err error)
- func (t *TxBase) GetHeight() uint64
- func (t *TxBase) GetNonce() uint64
- func (t *TxBase) GetTxHash() common.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 (z *TxBase) MarshalMsg(b []byte) (o []byte, err error)
- func (z *TxBase) Msgsize() (s int)
- func (t *TxBase) Parents() common.Hashes
- func (t *TxBase) SetHash(hash common.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 (z *TxBase) UnmarshalMsg(bts []byte) (o []byte, err error)
- type TxBaseJson
- type TxBaseType
- func (z *TxBaseType) DecodeMsg(dc *msgp.Reader) (err error)
- func (z TxBaseType) EncodeMsg(en *msgp.Writer) (err error)
- func (z TxBaseType) MarshalMsg(b []byte) (o []byte, err error)
- func (z TxBaseType) Msgsize() (s int)
- func (t TxBaseType) String() string
- func (z *TxBaseType) UnmarshalMsg(bts []byte) (o []byte, err error)
- type Txi
- type TxiSmallCaseMarshal
- func (z *TxiSmallCaseMarshal) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *TxiSmallCaseMarshal) EncodeMsg(en *msgp.Writer) (err error)
- func (t *TxiSmallCaseMarshal) MarshalJSON() ([]byte, error)
- func (z *TxiSmallCaseMarshal) MarshalMsg(b []byte) (o []byte, err error)
- func (z *TxiSmallCaseMarshal) Msgsize() (s int)
- func (z *TxiSmallCaseMarshal) UnmarshalMsg(bts []byte) (o []byte, err error)
- type Txis
- func (z *Txis) DecodeMsg(dc *msgp.Reader) (err error)
- func (z Txis) EncodeMsg(en *msgp.Writer) (err error)
- func (t Txis) Len() int
- func (t Txis) Less(i, j int) bool
- func (z Txis) MarshalMsg(b []byte) (o []byte, err error)
- func (z Txis) Msgsize() (s int)
- func (t Txis) RawTxis() RawTxis
- func (t Txis) String() string
- func (t Txis) Swap(i, j int)
- func (z *Txis) UnmarshalMsg(bts []byte) (o []byte, err error)
Constants ¶
const ( VerifiedNone verifiedType = iota VerifiedFormat VerifiedGraph VerifiedFormatAndGraph )
Variables ¶
var ( ErrDuplicateTx = errors.New("Duplicate tx found in txlookup") ErrDuplicateNonce = errors.New("Duplicate tx nonce") ErrNonceNotExist = errors.New("Nonce not exist") )
var CanRecoverPubFromSig bool
Functions ¶
func ChannelHandler ¶
Types ¶
type BinaryWriter ¶ added in v0.0.2
type BinaryWriter struct {
// contains filtered or unexported fields
}
func NewBinaryWriter ¶ added in v0.0.2
func NewBinaryWriter() *BinaryWriter
func (*BinaryWriter) Write ¶ added in v0.0.2
func (s *BinaryWriter) Write(datas ...interface{})
type ConfirmTime ¶
type ConfirmTime struct {
SeqHeight uint64 `json:"seq_Height"`
TxNum uint64 `json:"tx_num"`
ConfirmTime string `json:"confirm_time"`
}
func (*ConfirmTime) DecodeMsg ¶
func (z *ConfirmTime) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (ConfirmTime) EncodeMsg ¶
func (z ConfirmTime) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (ConfirmTime) MarshalMsg ¶
func (z ConfirmTime) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (ConfirmTime) Msgsize ¶
func (z ConfirmTime) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*ConfirmTime) UnmarshalMsg ¶
func (z *ConfirmTime) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type PublicKey ¶ added in v0.0.2
type PublicKey []byte
func (PublicKey) MarshalJson ¶ added in v0.0.2
func (PublicKey) MarshalMsg ¶ added in v0.0.2
MarshalMsg implements msgp.Marshaler
type RawTxi ¶
type RawTxi interface {
GetType() TxBaseType
GetHeight() uint64
GetWeight() uint64
GetTxHash() common.Hash
GetNonce() uint64
Parents() common.Hashes // Parents returns the hash of txs that it directly proves.
SetHash(h common.Hash)
String() string
CalcTxHash() common.Hash // TxHash returns a full tx hash (parents sealed by PoW stage 2)
CalcMinedHash() common.Hash // NonceHash returns the part that needs to be considered in PoW stage 1.
CalculateWeight(parents Txis) uint64
Txi() Txi
// implemented by msgp
DecodeMsg(dc *msgp.Reader) (err error)
EncodeMsg(en *msgp.Writer) (err error)
MarshalMsg(b []byte) (o []byte, err error)
UnmarshalMsg(bts []byte) (o []byte, err error)
Msgsize() (s int)
}
type RawTxis ¶
type RawTxis []RawTxi
func (t Txis) ToRaw() (txs RawTxs, cps RawCampaigns, tcs RawTermChanges, seqs RawSequencers) {
for _, txi := range t {
switch tx := txi.(type) {
case *Tx:
txs = append(txs, tx.RawTx())
case *Campaign:
cps = append(cps, tx.RawCampaign())
case *TermChange:
tcs = append(tcs, tx.RawTermChange())
case *Sequencer:
seqs = append(seqs, tx.RawSequencer())
}
}
if len(txs) == 0 {
txs = nil
}
if len(cps) == 0 {
cps = nil
}
if len(seqs) == 0 {
seqs = nil
}
return
}
func (RawTxis) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type TxBase ¶
type TxBase struct {
Type TxBaseType
Hash common.Hash
ParentsHash common.Hashes
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 ¶ added in v0.0.2
func (*TxBase) IsVerified ¶ added in v0.0.2
func (t *TxBase) IsVerified() verifiedType
func (*TxBase) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (*TxBase) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*TxBase) SetInValid ¶
func (*TxBase) SetVerified ¶ added in v0.0.2
func (t *TxBase) SetVerified(v verifiedType)
func (*TxBase) ToSmallCase ¶ added in v0.0.2
func (t *TxBase) ToSmallCase() *TxBaseJson
func (*TxBase) ToSmallCaseJson ¶ added in v0.0.2
type TxBaseJson ¶ added in v0.0.2
type TxBaseJson struct {
Type TxBaseType `json:"type"`
Hash common.Hash `json:"hash"`
ParentsHash common.Hashes `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
}
func (*TxBaseJson) DecodeMsg ¶ added in v0.0.2
func (z *TxBaseJson) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*TxBaseJson) EncodeMsg ¶ added in v0.0.2
func (z *TxBaseJson) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*TxBaseJson) MarshalMsg ¶ added in v0.0.2
func (z *TxBaseJson) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*TxBaseJson) Msgsize ¶ added in v0.0.2
func (z *TxBaseJson) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*TxBaseJson) UnmarshalMsg ¶ added in v0.0.2
func (z *TxBaseJson) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type TxBaseType ¶
type TxBaseType uint16
const ( TxBaseTypeNormal TxBaseType = iota TxBaseTypeSequencer TxBaseTypeCampaign TxBaseTypeTermChange TxBaseTypeArchive TxBaseAction )
add tx types here
func (*TxBaseType) DecodeMsg ¶
func (z *TxBaseType) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (TxBaseType) EncodeMsg ¶
func (z TxBaseType) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (TxBaseType) MarshalMsg ¶
func (z TxBaseType) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (TxBaseType) Msgsize ¶
func (z TxBaseType) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (TxBaseType) String ¶
func (t TxBaseType) String() string
func (*TxBaseType) UnmarshalMsg ¶
func (z *TxBaseType) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type Txi ¶
type Txi interface {
// Implemented by TxBase
GetType() TxBaseType
GetHeight() uint64
GetWeight() uint64
GetTxHash() common.Hash
GetNonce() uint64
Parents() common.Hashes // Parents returns the common.Hash of txs that it directly proves.
SetHash(h common.Hash)
String() string
CalcTxHash() common.Hash // TxHash returns a full tx common.Hash (parents sealed by PoW stage 2)
CalcMinedHash() common.Hash // NonceHash returns the part that needs to be considered in PoW stage 1.
CalculateWeight(parents Txis) uint64
SetInValid(b bool)
InValid() bool
// implemented by each tx type
GetBase() *TxBase
Sender() common.Address
GetSender() *common.Address
SetSender(addr common.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.
RawTxi() RawTxi // compressed txi
// implemented by msgp
DecodeMsg(dc *msgp.Reader) (err error)
EncodeMsg(en *msgp.Writer) (err error)
MarshalMsg(b []byte) (o []byte, err error)
UnmarshalMsg(bts []byte) (o []byte, err error)
Msgsize() (s int)
GetVersion() byte
ToSmallCaseJson() ([]byte, error)
IsVerified() verifiedType
SetVerified(v verifiedType)
}
type TxiSmallCaseMarshal ¶ added in v0.0.2
type TxiSmallCaseMarshal struct {
Txi Txi
}
func (*TxiSmallCaseMarshal) DecodeMsg ¶ added in v0.0.2
func (z *TxiSmallCaseMarshal) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*TxiSmallCaseMarshal) EncodeMsg ¶ added in v0.0.2
func (z *TxiSmallCaseMarshal) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*TxiSmallCaseMarshal) MarshalJSON ¶ added in v0.0.2
func (t *TxiSmallCaseMarshal) MarshalJSON() ([]byte, error)
func (*TxiSmallCaseMarshal) MarshalMsg ¶ added in v0.0.2
func (z *TxiSmallCaseMarshal) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*TxiSmallCaseMarshal) Msgsize ¶ added in v0.0.2
func (z *TxiSmallCaseMarshal) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*TxiSmallCaseMarshal) UnmarshalMsg ¶ added in v0.0.2
func (z *TxiSmallCaseMarshal) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type Txis ¶
type Txis []Txi
func (Txis) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler