Documentation ¶
Index ¶
- Constants
- Variables
- func Broadcast(s string, reqBody []byte) error
- func CacheTx(b []byte)
- func Flushall()
- func Init()
- func InitTranToRedis()
- func NewPost(endPoint string, reqBody []byte) (*http.Request, error)
- func SendPublicKey()
- func SendTrans()
- func SendTransV2()
- type BlockState
- func (bs *BlockState) CheckAndStore(hash string)
- func (bs *BlockState) Checkblock(b *common.Block) bool
- func (bs *BlockState) Checks(hash string) bool
- func (bs *BlockState) GetCurrB() common.Block
- func (bs *BlockState) GetTmpB() common.Block
- func (bs *BlockState) SetCurrB(b common.Block)
- func (bs *BlockState) SetTmpB(b common.Block)
- func (bs *BlockState) StoreBlock()
- type Client
- type Content
- type MerkleTree
- func (m *MerkleTree) GetMerklePath(content Content) ([][]byte, []int64, error)
- func (m *MerkleTree) MerkleRoot() []byte
- func (m *MerkleTree) RebuildTree() error
- func (m *MerkleTree) RebuildTreeWith(cs []Content) error
- func (m *MerkleTree) String() string
- func (m *MerkleTree) VerifyContent(content Content) (bool, error)
- func (m *MerkleTree) VerifyTree() (bool, error)
- type Node
- type ReVote
- type ReVoteMsg
- type Req
- type Server
- type ServerConfig
- type Sig
- type TestContent
- type TestInfo
- type TestInfoResponseNet
- type TransHash
- type Vote
- type VoteMsg
Constants ¶
const ( // DefaultServerPort is the default listening port for the server DefaultServerPort = 8000 // DefaultServerAddr is the default listening address for the server DefaultServerAddr = "0.0.0.0" )
const ( // Unknown error code ErrUnknown = 0 // HTTP method not allowed ErrMethodNotAllowed = 1 // No authorization header was found in request ErrNoAuthHdr = 2 // Failed reading the HTTP request body ErrReadingReqBody = 3 // HTTP request body was empty but should not have been ErrEmptyReqBody = 4 // HTTP request body was of the wrong format ErrBadReqBody = 5 // The token in the authorization header was invalid ErrBadReqToken = 6 // The caller does not have the "hf.Revoker" attibute ErrNotRevoker = 7 // Certificate to be revoked was not found ErrRevCertNotFound = 8 // Certificate to be revoked is not owned by expected user ErrCertWrongOwner = 9 // Identity of certificate to be revoked was not found ErrRevokeIDNotFound = 10 // User info was not found for issuee of revoked certificate ErrRevokeUserInfoNotFound = 11 // Certificate revocation failed for another reason ErrRevokeFailure = 12 // Failed to update user info when revoking identity ErrRevokeUpdateUser = 13 // Failed to revoke any certificates by identity ErrNoCertsRevoked = 14 // Missing fields in the revocation request ErrMissingRevokeArgs = 15 // Failed to get user's affiliation ErrGettingAffiliation = 16 // Revoker's affiliation not equal to or above revokee's affiliation ErrRevokerNotAffiliated = 17 // Failed to send an HTTP response ErrSendingResponse = 18 // The CA (Certificate Authority) name was not found ErrCANotFound = 19 // Authorization failure ErrAuthFailure = 20 // No username and password were in the authorization header ErrNoUserPass = 21 // Enrollment is currently disabled for the server ErrEnrollDisabled = 22 // Invalid user name ErrInvalidUser = 23 // Invalid password ErrInvalidPass = 24 // Invalid token in authorization header ErrInvalidToken = 25 // Certificate was not issued by a trusted authority ErrUntrustedCertificate = 26 // Certificate has expired ErrCertExpired = 27 // Certificate has been revoked ErrCertRevoked = 28 // Failed trying to check if certificate is revoked ErrCertRevokeCheckFailure = 29 // Certificate was not found ErrCertNotFound = 30 // Bad certificate signing request ErrBadCSR = 31 // Failed to get identity's prekey ErrNoPreKey = 32 // The caller was not authenticated ErrCallerIsNotAuthenticated = 33 // Invalid configuration setting ErrConfig = 34 // The caller does not have authority to generate a CRL ErrNoGenCRLAuth = 35 // Invalid RevokedAfter value in the GenCRL request ErrInvalidRevokedAfter = 36 // Invalid ExpiredAfter value in the GenCRL request ErrInvalidExpiredAfter = 37 // Failed to get revoked certs from the database ErrRevokedCertsFromDB = 38 // Failed to get CA cert ErrGetCACert = 39 // Failed to get CA signer ErrGetCASigner = 40 // Failed to generate CRL ErrGenCRL = 41 // Registrar does not have the authority to register an attribute ErrRegAttrAuth = 42 // Registrar does not own 'hf.Registrar.Attributes' ErrMissingRegAttr = 43 // Caller does not have appropriate affiliation to perform requested action ErrCallerNotAffiliated = 44 // Failed to verify if caller has appropriate type ErrGettingType = 45 // CA cert does not have 'crl sign' usage ErrNoCrlSignAuth = 46 // Incorrect level of database ErrDBLevel = 47 // Incorrect level of configuration file ErrConfigFileLevel = 48 // Failed to get user from database ErrGettingUser = 49 // Error processing HTTP request ErrHTTPRequest = 50 // Error connecting to database ErrConnectingDB = 51 // Failed to add identity ErrAddIdentity = 52 // Unauthorized to perform update action ErrUpdateConfigAuth = 53 // Registrar not authorized to act on type ErrRegistrarInvalidType = 54 // Registrar not authorized to act on affiliation ErrRegistrarNotAffiliated = 55 // Failed to remove identity ErrRemoveIdentity = 56 // Failed to get boolean query parameter ErrGettingBoolQueryParm = 57 // Failed to modify identity ErrModifyingIdentity = 58 // Caller does not have the appropriate role ErrMissingRole = 59 // Failed to add new affiliation ErrUpdateConfigAddAff = 60 // Failed to remove affiliation ErrUpdateConfigRemoveAff = 61 // Error occured while removing affiliation in database ErrRemoveAffDB = 62 // Error occured when making a Get request to database ErrDBGet = 63 // Failed to modiy affiliation ErrUpdateConfigModifyAff = 64 // Error occured while deleting user ErrDBDeleteUser = 65 // Certificate that is being revoked has already been revoked ErrCertAlreadyRevoked = 66 // Failed to get requested certificate(s) ErrGettingCert = 67 // Error occurred parsing variable as an integer ErrParsingIntEnvVar = 68 // CA certificate file is not found warning message ErrCACertFileNotFound = 69 )
const TransPool = "transPool"
Variables ¶
var ( Nodes = 4 Urls []string = []string{ "http://192.168.1.101:8000", "http://192.168.1.155:8001", "http://192.168.1.102:8002", "http://192.168.1.104:8003", } Ports string Sender string = "windows" MaxTransInBlock int = 6000 TransChangeStep = 200 //每一个大轮次区块中交易数量的变化幅度 NeedZip = false //是否需要压缩与解压缩(配套使用) Testflag = "" )
var (
HashTranMap = make(map[string]common.Transaction)
)
Functions ¶
func InitTranToRedis ¶
func InitTranToRedis()
func SendPublicKey ¶
func SendPublicKey()
func SendTransV2 ¶
func SendTransV2()
Types ¶
type BlockState ¶
func (*BlockState) CheckAndStore ¶
func (bs *BlockState) CheckAndStore(hash string)
func (*BlockState) Checkblock ¶
func (bs *BlockState) Checkblock(b *common.Block) bool
func (*BlockState) Checks ¶
func (bs *BlockState) Checks(hash string) bool
func (*BlockState) GetCurrB ¶
func (bs *BlockState) GetCurrB() common.Block
func (*BlockState) GetTmpB ¶
func (bs *BlockState) GetTmpB() common.Block
func (*BlockState) SetCurrB ¶
func (bs *BlockState) SetCurrB(b common.Block)
func (*BlockState) SetTmpB ¶
func (bs *BlockState) SetTmpB(b common.Block)
func (*BlockState) StoreBlock ¶
func (bs *BlockState) StoreBlock()
type MerkleTree ¶
MerkleTree is the container for the tree. It holds a pointer to the root of the tree, a list of pointers to the leaf nodes, and the merkle root.
func NewTree ¶
func NewTree(cs []Content) (*MerkleTree, error)
NewTree creates a new Merkle Tree using the content cs.
func NewTreeWithHashStrategy ¶
func NewTreeWithHashStrategy(cs []Content, hashStrategy func() hash.Hash) (*MerkleTree, error)
NewTreeWithHashStrategy creates a new Merkle Tree using the content cs using the provided hash strategy. Note that the hash type used in the type that implements the Content interface must match the hash type profided to the tree.
func (*MerkleTree) GetMerklePath ¶
func (m *MerkleTree) GetMerklePath(content Content) ([][]byte, []int64, error)
GetMerklePath: Get Merkle path and indexes(left leaf or right leaf)
func (*MerkleTree) MerkleRoot ¶
func (m *MerkleTree) MerkleRoot() []byte
MerkleRoot returns the unverified Merkle Root (hash of the root node) of the tree.
func (*MerkleTree) RebuildTree ¶
func (m *MerkleTree) RebuildTree() error
RebuildTree is a helper function that will rebuild the tree reusing only the content that it holds in the leaves.
func (*MerkleTree) RebuildTreeWith ¶
func (m *MerkleTree) RebuildTreeWith(cs []Content) error
RebuildTreeWith replaces the content of the tree and does a complete rebuild; while the root of the tree will be replaced the MerkleTree completely survives this operation. Returns an error if the list of content cs contains no entries.
func (*MerkleTree) String ¶
func (m *MerkleTree) String() string
String returns a string representation of the tree. Only leaf nodes are included in the output.
func (*MerkleTree) VerifyContent ¶
func (m *MerkleTree) VerifyContent(content Content) (bool, error)
VerifyContent indicates whether a given content is in the tree and the hashes are valid for that content. Returns true if the expected Merkle Root is equivalent to the Merkle root calculated on the critical path for a given content. Returns true if valid and false otherwise.
func (*MerkleTree) VerifyTree ¶
func (m *MerkleTree) VerifyTree() (bool, error)
VerifyTree verify tree validates the hashes at each level of the tree and returns true if the resulting hash at the root of the tree matches the resulting root hash; returns false otherwise.
type Node ¶
type Node struct { Tree *MerkleTree Parent *Node Left *Node Right *Node Hash []byte C Content // contains filtered or unexported fields }
Node represents a node, root, or leaf in the tree. It stores pointers to its immediate relationships, a hash, the content stored if it is a leaf, and other metadata.
type Server ¶
type Server struct { // The home directory for the server HomeDir string // BlockingStart if true makes the Start function blocking; // It is non-blocking by default. BlockingStart bool // The server's configuration Config *ServerConfig // contains filtered or unexported fields }
type ServerConfig ¶
type ServerConfig struct { // Listening port for the server Port int `def:"8000" opt:"p" help:"Listening port of server"` // Bind address for the server Address string `def:"0.0.0.0" help:"Listening address of server"` // Enables debug logging Debug bool `def:"false" opt:"d" help:"Enable debug level logging"` }
type TestContent ¶
type TestContent struct {
// contains filtered or unexported fields
}
func (TestContent) CalculateHash ¶
func (t TestContent) CalculateHash() ([]byte, error)
CalculateHash hashes the values of a TestContent