Documentation ¶
Index ¶
- Constants
- func ByteSlice(x uint32) []byte
- func Decode(tmp *[]byte, out interface{}) error
- func DecodeBig(current *[]byte, out *big.Int) error
- func DecodeByte(d *[]byte, out *[]byte) error
- func DecodeByteL(d *[]byte, out *[]byte, l int) error
- func DecodeDoubleBig(current *[]byte, a *big.Int, b *big.Int) error
- func DecodeInt(d *[]byte, out interface{}) error
- func Deserialize(buf *[]byte, a interface{}) error
- func DoubleHash256(a *[]byte, b *[32]byte)
- func Encode(tmp *[]byte, out interface{}) error
- func EncodeBig(current *[]byte, d *big.Int) error
- func EncodeByte(current *[]byte, d *[]byte) error
- func EncodeByteL(current *[]byte, d []byte, l int) error
- func EncodeDoubleBig(current *[]byte, a *big.Int, b *big.Int) error
- func EncodeInt(current *[]byte, d interface{}) error
- func FindBigInt(a int) big.Int
- func FindByte32(a int) [32]byte
- func GenMerkTree(d *[]Transaction, out *[32]byte) error
- func HashCut(x [32]byte) [SHash]byte
- func MakeTx(a *[]InType, b *[]OutType, out *Transaction, kind int) error
- func Serialize(a interface{}, b *[]byte) error
- func ShardIndex(str [32]byte) uint32
- type AccCache
- type InType
- func (a *InType) Acc() bool
- func (a *InType) Byte(b *[]byte)
- func (a *InType) DataToIn(data *[]byte) error
- func (a *InType) InToData(b *[]byte)
- func (a *InType) Init()
- func (a *InType) Print()
- func (a *InType) Puk() ecdsa.PublicKey
- func (a *InType) ShardIndex() uint32
- func (a *InType) SignTxIn(prk *ecdsa.PrivateKey, h [32]byte)
- func (a *InType) VerifyIn(b *OutType, h [32]byte) bool
- type Miner
- type OutType
- type RCSign
- type Transaction
- func (a *Transaction) AddIn(b InType)
- func (a *Transaction) AddOut(b OutType)
- func (a *Transaction) Decode(buf *[]byte) error
- func (a *Transaction) Encode(tmp *[]byte)
- func (a *Transaction) HashTx() [32]byte
- func (a *Transaction) New(kind int, seed int64, writer uint32) error
- func (a *Transaction) Print()
- func (a *Transaction) SignTx(i uint32, prk *ecdsa.PrivateKey) error
- func (a *Transaction) VerifyTx(i uint32, b *OutType) bool
- type TransactionBatch
- type TxBlock
- func (a *TxBlock) Decode(buf *[]byte, full int) error
- func (a *TxBlock) Encode(tmp *[]byte, full int)
- func (a *TxBlock) Hash() [32]byte
- func (a *TxBlock) MakeStartBlock(ID uint32, b *[][32]byte, preHash [32]byte, prk *ecdsa.PrivateKey, h uint32) error
- func (a *TxBlock) MakeTxBlock(ID uint32, b *[]Transaction, preHash [32]byte, prk *ecdsa.PrivateKey, h uint32, ...) error
- func (a *TxBlock) Print()
- func (a *TxBlock) Serial() []byte
- func (a *TxBlock) Transform() error
- func (a *TxBlock) Verify(puk *ecdsa.PublicKey) (bool, error)
- type TxDecSet
- func (a *TxDecSet) Add(b *TxDecision)
- func (a *TxDecSet) Decode(buf *[]byte) error
- func (a *TxDecSet) Encode(tmp *[]byte)
- func (a *TxDecSet) Hash() [32]byte
- func (a *TxDecSet) Print()
- func (a *TxDecSet) Result(index uint32) bool
- func (a *TxDecSet) ResultMiner(index uint32, miner uint32) byte
- func (a *TxDecSet) Set(b *TxList, x uint32, y int)
- func (a *TxDecSet) Sign(prk *ecdsa.PrivateKey)
- func (a *TxDecSet) Verify(puk *ecdsa.PublicKey) bool
- type TxDecision
- func (a *TxDecision) Add(x byte) error
- func (a *TxDecision) Decode(buf *[]byte) error
- func (a *TxDecision) Encode(tmp *[]byte)
- func (a *TxDecision) Print()
- func (a *TxDecision) Set(ID uint32, target uint32, single uint32) error
- func (a *TxDecision) Sign(prk *ecdsa.PrivateKey, x uint32)
- func (a *TxDecision) Verify(puk *ecdsa.PublicKey, x uint32) bool
- type TxList
- func (a *TxList) AddTx(tx *Transaction)
- func (a *TxList) Decode(buf *[]byte) error
- func (a *TxList) Encode(tmp *[]byte)
- func (a *TxList) Hash() [32]byte
- func (a *TxList) Print()
- func (a *TxList) Set(ID uint32, height uint32)
- func (a *TxList) Sign(prk *ecdsa.PrivateKey)
- func (a *TxList) Verify(puk *ecdsa.PublicKey) bool
- type UserClient
Constants ¶
const Delay int = 10
Delay the communication delay(ms)
const GenesisTxBlock = "First TxBlock"
GenesisTxBlock is the predefined hash of TDS
const SHash int = 12
SHash is the shortcut length of hash
Variables ¶
This section is empty.
Functions ¶
func DecodeByte ¶
DecodeByte Decode bytes with a uint32 preamble
func DecodeByteL ¶
DecodeByteL Decode bytes with a uint32 preamble
func DecodeDoubleBig ¶
DecodeDoubleBig encodes a signature into data
func Deserialize ¶
Deserialize is the general encoding function
func DoubleHash256 ¶
DoubleHash256 returns the double hash result of hash256
func EncodeByte ¶
EncodeByte add length bit at the head of the byte array
func EncodeByteL ¶
EncodeByteL add length bit at the head of the byte array with specific length
func EncodeDoubleBig ¶
EncodeDoubleBig encodes a signature into data
func FindByte32 ¶
FindByte32 gives a [32]byte data with the input int
func GenMerkTree ¶
func GenMerkTree(d *[]Transaction, out *[32]byte) error
GenMerkTree generates the merkleroot tree given the transactions
func MakeTx ¶
func MakeTx(a *[]InType, b *[]OutType, out *Transaction, kind int) error
MakeTx implements the method to create a new transaction
Types ¶
type InType ¶
InType is the format of the input address data in the transaction
func (*InType) ShardIndex ¶
ShardIndex returns the target shard of the input address
type OutType ¶
OutType is the format of the output address data in the transaction
func (*OutType) ShardIndex ¶
ShardIndex returns the target shard of the output address
type RCSign ¶
RCSign is the signature type in our design
func (*RCSign) DataToSign ¶
DataToSign decode the []byte into signature
func (*RCSign) Sign ¶
func (a *RCSign) Sign(b []byte, prk *ecdsa.PrivateKey)
Sign returns the signature
func (*RCSign) SignToData ¶
SignToData encode the signature into []byte
type Transaction ¶
type Transaction struct { Timestamp uint64 TxinCnt uint32 In []InType TxoutCnt uint32 Out []OutType Kind uint32 Locktime uint32 Hash [32]byte }
Transaction is the transaction data which sent by the sender
func (*Transaction) AddIn ¶
func (a *Transaction) AddIn(b InType)
AddIn increases one input of transaction a
func (*Transaction) AddOut ¶
func (a *Transaction) AddOut(b OutType)
AddOut increases one output of transaction a
func (*Transaction) Decode ¶
func (a *Transaction) Decode(buf *[]byte) error
Decode decodes the packets into transaction format
func (*Transaction) Encode ¶
func (a *Transaction) Encode(tmp *[]byte)
Encode converts the transaction into bytes
func (*Transaction) New ¶
func (a *Transaction) New(kind int, seed int64, writer uint32) error
New is to initialize a transaction
func (*Transaction) SignTx ¶
func (a *Transaction) SignTx(i uint32, prk *ecdsa.PrivateKey) error
SignTx sign the ith in-address with the private key
type TransactionBatch ¶
type TransactionBatch struct { TxCnt uint32 TxArray []Transaction }
TransactionBatch a set of multiple transactions
func (*TransactionBatch) Add ¶
func (a *TransactionBatch) Add(b *Transaction) error
Add is to add a transactionbatch
func (*TransactionBatch) Decode ¶
func (a *TransactionBatch) Decode(buf *[]byte) error
Decode is to encode a transactionbatch
func (*TransactionBatch) Encode ¶
func (a *TransactionBatch) Encode() []byte
Encode is to encode a transactionbatch
func (*TransactionBatch) New ¶
func (a *TransactionBatch) New(b *[]Transaction) error
New is to initialize a transactionbatch
type TxBlock ¶
type TxBlock struct { ID uint32 PrevHash [32]byte PrevFinalHash [32]byte ShardID uint32 HashID [32]byte MerkleRoot [32]byte Kind uint32 Timestamp int64 Height uint32 TxCnt uint32 TxArray []Transaction TxHash [][32]byte TxArrayX [][SHash]byte Sig RCSign }
TxBlock introduce the struct of the transaction block
func NewGensisFinalTxBlock ¶
NewGensisFinalTxBlock is the gensis block
func (*TxBlock) MakeStartBlock ¶
func (a *TxBlock) MakeStartBlock(ID uint32, b *[][32]byte, preHash [32]byte, prk *ecdsa.PrivateKey, h uint32) error
MakeStartBlock creates the transaction blocks given verified transactions
func (*TxBlock) MakeTxBlock ¶
func (a *TxBlock) MakeTxBlock(ID uint32, b *[]Transaction, preHash [32]byte, prk *ecdsa.PrivateKey, h uint32, kind uint32, preFH *[32]byte, shardID uint32) error
MakeTxBlock creates the transaction blocks given verified transactions
type TxDecSet ¶
type TxDecSet struct { ID uint32 Round uint32 HashID [32]byte MemCnt uint32 ShardIndex uint32 MemD []TxDecision TxCnt uint32 TxArray [][32]byte TxArrayX [][SHash]byte Sig RCSign }
TxDecSet is the set of all decisions from one shard, signed by leader
func (*TxDecSet) ResultMiner ¶
ResultMiner is the specific result of a miner
type TxDecision ¶
type TxDecision struct { ID uint32 // miner id what id? hash256(pubkey) HashID [32]byte // transaction list id TxCnt uint32 Decision []byte Target uint32 Single uint32 Sig []RCSign }
TxDecision is the decisions based on given TxList
func (*TxDecision) Add ¶
func (a *TxDecision) Add(x byte) error
Add adds one decision given the result
func (*TxDecision) Decode ¶
func (a *TxDecision) Decode(buf *[]byte) error
Decode decodes the []byte into TxDecision
func (*TxDecision) Encode ¶
func (a *TxDecision) Encode(tmp *[]byte)
Encode encodes the TxDecision into []byte
func (*TxDecision) Set ¶
func (a *TxDecision) Set(ID uint32, target uint32, single uint32) error
Set initiates the TxDecision given the TxList and the account
func (*TxDecision) Sign ¶
func (a *TxDecision) Sign(prk *ecdsa.PrivateKey, x uint32)
Sign signs the TxDecision
type TxList ¶
type TxList struct { ID uint32 HashID [32]byte Round uint32 TxCnt uint32 TxArray [][32]byte TxArrayX [][SHash]byte Sig RCSign }
TxList is the list of tx sent by Leader to miner for their verification
func (*TxList) AddTx ¶
func (a *TxList) AddTx(tx *Transaction)
AddTx adds the tx into transaction list
func (*TxList) Sign ¶
func (a *TxList) Sign(prk *ecdsa.PrivateKey)
Sign signs the TxList with the leader's private key
type UserClient ¶
type UserClient struct { IPaddress string Prk ecdsa.PublicKey // contains filtered or unexported fields }
UserClient is the struct for miner and client