MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / produceAndStoreBlock

Method produceAndStoreBlock

blockproducer/chain.go:909–937  ·  view source on GitHub ↗
(
	now time.Time, priv *asymmetric.PrivateKey)

Source from the content-addressed store, hash-verified

907}
908
909func (c *Chain) produceAndStoreBlock(
910 now time.Time, priv *asymmetric.PrivateKey) (out *types.BPBlock, err error,
911) {
912 var (
913 bl *types.BPBlock
914 br *branch
915 ierr error
916 )
917
918 defer c.stat()
919 c.Lock()
920 defer c.Unlock()
921
922 // Try to produce new block
923 if br, bl, ierr = c.headBranch.produceBlock(
924 c.heightOfTime(now), now, c.address, priv,
925 ); ierr != nil {
926 err = errors.Wrapf(ierr, "failed to produce block at head %s",
927 c.headBranch.head.hash.Short(4))
928 return
929 }
930 if ierr = c.replaceAndSwitchToBranch(bl, c.headIndex, br); ierr != nil {
931 err = errors.Wrapf(ierr, "failed to switch branch #%d:%s",
932 c.headIndex, c.headBranch.head.hash.Short(4))
933 return
934 }
935 out = bl
936 return
937}
938
939// now returns the current coordinated chain time.
940func (c *Chain) now() time.Time {

Callers 1

produceBlockMethod · 0.95

Calls 5

statMethod · 0.95
heightOfTimeMethod · 0.95
ShortMethod · 0.80
produceBlockMethod · 0.45

Tested by

no test coverage detected