package
1.2.2
Repository: https://github.com/alexfordev/atlas.git
Documentation: pkg.go.dev

# README

Atlas multilChain introduce

Multichain databases are used to store data from different chains,Distinguishing different chains with ChainType uint64。The data structure is:

type HeaderChainStore struct {
	chainDb          ethdb.Database
	currentChainType rawdb.ChainType
	Mu               sync.RWMutex // blockchaindb insertion lock
	rand             *mrand.Rand
}

Call through the following function when you want to use multilChainDb. ps:The only identification of the chain is chainType

func GetStoreMgr(chainType rawdb.ChainType) (*HeaderChainStore, error) {
	if storeMgr == nil {
		return nil, error01
	}
	storeMgr.currentChainType = chainType
	return storeMgr, nil
}
for Example:
    hc, error := GetStoreMgr(chainType)
    if error !=nil {
        ....
    }

Building the multilChain db source

When the project starts, the multilChain db is initialized within the makeFullNode() function. ps:【multiChain.NewStoreDb(ctx, &cfg.Eth) 】

Interface function

Write block header information:

nameparamsintroduce
WriteHeaderheaderheaderInfo (ethereum.Header)

Get block header information with hash and number .

nameparamsintroducereturn type
ReadHeaderHashhashValue*ethereum.Header
numberblockNumber
Insert what you want to deposit
nameparamsintroduce
InsertHeaderChainchainsIncoming []*ethereum.Header
starttime.Time for log

for Example:
   	status, error := hc.InsertHeaderChain(chain, time.Now())
    if error !=nil {
        ....
    }
   	if status != wantStatus {
   		t.Errorf("wrong write status from InsertHeaderChain: got %v, want %v", status, wantStatus)
   	}
ps:
status value
NonStatTyState   WriteStatus = iota // not the Canonical will be ignore
CanonStatTyState                    // the Canonical
SideStatTyState                     // the branch

Get block number with hash .

nameparamsreturn type
GetBlockNumberhash*uint64

Gets the block height of the current type chain:

namereturn type
CurrentHeaderNumberuint64

Gets the block lastHash of the current type chain:

namereturn type
CurrentHeaderHashcommon.Hash

Get difficulty with hash:

namereturn type
GetTdByHash*big.Int
Get header information by hash:
namereturn type
GetHeaderByHash*Header
Get header information for a type of chain through number:
namereturn type
GetHeaderByNumber*Header

Get the headhash of a type of specification chain through number:

namereturn type
ReadCanonicalHashcommon.Hash