mirror of
				https://github.com/grassrootseconomics/eth-tracker.git
				synced 2025-11-03 18:11:53 +01:00 
			
		
		
		
	feat: cache contracts created by other cached accounts for instant indexing
This commit is contained in:
		
							parent
							
								
									ef28ec1298
								
							
						
					
					
						commit
						679d7f9927
					
				@ -11,7 +11,7 @@ func bootstrapEventRouter(cacheProvider cache.Cache, pubCB router.Callback) *rou
 | 
			
		||||
	handlerContainer := handler.New(cacheProvider)
 | 
			
		||||
	router := router.New(pubCB)
 | 
			
		||||
 | 
			
		||||
	router.RegisterContractCreationHandler(handler.HandleContractCreation())
 | 
			
		||||
	router.RegisterContractCreationHandler(handler.HandleContractCreation(handlerContainer))
 | 
			
		||||
 | 
			
		||||
	router.RegisterLogRoute(w3.H("0x26162814817e23ec5035d6a2edc6c422da2da2119e27cfca6be65cc2dc55ca4c"), handler.HandleFaucetGiveLog())
 | 
			
		||||
	router.RegisterLogRoute(w3.H("0xa226db3f664042183ee0281230bba26cbf7b5057e50aee7f25a175ff45ce4d7f"), handler.HandleIndexAddLog(handlerContainer))
 | 
			
		||||
 | 
			
		||||
@ -9,7 +9,7 @@ import (
 | 
			
		||||
 | 
			
		||||
const contractCreationEventName = "CONTRACT_CREATION"
 | 
			
		||||
 | 
			
		||||
func HandleContractCreation() router.ContractCreationHandlerFunc {
 | 
			
		||||
func HandleContractCreation(hc *HandlerContainer) router.ContractCreationHandlerFunc {
 | 
			
		||||
	return func(ctx context.Context, ccp router.ContractCreationPayload, c router.Callback) error {
 | 
			
		||||
		contractCreationEvent := event.Event{
 | 
			
		||||
			Block:           ccp.Block,
 | 
			
		||||
@ -23,6 +23,10 @@ func HandleContractCreation() router.ContractCreationHandlerFunc {
 | 
			
		||||
			},
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := hc.cache.Add(ctx, ccp.ContractAddress); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return c(ctx, contractCreationEvent)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user