github.com/aergoio/aergo@v1.3.1/cmd/brick/context/context.go (about)

     1  // blockchain
     2  
     3  // wording directory
     4  
     5  // height?
     6  
     7  // oo
     8  
     9  package context
    10  
    11  import (
    12  	"strconv"
    13  
    14  	"github.com/aergoio/aergo/contract"
    15  )
    16  
    17  var CurrentCtx *context
    18  
    19  var GitHash = "?"
    20  
    21  func init() {
    22  	Reset()
    23  }
    24  
    25  type context struct {
    26  	chain *contract.DummyChain
    27  }
    28  
    29  func Reset() {
    30  	chain, err := contract.LoadDummyChain()
    31  	if err != nil {
    32  		panic(err)
    33  	}
    34  	CurrentCtx = &context{
    35  		chain: chain,
    36  	}
    37  }
    38  
    39  func LivePrefix() (string, bool) {
    40  	height := strconv.FormatUint(CurrentCtx.chain.BestBlockNo(), 10)
    41  	ret := height + "> "
    42  	return ret, true
    43  }
    44  
    45  func Get() *contract.DummyChain {
    46  	return CurrentCtx.chain
    47  }