Documentation
¶
Overview ¶
Provides a reduced record of approved cycle transactions to store with the balance list. This is used to enforce the ∩100,000 per 10,000-block limit of NTTP-3/3. The initiator and receiver, while not necessary for this, are stored because they are small and helpful for anyone reviewing the balance list.
A balance list, including all the auxiliary data typical for the Java implementation. This is not strictly part of the blockchain, but for local storage, balance lists are serialized and deserialized just like blockchain data.
Individual entry in a balance list.
A Nyzo block, only low-level serialization/deserialization activity should happen here, plus basical structural sanity checking. More complex stuff like transaction validation or continuity needs to go further up.
Used to attach additional cycle info to a block, this is not part of the original spec, it exists to speed up cycle-related calculations and is only of local relevance.
A block vote.
Gets attached to a block, represents info about the current and past cycles.
An individual cycle transaction signature (V1 blockchain).
A special data type sometimes used to save a little space during data serialization.
An individual transaction. Only simple serialization/deserialization and structural sanity checking belongs here.
Used for costly verifications (so that we don't have to repeat them).
Index ¶
Constants ¶
const ( TransactionTypeCoinGeneration = 0 TransactionTypeSeed = 1 TransactionTypeStandard = 2 TransactionTypeCycle = 3 TransactionTypeCycleSignature = 4 TransactionTypeAccountFee = 97 TransactionTypeCycleReward = 98 TransactionTypeVerifierReward = 99 )
const ( Undetermined = 0 Valid = 1 Invalid = 2 )
Variables ¶
This section is empty.
Functions ¶
func FromShlong ¶
Takes a shlong and turns it into a long and a short.
Types ¶
type ApprovedCycleTransaction ¶
type ApprovedCycleTransaction struct {
InitiatorIdentifier []byte
ReceiverIdentifier []byte
ApprovalHeight int64
Amount int64
}
func ReadNewApprovedCycleTransaction ¶
func ReadNewApprovedCycleTransaction(r io.Reader) (*ApprovedCycleTransaction, error)
Convenience to create an approved cycle transaction from a byte buffer.
func (*ApprovedCycleTransaction) GetSerializedLength ¶
func (t *ApprovedCycleTransaction) GetSerializedLength() int
Serializable interface: data length when serialized.
func (*ApprovedCycleTransaction) Read ¶
func (t *ApprovedCycleTransaction) Read(r io.Reader) error
Serializable interface: convert from bytes.
func (*ApprovedCycleTransaction) ToBytes ¶
func (t *ApprovedCycleTransaction) ToBytes() []byte
Serializable interface: convert to bytes.
type BalanceList ¶
type BalanceList struct {
BlockchainVersion int16
BlockHeight int64
RolloverFees byte
PreviousVerifiers [][]byte
Items []BalanceListItem
UnlockThreshold int64
UnlockTransferSum int64
PendingCycleTransactions []*Transaction
RecentlyApprovedCycleTransactions []*ApprovedCycleTransaction
}
func ReadNewBalanceList ¶
func ReadNewBalanceList(r io.Reader) (*BalanceList, error)
func (*BalanceList) GetHash ¶
func (bl *BalanceList) GetHash() []byte
Get the hash for this balance list
func (*BalanceList) GetSerializedLength ¶
func (bl *BalanceList) GetSerializedLength() int
Serializable interface: data length when serialized
func (*BalanceList) Normalize ¶
func (bl *BalanceList) Normalize()
Normalize a balance list by removing accounts with 0 micronyzo and duplicates
func (*BalanceList) Read ¶
func (bl *BalanceList) Read(r io.Reader) error
Serialization interface. Read a balance list from bytes.
func (*BalanceList) ToBytes ¶
func (bl *BalanceList) ToBytes() []byte
Serializable interface: convert to bytes.
type BalanceListItem ¶
type Block ¶
type Block struct {
BlockchainVersion int16 // 2 bytes; 16-bit integer of the blockchain version
Height int64 // 6 bytes; 48-bit integer block height from the Genesis block, which has a height of 0
PreviousBlockHash []byte // 32 bytes (this is the double-SHA-256 of the previous block signature)
StartTimestamp int64 // 8 bytes; 64-bit Unix timestamp of the start of the block, in milliseconds
VerificationTimestamp int64 // 8 bytes; 64-bit Unix timestamp of when the verifier creates the block, in milliseconds
Transactions []*Transaction // 4 bytes for number + variable
BalanceListHash []byte // 32 bytes (this is the double-SHA-256 of the account balance list)
VerifierIdentifier []byte // 32 bytes
VerifierSignature []byte // 64 bytes
ContinuityState int
SignatureState int
CycleInformation *CycleInformation
Hash []byte
CycleInfoCache *BlockCycleInfoCache
}
func ReadNewBlock ¶
Read a new block from the given reader.
func (*Block) GetSerializedLength ¶
Serializable interface: data length when serialized
type BlockCycleInfoCache ¶
type BlockVote ¶
type BlockVote struct {
Height int64
Hash []byte
Timestamp int64 // to prevent replay attacks of old votes (actually, unnecessary due to message timestamp)
ReceiptTimestamp int64 // local-only field used to ensure minimum spacing between votes
SenderIdentifier []byte // sender of the message for BlockWithVotesResponse
MessageTimestamp int64 // timestamp of the message for BlockWithVotesResponse
MessageSignature []byte // signature of the message for BlockWithVotesResponse
}
func (*BlockVote) GetSerializedLength ¶
Serializable interface: data length when serialized
type CycleInformation ¶
type CycleInformation struct {
MaximumCycleLength int
CycleLengths []int
NewVerifier bool
InGenesisCycle bool
}
func (CycleInformation) CalculateTrailingEdgeHeight ¶
func (c CycleInformation) CalculateTrailingEdgeHeight(blockHeight int64) int64
The trailing edge is 4 cycles back from the current height (or 0)
type CycleSignature ¶
type Transaction ¶
type Transaction struct {
// in all transactions
Type byte // 1 byte, see above
Timestamp int64 // 8 bytes; 64-bit Unix timestamp of the transaction initiation, in milliseconds
Amount int64 // 8 bytes; 64-bit amount in micronyzos
RecipientId []byte // 32 bytes (256-bit public key of the recipient)
// type 1, 2 and 3
PreviousHashHeight int64 // 8 bytes; 64-bit index of the block height of the previous-block hash
PreviousBlockHash []byte // 32 bytes (SHA-256 of a recent block in the chain), not serialized
SenderId []byte // 32 bytes (256-bit public key of the sender)
SenderData []byte // up to 32 bytes, length when serialized: 1 byte + actual length
// type 1 and 2
Signature []byte // 64 bytes (512-bit signature)
// type 3
CycleSignatures []*CycleSignature
SignatureState int
// type 4
CycleSignatureTransactions []*Transaction
CycleTransactionVote bool
CycleTransactionSignature []byte
}
func ReadNewTransaction ¶
func ReadNewTransaction(r io.Reader) (*Transaction, error)
func (*Transaction) GetFee ¶
func (t *Transaction) GetFee() int64
Calculate the fee charged for this transaction.
func (*Transaction) GetSerializedLength ¶
func (t *Transaction) GetSerializedLength() int
Serializable interface: data length when serialized
func (*Transaction) Read ¶
func (t *Transaction) Read(r io.Reader, balanceListCycleTransaction bool) error
Serializable interface: read from reader.
func (*Transaction) SignatureIsValid ¶
func (t *Transaction) SignatureIsValid() bool
Verify this transaction's signature (if necessary) and return whether it's valid.
func (*Transaction) ToBytes ¶
func (t *Transaction) ToBytes() []byte
Serializable interface: convert to bytes.